PageSourceSearch

https://thearc.org/wp-content/themes/enfold/js/avia-js.js?ver=7.1

js thearc.org collected 2026-09-24 08:37:15 UTC 2,740 bytes, 168 lines download raw bytes

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
70				let obj = window['wp'].hooks;
71
72				obj.applyFilters = this.wpHooks_applyFilters;
73				obj.doAction = this.wpHooks_applyFilters;
74				obj.hasFilter = this.wpHooks_hasFilters;
75				obj.hasAction = this.wpHooks_hasFilters;
76			}
77
78			wpHooks_applyFilters( handle, value )
79			{
80				return value;
81			}
82
83			wpHooks_hasFilters( handle, namespace )
84			{
85				return false;
86			}
87		}
88
89		aviaJS.aviaJSHelpers = new aviaJSHelpers();
90	}
91
92	if( ! aviaJS.aviaPlugins )
93	{
94		class aviaPlugins
95		{
96			plugins = [];
97			defaultPlugin = {
98				classFactory:	null,
99				selector:		''
100			};
101
102			constructor()
103			{
104				this.plugins = [];
105			}
106
107			register( classFactory, selector )
108			{
109				if( 'function' != typeof classFactory )
110				{
111					return false;
112				}
113
114				let newPlugin = Object.assign( {}, this.defaultPlugin );
115
116				if( 'string' != typeof selector )
117				{
118					selector = 'body';
119				}
120
121				newPlugin.classFactory = classFactory;
122				newPlugin.selector = selector;
123
124				this.plugins.push( newPlugin );
125
126				this.check_bind();
127			}
128
129			check_bind()
130			{
131				if( document.readyState === 'complete' )
132				{
133					// The page is already fully loaded
134					this.bind_plugins();
135				}
136				else
137				{
138					document.addEventListener( 'readystatechange', this.bind_plugins.bind( this ) );
139				}
140			}
141
142			bind_plugins( e )
143			{
144				if( document.readyState !== 'complete' )
145				{
146					return;
147				}
148
149				let plugins = this.plugins;
150				this.plugins = [];
151
152				for( let plugin of plugins )
153				{
154					let elements = document.querySelectorAll( plugin.selector );
155
156					for( let element of elements )
157					{
158						plugin.classFactory( element );
159					}
160				}
161			}
162		}
163
164		aviaJS.aviaPlugins = new aviaPlugins();
165	}
166
167})();
168

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.