]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - app.js
Change message box background according to the theme.
[github/bastienwirtz/homer.git] / app.js
diff --git a/app.js b/app.js
index a2960690a88072846cde77e93179307251c5f0ee..36508abb694ef108fc0ecbfd552f3cda62a71f81 100644 (file)
--- a/app.js
+++ b/app.js
@@ -21,6 +21,7 @@ const app = new Vue({
         this.checkOffline();
         try {
             this.config =  await this.getConfig();
+            document.title = this.config.title + ' | Homer';
         } catch (error) {
             this.offline = true;
         }
@@ -84,6 +85,35 @@ const app = new Vue({
         toggleMenu: function() {
             this.showMenu = !this.showMenu;
         }
+    },
+    mounted() {
+        function isSmallScreen() {
+            return window.matchMedia('screen and (max-width: 1023px)').matches;
+        }
+        this._keyListener = function(e) {
+            if (e.key === '/') {
+                if (isSmallScreen()) {
+                    this.showMenu = true;
+                }
+                Vue.nextTick(() => {
+                    this.$refs.search.focus();
+                });
+
+                e.preventDefault();
+            }
+            if (e.key === 'Escape') {
+                this.filter = '';
+                this.$refs.search.blur();
+                if (isSmallScreen()) {
+                    this.showMenu = false;
+                }
+            }
+        }
+
+        document.addEventListener('keydown', this._keyListener.bind(this));
+    },
+    beforeDestroy() {
+        document.removeEventListener('keydown', this._keyListener);
     }
 });