1BX.namespace('Aspro.SmartSearch.Input'); 2 3(() => { 4 class JAsproSmartSearchInput { 5 constructor(node, params, result) { 6 node = typeof node === 'string' && node ? document.querySelector(node) : node; 7 node = typeof node === 'object' && node && node instanceof Node ? node : null; 8 this.node = node; 9 10 params = typeof params === 'object' && params ? params : {}; 11 this.params = params; 12 13 result = typeof result === 'object' && result ? result : {}; 14 this.result = result; 15 16 this.syncHistory(); 17 18 if (this.node) { 19 this.bindEvents(); 20 } 21 } 22 23 bindEvents() { 24 if (!this.node) { 25 return; 26 } 27 28 BX.bind( 29 this.node, 30 'focus', 31 BX.proxy( 32 this.onInputFocus, 33 this 34 ) 35 ); 36 } 37 38 unbindEvents() { 39 if (!this.node) { 40 return; 41 } 42 43 BX.unbind( 44 this.node, 45 'focus', 46 BX.proxy( 47 this.onInputFocus, 48 this 49 ) 50 ); 51 } 52 53 load(assets) { 54 return new Promise((resolve, reject) => { 55 assets = BX.Type.isObject(assets) ? assets : {}; 56 const ext2load = BX.Type.isArray(assets.ext) ? assets.ext : []; 57 const css2load = BX.Type.isArray(assets.css) ? assets.css : []; 58 const js2load = BX.Type.isArray(assets.js) ? assets.js : []; 59 60 BX.loadExt(ext2load).then(() => { 61 if (css2load.length) { 62 BX.loadCSS(css2load, () => { 63 if (js2load) { 64 BX.loadScript(js2load, () => { 65 resolve(); 66 });
67 } else { 68 resolve(); 69 } 70 }); 71 } else { 72 if (js2load) { 73 BX.loadScript(js2load, () => { 74 resolve(); 75 }); 76 } else { 77 resolve(); 78 } 79 } 80 }); 81 }); 82 } 83 84 syncHistory() { 85 if (this.result.history?.enabled) { 86 if ( 87 this.result.history.hash 88 && typeof localStorage === 'object' 89 && localStorage 90 ) { 91 localStorage.setItem('aspro-search-history-sync', this.result.history.hash); 92 } 93 } 94 } 95 96 onInputFocus() { 97 if (!this.node) { 98 return; 99 } 100 101 this.unbindEvents(); 102 103 if (this.result.suggest?.enabled) { 104 this.load(this.result.suggest?.load).then(() => { 105 if (BX.Type.isFunction(BX.Aspro.SmartSearch.Suggest)) { 106 (new BX.Aspro.SmartSearch.Suggest(this.node, this.result.suggest?.params)).importTemplate(); 107 } 108 }); 109 } 110 111 if (this.result.history?.enabled) { 112 this.load(this.result.history?.load).then(() => { 113 if (BX.Type.isFunction(BX.Aspro.SmartSearch.History)) { 114 (new BX.Aspro.SmartSearch.History(this.node, this.result.history?.params)).importTemplate(); 115 } 116 }); 117 } 118 } 119 } 120 121 BX.Aspro.SmartSearch.Input = JAsproSmartSearchInput; 122})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.