From 72b2a5f805d6515c3a9fb570f867b496daaa2ad0 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Thu, 21 Sep 2017 16:44:37 +0200 Subject: [PATCH] Done #1676 @1.5 --- js/libs/fluidbook/fluidbook.nav.js | 46 ++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index e5453074..e2f16ce3 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -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 = '' + getSpriteIcon('interface-menu') + '' + this.fluidbook.l10n.__('Menu') + ''; $('#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; -- 2.39.5