From 223c0d342f4660ebe5eee64a87c074d1176eb150 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Wed, 14 Jun 2017 19:34:10 +0200 Subject: [PATCH] Integration of contents index into MMenu. WIP #807 @5.5 --- js/libs/fluidbook/fluidbook.nav.js | 72 +++++++++++++++++++++++++++--- style/fluidbook.less | 2 +- style/mmenu/mmenu.less | 5 +++ 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index ae3ec6f7..7a0684f4 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -4,6 +4,7 @@ function FluidbookNav(fluidbook) { this._inited = false; this.menuIsOpen = false; this.menu = $("#menu"); // Renamed from #nav because mmenu animations weren't working (probably due to some other script interference) + this.chaptersMenuHTML = ''; this.setNav(); } @@ -96,7 +97,9 @@ FluidbookNav.prototype = { if (icon == undefined) { icon = true; } - var res = ' (useful for MMenu) + if (href == '') { + return ''; + } else { + return ''; + } }, setNav: function () { if (this._inited == true) { @@ -188,7 +195,11 @@ FluidbookNav.prototype = { if (this.fluidbook.datas.chaptersPage != '') { this.addLink('nav-sommaire', '#/page/' + this.fluidbook.datas.chaptersPage, 'chapters', 'chapters'); } else if (this.fluidbook.datas.chapters.length > 0) { - this.addLink('nav-sommaire', '#/chapters', 'chapters', 'chapters'); + // this.addLink('nav-sommaire', '#/chapters', 'chapters', 'chapters'); + this.addLink('nav-sommaire', '', 'chapters', 'chapters'); + + // Get HTML for submenus (appended later) + this.chaptersMenuHTML = this.makeChapterLists(this.fluidbook.datas.chapters); } } } else if (icon == 'friend') { @@ -237,7 +248,7 @@ FluidbookNav.prototype = { this.addLink('nav-archives', '#/archives', 'archives', '!' + this.fluidbook.datas.archivesLabel); } } else if (icon == 'help') { - this.addLink('nav-help', '#', 'help', ''); + this.addLink('nav-help', '#', 'help', 'help'); } else if (icon == 'zoom' && !this.fluidbook.support.isMobile) { this.addLink('nav-zoomin', '#', 'zoomin', 'zoom in'); this.addLink('nav-zoomout', '#', 'zoomout', 'zoom out'); @@ -267,7 +278,12 @@ FluidbookNav.prototype = { this.setAfterSearch(); } this.setInterface(); + + if (this.chaptersMenuHTML != '') { + $('#chapters').parent().append(this.chaptersMenuHTML); + } this.initMenu(); + $(this.fluidbook).trigger('fluidbooknavready'); }, addMultilangLink: function (langs) { @@ -301,7 +317,13 @@ FluidbookNav.prototype = { if (q == '') { return false; } + window.location.hash = '/search/' + q; + + if ($this.menuIsOpen) { + $this.menuAPI.close(); + } + return false; }); $("#q").keyup(searchHints); @@ -326,7 +348,7 @@ FluidbookNav.prototype = { return searchHTML; }, setAfterSearch: function () { - this.menu.find('ul').append('
' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '
'); + this.menu.find('ul').append('
'); }, setInterface: function () { @@ -335,5 +357,43 @@ FluidbookNav.prototype = { $('#interface').append(res); $(document).on('click', '#next', goNextPage); $(document).on('click', '#previous', goPreviousPage); + }, + + // Build nested lists from chapters + makeChapterLists: function (chapters) { + + var currentLevel = 0, + loopIndex = 0, + html = '
'; + + return html; } }; \ No newline at end of file diff --git a/style/fluidbook.less b/style/fluidbook.less index 804c7150..7cdd5b8d 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -540,7 +540,7 @@ header { background-color: @menu-background; color: @menu-text; - a { + a, span { padding: 10px; img { diff --git a/style/mmenu/mmenu.less b/style/mmenu/mmenu.less index b080d939..8207c052 100644 --- a/style/mmenu/mmenu.less +++ b/style/mmenu/mmenu.less @@ -15,6 +15,11 @@ } } +// Submenu arrows < > +.mm-menu .mm-btn:after, .mm-menu .mm-btn:before, .mm-menu .mm-listview>li .mm-next:after { + border-color: @menu-text; +} + .mm-hasnavbar-top-1 .mm-panels { top: 60px; } -- 2.39.5