From: Stephen Cameron Date: Mon, 12 Jun 2017 16:01:23 +0000 (+0200) Subject: WIP #807 @4.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f689163b91df18150ee7f135d605e9d221146173;p=fluidbook-html5.git WIP #807 @4.5 --- diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 88f1134f..9241e264 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -114,6 +114,9 @@ FluidbookMenu.prototype = { }, displayResults: function (data, group, callback) { + + // ToDo: investigate MMenu dynamic content for displaying in menu: http://mmenu.frebsite.nl/tutorials/dynamic-content.html + var $this = this; var results = data.results; var hideNoResults = !this.fluidbook.datas.searchShowNoResultsPages; diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index 80adbb7a..1d0c5ed7 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -2,11 +2,49 @@ function FluidbookNav(fluidbook) { this.fluidbook = fluidbook; this._dimensions = this.fluidbook.datas.iconsDimensions; this._inited = false; + this.menu = $("#nav"); this.setNav(); } FluidbookNav.prototype = { + initMenu: function () { + var $this = this, + navbars = [ + { + "position": "bottom", + "content": [ + '[Sharing links]' + ] + } + ]; + + if (this.fluidbook.datas.search) { + navbars.push({ + "position": "top", + "content": [ this.getSearch() ] + }); + } + + $('#nav').mmenu({ + "extensions": [ + "pagedim-black" + ], + "offCanvas": { + "position": "right", + "zposition": "front" + }, + "navbars": navbars + }); + + this.menuAPI = $('#nav').data('mmenu'); + + $(document).on('click', '#menuOpener', function (e) { + e.preventDefault(); + $this.menuAPI.open(); + }); + + }, getIcon: function (name) { var src = 'data/images/' + name + '.'; if (this.fluidbook.support.SVG) { @@ -20,14 +58,14 @@ FluidbookNav.prototype = { return this.fluidbook.loader.getImage(src, this._dimensions[name][0], this._dimensions[name][1]); }, addLink: function (name, href, id, help, before, c) { - if ($("#nav").find('#' + id).length > 0) { + if (this.menu.find('#' + id).length > 0) { return; } - var l = this.getLink(name, href, id, help, c); + var l = '
  • ' + this.getLink(name, href, id, help, c) + '
  • '; if (before == undefined) { - $("#nav").append(l); + this.menu.find('ul').append(l); } else { - $("#nav #" + before).before(l); + this.menu.find("ul #" + before).before(l); } }, getLink: function (name, href, id, help, className, icon) { @@ -48,6 +86,12 @@ FluidbookNav.prototype = { if (icon) { res += this.getIcon(name); } + + // Temporary: use the help text as the link text - we probably need a dedicated string for these + if (help != undefined && help != '') { + res += ' ' + this.fluidbook.l10n.__(help); + } + res += ''; return res; }, @@ -67,6 +111,12 @@ FluidbookNav.prototype = { var $this = this; // index, chapters, print, friend, bookmark, pdf, archives, basket, fullscreen, sound, 3d, help + var menuOpener = '' + this.fluidbook.l10n.__('Menu') + ''; + $('#main header').append(menuOpener); + + // Add holder list element for menu items + this.menu.append(''); + try { var skipHome = (window.localStorage.getItem('home') === '0'); var forceHome = (window.localStorage.getItem('home') === '1'); @@ -186,13 +236,14 @@ FluidbookNav.prototype = { } } - if (this.fluidbook.datas.search) { - this.setSearch(); - } + // if (this.fluidbook.datas.search) { + // this.setSearch(); + // } if (this.fluidbook.datas.afterSearch != '' && this.fluidbook.datas.themeEnableAfterSearch) { this.setAfterSearch(); } this.setInterface(); + this.initMenu(); $(this.fluidbook).trigger('fluidbooknavready'); }, addMultilangLink: function (langs) { @@ -202,23 +253,26 @@ FluidbookNav.prototype = { return; } - $("#nav").append(l); - $("#nav #locales").css('background-image', 'url("images/flags/' + flag + '.png")'); + this.menu.append(l); + this.menu.find("#locales").css('background-image', 'url("images/flags/' + flag + '.png")'); }, - setSearch: function () { + getSearch: function () { var $this = this; var res = '
    '; res += ''; res += this.getLink('interface-search', '#', 'submitSearch'); res += '
    '; $("#search").append(res); - $("#submitSearch").click(function () { + + // Search submit button + $(document).on('click', '#submitSearch', function (e) { $("#searchForm").submit(); + e.preventDefault(); return false; }) // Search form - $("#searchForm").submit(function () { + $(document).on('submit', '#searchForm', function () { var q = $("#q").val(); if (q == '') { return false; @@ -241,10 +295,14 @@ FluidbookNav.prototype = { $this.fluidbook.hideSearchHints(); }, 250); }); - $("#nav").append($("#search")); + + //this.menu.append($("#search")); + var searchHTML = $('#search').html(); + $('#search').remove(); + return searchHTML; }, setAfterSearch: function () { - $("#nav").append('
    ' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '
    '); + this.menu.find('ul').append('
    ' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '
    '); }, setInterface: function () { diff --git a/js/libs/mmenu/jquery.mmenu.all.js b/js/libs/mmenu/jquery.mmenu.all.js new file mode 100644 index 00000000..f3514315 --- /dev/null +++ b/js/libs/mmenu/jquery.mmenu.all.js @@ -0,0 +1,186 @@ +;(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('jquery')); + } else { + root.jquery_mmenu_all_js = factory(root.jQuery); + } +}(this, function(jQuery) { +/* + * jQuery mmenu v6.1.0 + * @requires jQuery 1.7.0 or later + * + * mmenu.frebsite.nl + * + * Copyright (c) Fred Heusschen + * www.frebsite.nl + * + * License: CC-BY-NC-4.0 + * http://creativecommons.org/licenses/by-nc/4.0/ + */ +!function(e){function t(){e[n].glbl||(r={$wndw:e(window),$docu:e(document),$html:e("html"),$body:e("body")},s={},a={},o={},e.each([s,a,o],function(e,t){t.add=function(e){e=e.split(" ");for(var n=0,i=e.length;n