From 190e62a6ad7e6e249ad56161c33d9d29fb5a2636 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 20 Sep 2017 17:26:32 +0200 Subject: [PATCH] fix #1683 @0.5 --- js/libs/fluidbook/fluidbook.js | 38 --------------------------- js/libs/fluidbook/fluidbook.nav.js | 2 +- js/libs/fluidbook/fluidbook.search.js | 33 ++++++++++++++++++++++- js/main.js | 8 +++--- style/fluidbook.less | 2 +- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 06ebb9b5..4b082419 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -58,9 +58,7 @@ Fluidbook.prototype = { this.privacy = new FluidbookPrivacy(this); this.refw = 0; this.refh = 0; - this.searchHintXHR = null; this.searchString = ''; - this.vectorTexts = !this.support.imagesVersion; this.displayOnePage = false; this.indexHTML = ''; @@ -726,39 +724,6 @@ Fluidbook.prototype = { return i + 1; }, - getSearchHints: function (q) { - - var $this = this; - this.killLastSearchHint(); - this.search.getHints(q, function (r) { - $this.displaySearchHints(r); - }); - }, - displaySearchHints: function (hints) { - - this.hideSearchHints(); - if (hints.length == 0) { - return; - } - $.each(hints, function (k, v) { - $("#searchHints").append('' + v[0] + ' (' + v[1] + ')'); - }); - var qoffset = $("#q").offset(); - var top = qoffset.top + $("#q").outerHeight() + 5; - var left = qoffset.left; - if (this.l10n.dir == 'rtl') { - left = -1 * ($(window).width() - left - $("#q").outerWidth()); - } - $("#searchHints").css({top: top, left: left}).show(); - }, - killLastSearchHint: function () { - this.search.kill(); - }, - hideSearchHints: function () { - this.killLastSearchHint(); - $("#searchHints").html(''); - $("#searchHints").hide(); - }, print: function () { var $this = this; var pdf; @@ -897,9 +862,6 @@ Fluidbook.prototype = { return a.cloneNode(false).href; }, - highlightSearchTerms: function (pageNr) { - return; - }, touchOffset: function (offset) { offset *= $("#currentDoublePage").width(); $("#currentDoublePage").addClass('sliding'); diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index d0edb279..9bbe4674 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -255,7 +255,7 @@ FluidbookNav.prototype = { $("#q").blur(function (e) { setTimeout(function () { - $this.fluidbook.hideSearchHints(); + $this.fluidbook.search.hideSearchHints(); }, 250); }); $("#nav").append($("#search")); diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index a40e4aed..cd6faccc 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -290,6 +290,37 @@ FluidbookSearch.prototype = { $(h).attr('data-hash', hash); $(h).css(coords); $("#searchHighlights").append(h); - } + }, + getSearchHints: function (q) { + var $this = this; + this.killLastSearchHint(); + this.getHints(q, function (r) { + $this.displaySearchHints(r); + }); + }, + displaySearchHints: function (hints) { + this.hideSearchHints(); + if (hints.length == 0) { + return; + } + $.each(hints, function (k, v) { + $("#searchHints").append('' + v[0] + ' '); + }); + var qoffset = $("#q").offset(); + var top = qoffset.top + $("#q").outerHeight() + 5; + var left = qoffset.left; + if (this.fluidbook.l10n.dir == 'rtl') { + left = -1 * ($(window).width() - left - $("#q").outerWidth()); + } + $("#searchHints").css({top: top, left: left}).show(); + }, + killLastSearchHint: function () { + this.kill(); + }, + hideSearchHints: function () { + this.killLastSearchHint(); + $("#searchHints").html(''); + $("#searchHints").hide(); + }, }; diff --git a/js/main.js b/js/main.js index 5c8334b8..d3c08a45 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,7 @@ var DEVICE_READY_BEFORE_JQUERY = false; var JQUERY_READY = false; document.addEventListener('deviceready', _onDeviceReady, false); + function _onDeviceReady() { if (JQUERY_READY) { onDeviceReady(); @@ -502,13 +503,12 @@ function setBackground(page, resolution) { } function searchHints() { - if ($("#q").val().length >= 3) { - fluidbook.getSearchHints($("#q").val()); + if ($("#q").val().length >= 1) { + fluidbook.search.getSearchHints($("#q").val()); } else { try { - fluidbook.hideSearchHints(); + fluidbook.search.hideSearchHints(); } catch (err) { - } } } diff --git a/style/fluidbook.less b/style/fluidbook.less index 6ec1922e..1b102042 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -681,7 +681,7 @@ header { padding: 5px; display: none; z-index: 25; - position: relative; + position: absolute; } #logo { -- 2.39.5