1/** 2 * Contains plain js basic and helpers classes 3 * 4 * @since 5.6 5 */ 6 7/** 8 * Global namespace 9 * 10 * @since 5.6 11 */ 12var aviaJS = aviaJS || {}; 13 14(function() 15{ 16 "use strict"; 17 18 if( ! aviaJS.aviaJSHelpers ) 19 { 20 class aviaJSHelpers 21 { 22 constructor() 23 { 24 this.wpHooks(); 25 } 26 27 // based on _.js debounce() 28 debounce( callback, wait, immediate ) 29 { 30 var timeout; 31 32 return function() 33 { 34 var context = this, 35 args = arguments; 36 37 var later = function() 38 { 39 timeout = null; 40 if( ! immediate ) 41 { 42 callback.apply(context, args); 43 } 44 }; 45 46 var callNow = immediate && ! timeout; 47 48 clearTimeout( timeout ); 49 timeout = setTimeout( later, wait ); 50 if( callNow ) 51 { 52 callback.apply( context, args ); 53 } 54 }; 55 } 56 57 wpHooks() 58 { 59 // to avoid checking for wp.hooks calling filters or actions we create dummy functions here 60 if( window['wp'] && wp.hooks ) 61 { 62 return; 63 } 64 65 if( ! window['wp'] ) 66 { 67 window['wp'] = { hooks: {} }; 68 } 69 else 70 { 71 window['wp'].hooks = {}; 72 } 73 74 let obj = window['wp'].hooks; 75 76 obj.applyFilters = this.wpHooks_applyFilters; 77 obj.doAction = this.wpHooks_applyFilters; 78 obj.hasFilter = this.wpHooks_hasFilters; 79 obj.hasAction = this.wpHooks_hasFilters; 80 } 81 82 wpHooks_applyFilters( handle, value ) 83 { 84 return value; 85 } 86 87 wpHooks_hasFilters( handle, namespace ) 88 { 89 return false; 90 } 91 } 92 93 aviaJS.aviaJSHelpers = new aviaJSHelpers(); 94 } 95 96 if( ! aviaJS.aviaPlugins ) 97 { 98 class aviaPlugins 99 { 100 plugins = []; 101 defaultPlugin = { 102 classFactory: null, 103 selector: '' 104 }; 105 106 constructor() 107 { 108 this.plugins = []; 109 } 110 111 register( classFactory, selector ) 112 { 113 if( 'function' != typeof classFactory ) 114 { 115 return false; 116 } 117 118 let newPlugin = Object.assign( {}, this.defaultPlugin ); 119 120 if( 'string' != typeof selector ) 121 { 122 selector = 'body'; 123 } 124 125 newPlugin.classFactory = classFactory; 126 newPlugin.selector = selector; 127 128 this.plugins.push( newPlugin ); 129 130 this.check_bind(); 131 } 132 133 check_bind() 134 { 135 if( document.readyState === 'complete' ) 136 { 137 // The page is already fully loaded 138 this.bind_plugins(); 139 } 140 else 141 { 142 document.addEventListener( 'readystatechange', this.bind_plugins.bind( this ) ); 143 } 144 } 145 146 bind_plugins( e ) 147 { 148 if( document.readyState !== 'complete' ) 149 { 150 return; 151 } 152 153 let plugins = this.plugins; 154 this.plugins = []; 155 156 for( let plugin of plugins ) 157 { 158 let elements = document.querySelectorAll( plugin.selector ); 159 160 for( let element of elements ) 161 { 162 plugin.classFactory( element ); 163 } 164 } 165 } 166 } 167 168 aviaJS.aviaPlugins = new aviaPlugins(); 169 } 170 171})(); 172
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.