]> _ Git - fluidbook-html5.git/commitdiff
wait #7551 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 26 Jun 2025 16:08:51 +0000 (18:08 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 26 Jun 2025 16:08:51 +0000 (18:08 +0200)
js/libs/fluidbook/fluidbook.keyboard.js

index 951ac374fbc06fa302e94c9d93951d83fab5bd9f..58c6908557bc02b09889875802f6d9c3ebe3bd7e 100644 (file)
@@ -12,21 +12,7 @@ FluidbookKeyboard.prototype = {
             return !(e.is('input:not(#q),select,textarea'));
         }
         this.keyShortcut('escape', function () {
-            if ($this.fluidbook.help.isVisible()) {
-                $this.fluidbook.help.hide();
-            }
-            if ($this.fluidbook.menu.viewMode()) {
-                $this.fluidbook.menu.closeView(function () {
-
-                }, true, true);
-            }
-            $this.fluidbook.search.closeSearch();
-            $this.fluidbook.search.closeResultsNav();
-            $this.fluidbook.nav.burger.close();
-
-            if ($this.fluidbook.support.isFullscreen()) {
-                document.exitFullscreen();
-            }
+            $this.escape();
         });
         this.keyShortcut('tab,shift+tab', function (e, handler) {
             let dir = handler.shortcut === 'tab' ? 1 : -1;
@@ -56,7 +42,47 @@ FluidbookKeyboard.prototype = {
 
         this.keyShortcut('f10', function () {
             $this.fluidbook.nav.burger.toggle();
-        })
+        });
+
+        setInterval(function () {
+            $this.listenToIframeEscapeEvents();
+        }, 500);
+    },
+
+    listenToIframeEscapeEvents: function () {
+        var $this = this;
+        $('iframe:not(.listenescape)').each(function () {
+            $(this).addClass('listenescape');
+            let iframe = $(this);
+            $(this).on('load', function () {
+                let win = $(iframe).get(0).contentWindow;
+                let doc = win.document;
+                doc.addEventListener('keydown', function (e) {
+                    if (e.code === 'Escape') {
+                        $this.escape();
+                    }
+                });
+            });
+
+        });
+    },
+
+    escape: function () {
+        if (this.fluidbook.help.isVisible()) {
+            this.fluidbook.help.hide();
+        }
+        if (this.fluidbook.menu.viewMode()) {
+            this.fluidbook.menu.closeView(function () {
+
+            }, true, true);
+        }
+        this.fluidbook.search.closeSearch();
+        this.fluidbook.search.closeResultsNav();
+        this.fluidbook.nav.burger.close();
+
+        if (this.fluidbook.support.isFullscreen()) {
+            document.exitFullscreen();
+        }
     },
 
     _navigate: function (list, dir, actions) {