]> _ Git - fluidbook-html5.git/commitdiff
fix #2176 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Aug 2018 14:29:06 +0000 (16:29 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Aug 2018 14:29:06 +0000 (16:29 +0200)
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.search.js

index 16861d3f388fcf522ff4f123a00065ab0d6f8ea5..e05d1123161b48b25ac02e1ee8d7236ad55374ae 100644 (file)
@@ -101,11 +101,14 @@ FluidbookMenu.prototype = {
         } else if (view == 'iframe') {
             this.openIframe(param1, cb);
         } else if (view == 'search') {
-
+            this.openSearch(param1, cb);
         } else {
             this['open' + camelView](param1, param2, cb);
         }
     },
+    openSearch: function (q, cb) {
+        this.fluidbook.nav.openSearch(q, cb);
+    },
     openingView: function (callback) {
         var $this = this;
         this.fluidbook.resize.resizeView();
@@ -520,7 +523,7 @@ FluidbookMenu.prototype = {
                 break;
             case 'index':
                 fullscreen = true;
-                $("#indexViewHolder").css('width',Math.floor(ww / 230) * 230);
+                $("#indexViewHolder").css('width', Math.floor(ww / 230) * 230);
                 break;
             case 'share':
                 w = 200;
index 38cf5b261d2d60b697ade328c01f154c7aa01bf1..7303ec1ece778f6a171fa0f7c54b6d0b6bb03497 100644 (file)
@@ -655,13 +655,7 @@ FluidbookNav.prototype = {
         $(document).on('click', '#horizontalNav_searchIcon', function (event) {
             event.preventDefault()
 
-            if (!fluidbook.search.isSearchActive()) {
-                fluidbook.search.initSearchHints(); // Clears menu and only displays search box
-                $this.menuAPI.closeAllPanels(); // Make sure we're on the main panel with the search box
-            }
-            $this.menuAPI.open();
-
-            $('#q').focus(); // Put cursor in the search field
+            $this.openSearch();
         });
 
         // Full screen toggle
@@ -725,6 +719,23 @@ FluidbookNav.prototype = {
 
     },
 
+    openSearch: function (q, cb) {
+        if (!fluidbook.search.isSearchActive()) {
+            fluidbook.search.initSearchHints(); // Clears menu and only displays search box
+            this.menuAPI.closeAllPanels(); // Make sure we're on the main panel with the search box
+        }
+        this.menuAPI.open();
+
+        if (q !== undefined) {
+            $("#q").val(q);
+            this.fluidbook.search.submitForm();
+        }
+        $('#q').focus(); // Put cursor in the search field
+        if (cb !== undefined) {
+            cb();
+        }
+    },
+
     getMenuCloseButton: function () {
         var $this = this,
             buttonID = 'menuClose';
index 7783e85010a8727de9b8f1f0afd20cdc8ec3fb84..393bda6d46fdbe1f1ad888396859b7ded92a434a 100644 (file)
@@ -493,6 +493,8 @@ FluidbookSearch.prototype = {
             return false;
         }
 
+        window.location.hash = '/search/' + q;
+
         this.fluidbook.stats.track(1, this.fluidbook.currentPage, q);
         var $this = this;
         this.find(q, function (results) {