]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/global-search.js
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / resources / js / components / global-search.js
index 9f063f3985c28f31e2a31f64473be3d9f48f2f0c..2cdaf591ac458d99c13c5d3f8638d86a52ef3141 100644 (file)
@@ -1,11 +1,13 @@
-import {htmlToDom} from "../services/dom";
-import {debounce} from "../services/util";
-import {KeyboardNavigationHandler} from "../services/keyboard-navigation";
+import {htmlToDom} from '../services/dom.ts';
+import {debounce} from '../services/util.ts';
+import {KeyboardNavigationHandler} from '../services/keyboard-navigation.ts';
+import {Component} from './component';
 
 /**
- * @extends {Component}
+ * Global (header) search box handling.
+ * Mainly to show live results preview.
  */
-class GlobalSearch {
+export class GlobalSearch extends Component {
 
     setup() {
         this.container = this.$el;
@@ -23,12 +25,12 @@ class GlobalSearch {
 
         // Handle search input changes
         this.input.addEventListener('input', () => {
-            const value = this.input.value;
+            const {value} = this.input;
             if (value.length > 0) {
                 this.loadingWrap.style.display = 'block';
                 this.suggestionResultsWrap.style.opacity = '0.5';
                 updateSuggestionsDebounced(value);
-            }  else {
+            } else {
                 this.hideSuggestions();
             }
         });
@@ -53,7 +55,7 @@ class GlobalSearch {
         if (!this.input.value) {
             return;
         }
-        
+
         const resultDom = htmlToDom(results);
 
         this.suggestionResultsWrap.innerHTML = '';
@@ -69,7 +71,7 @@ class GlobalSearch {
         this.container.classList.add('search-active');
         window.requestAnimationFrame(() => {
             this.suggestions.classList.add('search-suggestions-animation');
-        })
+        });
     }
 
     hideSuggestions() {
@@ -77,6 +79,5 @@ class GlobalSearch {
         this.suggestions.classList.remove('search-suggestions-animation');
         this.suggestionResultsWrap.innerHTML = '';
     }
-}
 
-export default GlobalSearch;
\ No newline at end of file
+}