]> _ Git - fluidbook-html5.git/commitdiff
wip #7461 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 May 2025 11:09:48 +0000 (13:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 May 2025 11:09:48 +0000 (13:09 +0200)
js/libs/fluidbook/fluidbook.burger.js
js/libs/fluidbook/fluidbook.search.js
js/main.js

index 4be87c94c4f8b86a45e37e73f77ac6fa760636da..1672e542d49738025391d1564d33340570734534 100644 (file)
@@ -179,28 +179,34 @@ FluidbookBurger.prototype = {
         });
     },
 
-    open: function () {
+    open: function (focusClose) {
+        if (focusClose === undefined) {
+            focusClose = true;
+        }
         let $this = this;
-        this.isOpened = true;
-        $('body').addClass('menu-open');
         clearTimeout(this.closeTimeout);
-        $("#menu,#menuOverlay").show();
-        setTimeout(function () {
-            $("#menu").addClass('open');
+        if (!this.isOpened) {
+            $('body').addClass('menu-open');
+            $("#menu,#menuOverlay").show();
             setTimeout(function () {
-                if ($this.fluidbook.input.isUsingKeyboard()) {
-                    console.log('focus close')
-                    $("#menuClose").get(0).focus();
+                $("#menu").addClass('open');
+                if (focusClose) {
+                    setTimeout(function () {
+                        if ($this.fluidbook.input.isUsingKeyboard()) {
+                            $("#menuClose").get(0).focus();
+                        }
+                    }, 500);
                 }
-            }, 500);
-        }, 10);
-
-        $("#main").attr('aria-hidden', 'true');
-        $("#view").attr('aria-hidden', 'true');
-        $("#menu").attr('aria-hidden', 'false');
-        $("#menuOpener").attr('aria-expanded', 'true');
-
+            }, 10);
 
+            $("#main").attr('aria-hidden', 'true');
+            $("#view").attr('aria-hidden', 'true');
+            $("#menu").attr('aria-hidden', 'false');
+            $("#menuOpener").attr('aria-expanded', 'true');
+        } else {
+            console.log('already opened');
+        }
+        this.isOpened = true;
     },
 
     closeAll: function () {
@@ -231,11 +237,11 @@ FluidbookBurger.prototype = {
     },
 
     hideMenuItems: function () {
-        gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.1, autoAlpha: 0});
+        gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.1, opacity: 0, display: 'none'});
     },
 
     showMenuItems: function () {
-        gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.3, autoAlpha: 1});
+        gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.3, opacity: 1, display: 'block'});
     },
 
     openSearch: function (q, cb) {
@@ -252,7 +258,7 @@ FluidbookBurger.prototype = {
                 this.fluidbook.search.submitForm();
             }
         } else {
-            this.open();
+            this.open(false);
             $('#q').focus(); // Put cursor in the search field
         }
 
@@ -330,9 +336,10 @@ FluidbookBurger.prototype = {
                 case 38: // Up arrow
                 case 39: // Right arrow
                 case 40: // Down arrow
+                case 9: // Tab
                     return; // Ignore these keys
                 default:
-                    searchHints();
+                    $this.fluidbook.search.searchHints();
             }
         });
 
index 3c6110ff1a06c7055d0df708b7b2c732a600be08..fc7d0b6490fdc0968e713f85b97c4421d34ea77f 100644 (file)
@@ -751,6 +751,22 @@ FluidbookSearch.prototype = {
         });
     },
 
+    searchHints: function () {
+        this.hideSearchResults();
+        if ($("#q").val().length >= 1) {
+            this.initSearchHints();
+            this.getSearchHints($("#q").val());
+        } else {
+            try {
+                if ($("#q").val().length == 0) {
+                    this.hideSearchHints();
+                    this.fluidbook.nav.burger.showMenuItems(); // Show main menu items that were hidden previously
+                }
+            } catch (err) {
+            }
+        }
+    },
+
     displaySearchHints: function (hints) {
         if (!this.hintsEnabled) {
             return;
index 7dda1d0d8dbd2db270049f57cf21bdbfc57f32a3..fcf2cf76a552856b780ebb5630fcbab34ee4ad8d 100644 (file)
@@ -1,4 +1,4 @@
-window.stats=new FluidbookStats();
+window.stats = new FluidbookStats();
 
 var DEVICE_READY_BEFORE_JQUERY = false;
 var JQUERY_READY = false;
@@ -267,7 +267,7 @@ try {
         }
         try {
             window.fluidbook.loadPlugins();
-        }catch (e){
+        } catch (e) {
 
         }
         $(document).trigger('fluidbook.init');
@@ -281,10 +281,10 @@ try {
             window.fluidbook.ready();
         }
 
-        if(this.fluidbook.secureOKDone) {
+        if (this.fluidbook.secureOKDone) {
             initEvents();
-        }else{
-            this.fluidbook.initEventsWhenSecureOK=true;
+        } else {
+            this.fluidbook.initEventsWhenSecureOK = true;
         }
     }
 
@@ -308,7 +308,6 @@ try {
         }
 
 
-
         $(window).on('hashchange', function () {
             if (maskHashChange) {
                 return;
@@ -481,21 +480,7 @@ function setBackground(page, resolution) {
     fluidbook.setBackground(page, resolution);
 }
 
-function searchHints() {
-    if ($("#q").val().length >= 1) {
-        fluidbook.search.initSearchHints();
-        fluidbook.search.getSearchHints($("#q").val());
-    } else {
-        try {
-            if ($("#q").val().length == 0) {
-                fluidbook.search.hideSearchHints();
-                fluidbook.search.hideSearchResults();
-                fluidbook.nav.burger.showMenuItems(); // Show main menu items that were hidden previously
-            }
-        } catch (err) {
-        }
-    }
-}
+
 
 function lazy() {