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 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 } 58 59 aviaJS.aviaJSHelpers = new aviaJSHelpers(); 60 } 61 62 if( ! aviaJS.aviaPlugins ) 63 { 64 class aviaPlugins 65 { 66 plugins = []; 67 defaultPlugin = { 68 classFactory: null, 69 selector: '' 70 }; 71 72 constructor() 73 { 74 this.plugins = []; 75 } 76 77 register( classFactory, selector ) 78 { 79 if( 'function' != typeof classFactory ) 80 { 81 return false; 82 } 83 84 let newPlugin = Object.assign( {}, this.defaultPlugin ); 85 86 if( 'string' != typeof selector ) 87 { 88 selector = 'body'; 89 } 90 91 newPlugin.classFactory = classFactory; 92 newPlugin.selector = selector; 93 94 this.plugins.push( newPlugin ); 95 96 this.check_bind(); 97 } 98 99 check_bind() 100 { 101 if( document.readyState === 'complete' ) 102 { 103 // The page is already fully loaded 104 this.bind_plugins(); 105 } 106 else 107 { 108 document.addEventListener( 'readystatechange', this.bind_plugins.bind( this ) ); 109 } 110 } 111 112 bind_plugins( e ) 113 { 114 if( document.readyState !== 'complete' ) 115 { 116 return; 117 } 118 119 let plugins = this.plugins; 120 this.plugins = []; 121 122 for( let plugin of plugins ) 123 { 124 let elements = document.querySelectorAll( plugin.selector ); 125 126 for( let element of elements ) 127 { 128 plugin.classFactory( element ); 129 } 130 } 131 } 132 } 133 134 aviaJS.aviaPlugins = new aviaPlugins(); 135 } 136 137})(); 138
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.