From: Stephen Cameron Date: Mon, 19 Jun 2017 16:27:12 +0000 (+0200) Subject: Search hints integration with MMenu. WIP #807 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=006bea02e069eb3df8497ea12fb0c8b901dac6ec;p=fluidbook-html5.git Search hints integration with MMenu. WIP #807 @4 --- diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 5baf47d4..fed53a29 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -713,6 +713,14 @@ Fluidbook.prototype = { return this.datas.numerotation.indexOf(page) + 1; }, + initSearchHints: function () { + + this.menuSearchHints = $('#menuSearchHints'); + + if (this.menuSearchHints.hasClass('mm-hidden')) { + this.nav.menuAPI.openPanel(this.menuSearchHints, false); + } + }, getSearchHints: function (q) { var $this = this; @@ -723,12 +731,15 @@ Fluidbook.prototype = { }, displaySearchHints: function (hints) { - this.hideSearchHints(); + var $this = this; + + //this.hideSearchHints(); if (hints.length == 0) { return; } + this.menuSearchHints.html(''); $.each(hints, function (k, v) { - $("#searchHints").append('' + v[0] + ' (' + v[1] + ')'); + $this.menuSearchHints.append('' + v[0] + ' (' + v[1] + ')'); }); var qoffset = $("#q").offset(); var top = qoffset.top + $("#q").outerHeight() + 5; @@ -742,9 +753,10 @@ Fluidbook.prototype = { this.search.kill(); }, hideSearchHints: function () { - this.killLastSearchHint(); - $("#searchHints").html(''); - $("#searchHints").hide(); + // this.killLastSearchHint(); + // $("#searchHints").html(''); + // $("#searchHints").hide(); + this.nav.menuAPI.closeAllPanels(); // Todo: see if we can just close the hints panel. Doesn't seem to work using .closePanel(...). See how built-in search plugin works }, getLocationToShare: function () { if (this.datas.phonegap) { diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index 7a0684f4..2c448c7d 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -282,6 +282,8 @@ FluidbookNav.prototype = { if (this.chaptersMenuHTML != '') { $('#chapters').parent().append(this.chaptersMenuHTML); } + $('#menu').append(''); + $('#menu').append(''); this.initMenu(); $(this.fluidbook).trigger('fluidbooknavready'); @@ -326,7 +328,10 @@ FluidbookNav.prototype = { return false; }); - $("#q").keyup(searchHints); + + //$("#q").keyup(searchHints); + $(document).on('keyup', '#q', searchHints); + $(document).on('click', ".hint", function () { var e = $("#q").val().split(' '); e.pop(); @@ -336,11 +341,11 @@ FluidbookNav.prototype = { return false; }) - $("#q").blur(function (e) { - setTimeout(function () { - $this.fluidbook.hideSearchHints(); - }, 250); - }); + // $("#q").blur(function (e) { + // setTimeout(function () { + // $this.fluidbook.hideSearchHints(); + // }, 250); + // }); //this.menu.append($("#search")); var searchHTML = $('#search').html(); diff --git a/js/main.js b/js/main.js index 566df181..31711d70 100644 --- a/js/main.js +++ b/js/main.js @@ -500,6 +500,7 @@ function setBackground(page, resolution) { function searchHints() { if ($("#q").val().length >= 3) { + fluidbook.initSearchHints(); fluidbook.getSearchHints($("#q").val()); } else { try {