From ff65622eb7abb023469053aa80152d547782713e Mon Sep 17 00:00:00 2001 From: Gerome Matilla Date: Tue, 9 Jun 2020 18:13:12 +0800 Subject: [PATCH] cleanup --- js/auto-suggestion.js | 1 + js/centered-box.js | 1 + js/dashboard.js | 9 +++++++-- js/dock-buttons.js | 1 + js/greeter-date-message.js | 2 +- js/keybindings.js | 4 ++++ js/mobile-swipe-callback.js | 1 + js/profile-image.js | 4 ++++ js/show-search-box.js | 2 +- js/theme-engine.js | 1 + js/web-menu.js | 29 ++++++++++++++--------------- 11 files changed, 36 insertions(+), 19 deletions(-) diff --git a/js/auto-suggestion.js b/js/auto-suggestion.js index 11f9e47..8907adf 100644 --- a/js/auto-suggestion.js +++ b/js/auto-suggestion.js @@ -1,4 +1,5 @@ class AutoSuggestion { + constructor() { this._searchBox = document.querySelector('#searchBox'); this._suggestionsUL = document.querySelector('#suggestions'); diff --git a/js/centered-box.js b/js/centered-box.js index c91ccf6..fd94820 100644 --- a/js/centered-box.js +++ b/js/centered-box.js @@ -1,4 +1,5 @@ class CenteredBox { + constructor() { this._centeredBox = document.querySelector('#centeredBox'); diff --git a/js/dashboard.js b/js/dashboard.js index d1fe210..4a399c8 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -13,10 +13,15 @@ class Dashboard { this._searchBoxContainer = document.querySelector('#searchBoxContainer'); this._weatherScreen = document.querySelector('#weatherScreen'); - this._registerOverlayMouseUpEvent(); + this._init(); } - _disableDashboardInputs = (status) => { + _init = () => { + this._registerOverlayMouseUpEvent(); + this._disableDashboardInputs(true); + } + + _disableDashboardInputs = status => { const elems = this._dashboard.getElementsByTagName('input'); const len = elems.length; diff --git a/js/dock-buttons.js b/js/dock-buttons.js index 700f99e..947d1bd 100644 --- a/js/dock-buttons.js +++ b/js/dock-buttons.js @@ -62,6 +62,7 @@ class DockButtons { const aDock = document.createElement('a'); aDock.className = 'dockLink'; aDock.href = url; + aDock.tabIndex = '-1'; // Create div container const dockButton = this._buildDockButton( diff --git a/js/greeter-date-message.js b/js/greeter-date-message.js index d486448..fa1a494 100644 --- a/js/greeter-date-message.js +++ b/js/greeter-date-message.js @@ -1,5 +1,5 @@ - class GreeterDateMessage { + constructor() { this._greeterMessage = document.querySelector('#greeterMessage'); this._dateMessage = document.querySelector('#dateMessage'); diff --git a/js/keybindings.js b/js/keybindings.js index 5d7d3e1..a06dbb1 100644 --- a/js/keybindings.js +++ b/js/keybindings.js @@ -9,6 +9,10 @@ class KeyBinding { this._documentAddKeyDownEvent = this._documentAddKeyDownEvent.bind(this); this._documentAddKeyUpEvent = this._documentAddKeyUpEvent.bind(this); + this._init(); + } + + _init = () => { this._registerDocumentAddKeyDownEvent(); this._registerDocumentAddKeyUpEvent(); } diff --git a/js/mobile-swipe-callback.js b/js/mobile-swipe-callback.js index 380aaaa..6640121 100644 --- a/js/mobile-swipe-callback.js +++ b/js/mobile-swipe-callback.js @@ -1,4 +1,5 @@ class SwipeEventCallbacks extends SwipeEventManager { + constructor() { super(); this.swipeEvent = this.swipeEvent; diff --git a/js/profile-image.js b/js/profile-image.js index 079b8ff..9521c26 100644 --- a/js/profile-image.js +++ b/js/profile-image.js @@ -15,6 +15,10 @@ class ProfileImage { this.getProfileAnimationStatus = this.getProfileAnimationStatus.bind(this); + this._init(); + } + + _init = () => { this._registerAnimationEndEvent(); this._registerOnClickEvent(); } diff --git a/js/show-search-box.js b/js/show-search-box.js index 2a04ce7..5ac8142 100644 --- a/js/show-search-box.js +++ b/js/show-search-box.js @@ -1,4 +1,5 @@ class SearchBoxShow { + constructor() { this._searchBox = document.querySelector('#searchBox'); @@ -10,7 +11,6 @@ class SearchBoxShow { this.showSearchBox = this.showSearchBox.bind(this); this.hideSearchBox = this.hideSearchBox.bind(this); this.toggleSearchBox = this.toggleSearchBox.bind(this); - } getSearchBoxVisibility = () => { diff --git a/js/theme-engine.js b/js/theme-engine.js index 2999964..1588bdc 100644 --- a/js/theme-engine.js +++ b/js/theme-engine.js @@ -1,4 +1,5 @@ class ThemeEngine { + constructor() { this._localStorage = window.localStorage; diff --git a/js/web-menu.js b/js/web-menu.js index a24a6eb..13b0dfb 100644 --- a/js/web-menu.js +++ b/js/web-menu.js @@ -15,17 +15,28 @@ class WebMenu { this._webItemFocus; this._webListIndex = 0; - this._fuzzySearch(); this._init(); } + _init = () => { + this._fuzzySearch(); + this._populateWebMenu(); + this._getFirstItem(); + + // Disable inputs + this._disableWebMenuInputs(true); + + this._registerWebMenuSearchBoxKeyDownEvent(); + this._registerWebMenuKeyDownEvent(); + } + // Return web menu status getwebMenuVisibility = () => { return this._webMenuVisibility; } // Disable textboxes - _disableWebMenuInputs = (status) => { + _disableWebMenuInputs = status => { const elems = this._webMenu.getElementsByTagName('input'); const len = elems.length; @@ -310,7 +321,7 @@ class WebMenu { const menuItemWidth = 138; const scrollBarWidth = 10; // viewport width - const vw = (unit) => window.innerWidth * (unit / 100); + const vw = unit => window.innerWidth * (unit / 100); // Gets the number of columns by dividing the screen width minus the padding, scroll width and // average of menu item width by the menu item width @@ -420,16 +431,4 @@ class WebMenu { _registerWebMenuSearchBoxKeyDownEvent = () => { this._webMenuSearchBox.onkeydown = this._webMenuSearchBoxKeyDownEvent; } - - _init = () => { - this._populateWebMenu(); - this._getFirstItem(); - - // Disable inputs - this._disableWebMenuInputs(true); - - this._registerWebMenuSearchBoxKeyDownEvent(); - this._registerWebMenuKeyDownEvent(); - } - }