]> _ Git - fluidbook-html5.git/commitdiff
Done #1676 @1.5
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 21 Sep 2017 14:44:37 +0000 (16:44 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 21 Sep 2017 14:44:37 +0000 (16:44 +0200)
js/libs/fluidbook/fluidbook.nav.js

index e5453074ea0e0e5fc061326dc321bd05a736869e..e2f16ce354a7a7945432841ae21ba84165063d16 100644 (file)
@@ -220,12 +220,17 @@ FluidbookNav.prototype = {
          * __('home')
          * __('full screen')
          */
-        var $this = this;
-        // index, chapters, print, friend, bookmark, pdf, archives, basket, fullscreen, sound, 3d, help
+        var $this = this,
+            navOrder = this.fluidbook.datas.navOrder; // Default desktop order, maybe be overridden later
 
         // MMenu specific elements
         if (navType == 'menu') {
 
+            // Use navOrderH (mobile icon order) if it is set
+            if (this.fluidbook.datas.navOrderH.length > 0) {
+                navOrder = this.fluidbook.datas.navOrderH;
+            }
+
             var menuOpener = '<a href="#" id="menuOpener">' + getSpriteIcon('interface-menu') + '<span class="label">' + this.fluidbook.l10n.__('Menu') + '</span></a>';
             $('#main header').append(menuOpener);
 
@@ -259,23 +264,46 @@ FluidbookNav.prototype = {
 
 
         // All possible icons and default ordering
-        var all = "extra,index,chapters,search,friend,print,bookmark,archives,basket,fullscreen,sound,3d,help,lang".split(",");
+        var all = [
+            "extra",
+            "index",
+            "chapters",
+            "search",
+            "friend",
+            "print",
+            "pdf",
+            "bookmark",
+            "archives",
+            "basket",
+            "fullscreen",
+            "sound",
+            "3d",
+            "help",
+            "lang",
+        ];
+
+        // Note: no longer necessary to hide icons this way because their event handlers are set in initEventHandlers()
         // var hide = array_diff(all, this.fluidbook.datas.navOrder); // Array of icons that aren't in the navOrder list and should be hidden
         // var loop = [].concat(this.fluidbook.datas.navOrder).concat(hide);
-        var loop = this.fluidbook.datas.navOrder;
-        var localeIconIndex;
+
+        // Fallback to default list if navOrder is still empty for some reason
+        if (navOrder.length == 0) {
+            navOrder = all;
+        }
 
         if (!this.fluidbook.datas.displayChaptersIcon) {
             hide.push('chapters');
         }
 
         // If the locales icon is included, it should always be placed last in the list for formatting reasons
-        // if ((localeIconIndex = loop.indexOf('lang')) !== -1) {
-        //     loop.push(loop.splice(localeIconIndex, 1)[0]); // Push to end of array
+        // Update: disabled this to allow it to be set anywhere in the list
+        // var localeIconIndex;
+        // if ((localeIconIndex = navOrder.indexOf('lang')) !== -1) {
+        //     navOrder.push(navOrder.splice(localeIconIndex, 1)[0]); // Push to end of array
         // }
 
-        for (var e in loop) {
-            var icon = loop[e];
+        for (var i in navOrder) {
+            var icon = navOrder[i];
             //var visible = hide.indexOf(icon) == -1;
             var link = null;