-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathithoughts-core-v5.html
More file actions
executable file
·581 lines (524 loc) · 26.8 KB
/
Copy pathithoughts-core-v5.html
File metadata and controls
executable file
·581 lines (524 loc) · 26.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<!DOCTYPE html>
<html>
<head>
<title>ithoughts-core-v5.js</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="ithoughts-core-v5.html">
ithoughts-core-v5.js
</a>
<a class="source" href="jquery-serialize-object-v5.html">
jquery-serialize-object-v5.js
</a>
<a class="source" href="simple-ajax-form-v5.html">
simple-ajax-form-v5.js
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>ithoughts-core-v5.js</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-comment">/**
* @file Minify compliant generic shorthands
*
* @author Alexandre Germain
* @copyright 2016 iThoughts informatique
* @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
* @package iThoughts-toolbox
*
*/</span>
<span class="hljs-comment">/**
* @namespace iThoughts
* @description iThoughts Helpers versions
*/</span>
<span class="hljs-comment">/**
* @namespace iThoughts.v5
* @@memberof iThoughts
* @description iThoughts v5 Helpers
*/</span>
<span class="hljs-meta">
'use strict'</span>;
<span class="hljs-keyword">if</span> ( <span class="hljs-string">'undefined'</span> == <span class="hljs-keyword">typeof</span> iThoughts ) {
<span class="hljs-built_in">window</span>.iThoughts = {};
}
( <span class="hljs-function"><span class="hljs-params">s</span> =></span> {
<span class="hljs-comment">/**
* @function isNA
* @description Tests if the value is null or undefined
* @author Gerkin
* @param {*} value The value to test
* @returns {Boolean} Returns true if `value` is null or undefined
*/</span>
<span class="hljs-keyword">const</span> isNA = <span class="hljs-function"><span class="hljs-params">value</span> =></span> {
<span class="hljs-keyword">return</span> <span class="hljs-literal">null</span> === value || <span class="hljs-string">'undefined'</span> === <span class="hljs-keyword">typeof</span> value;
};
<span class="hljs-keyword">if</span> ( isNA( s.v5 )) {
s.v5 = {};
} <span class="hljs-keyword">else</span> {
<span class="hljs-keyword">return</span>;
}
<span class="hljs-keyword">var</span> v5 = s.v5,
d = <span class="hljs-built_in">document</span>,
w = <span class="hljs-built_in">window</span>,</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<pre><code>el = Element,
</code></pre>
</div>
<div class="content"><div class='highlight'><pre> et = <span class="hljs-keyword">typeof</span> EventTarget != <span class="hljs-string">'undefined'</span> && !isNA( EventTarget ) ? EventTarget : <span class="hljs-built_in">document</span>.createDocumentFragment().constructor,
dc = v5.deepClone = <span class="hljs-function">(<span class="hljs-params"> obj </span>) =></span> {
<span class="hljs-keyword">let</span> newT;
<span class="hljs-keyword">if</span> ( !isNA( obj )) {
<span class="hljs-keyword">switch</span> ( obj.constructor ) {
<span class="hljs-keyword">case</span> <span class="hljs-built_in">Object</span>: {
newT = {};
<span class="hljs-keyword">for</span> ( <span class="hljs-keyword">let</span> i <span class="hljs-keyword">in</span> obj ) {
<span class="hljs-keyword">if</span> ( v5.hop( obj, i )) {
newT[i] = dc( obj[i]);
}
}
<span class="hljs-keyword">return</span> newT;
}
<span class="hljs-keyword">case</span> <span class="hljs-built_in">Array</span>: {
newT = [];
<span class="hljs-keyword">for</span> ( <span class="hljs-keyword">let</span> i <span class="hljs-keyword">in</span> obj ) {
<span class="hljs-keyword">if</span> ( v5.hop( obj, i )) {
newT[i] = dc( obj[i]);
}
}
<span class="hljs-keyword">return</span> newT;
}
<span class="hljs-keyword">default</span>: {
<span class="hljs-keyword">return</span> obj;
}
}
} <span class="hljs-keyword">else</span> {
<span class="hljs-keyword">return</span> obj;
}
};
<span class="hljs-comment">/**
* @function isNA
* @description Check if value is null or undefined
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {*} value The value tu check
* @returns {boolean} True if null or undefined, false otherwise
*/</span>
v5.isNA = isNA;
<span class="hljs-comment">/**
* @function waitFor
* @description Look into `scope` for property `prop` every `every`ms, then execute `callback` when the property exists
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {*} scope The parent scope to check for property in
* @param {string} prop Name of the property to wait for
* @param {integer} [every] Time in ms between each checks
* @param {function} callback Function to execute once property exists
* @returns {undefined} Async
*/</span>
v5.waitFor = <span class="hljs-function">(<span class="hljs-params"> scope, prop, every, callback </span>) =></span> {
<span class="hljs-keyword">if</span> ( <span class="hljs-string">'function'</span> == <span class="hljs-keyword">typeof</span> every ) {
callback = every;
every = <span class="hljs-literal">undefined</span>;
}
<span class="hljs-keyword">if</span> ( <span class="hljs-keyword">typeof</span> scope != <span class="hljs-string">'object'</span> || <span class="hljs-keyword">typeof</span> prop != <span class="hljs-string">'string'</span> || ( <span class="hljs-string">'number'</span> == <span class="hljs-keyword">typeof</span> every && <span class="hljs-keyword">typeof</span> callback != <span class="hljs-string">'function'</span> ) || <span class="hljs-keyword">typeof</span> callback != <span class="hljs-string">'function'</span> ) {
<span class="hljs-keyword">throw</span> <span class="hljs-built_in">TypeError</span>( <span class="hljs-string">'"waitFor" expects following types combinations:\n'</span> +
<span class="hljs-string">'\t{Object} scope\, {String} prop, {Number} every, {Function} callback\n'</span> +
<span class="hljs-string">'\t{Object} scope\, {String} prop, {Function} callback'</span> );
}
<span class="hljs-keyword">if</span> ( v5.hop( scope, prop )) {
callback();
} <span class="hljs-keyword">else</span> {
timer = setInterval(<span class="hljs-function"><span class="hljs-params">()</span> =></span> {
<span class="hljs-keyword">if</span> ( v5.hop( scope, prop )) {
clearInterval( timer );
callback();
}
}, every || <span class="hljs-number">100</span> );
}
<span class="hljs-keyword">var</span> timer = <span class="hljs-literal">null</span>;
};
<span class="hljs-comment">/**
* @function mergeRecursive
* @description Combine each object from left to right, keeping the left-most value
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {...(object|array)} objects Any number of objects/arrays to merge
* @returns {boolean} True if null or undefined, false otherwise
*/</span>
v5.mergeRecursive = <span class="hljs-function">(<span class="hljs-params"> ...objects </span>) =></span> {
<span class="hljs-keyword">var</span> newObj = <span class="hljs-literal">null</span>,
j,
curObj,
recurse = <span class="hljs-function">(<span class="hljs-params"> obj1, obj2 </span>) =></span> {
<span class="hljs-keyword">var</span> i,
newT;
<span class="hljs-keyword">if</span> ( !isNA( obj2 )) {
<span class="hljs-keyword">switch</span> ( obj2.constructor ) {
<span class="hljs-keyword">case</span> <span class="hljs-built_in">Object</span>: {
<span class="hljs-keyword">if</span> ( !isNA( obj1 ) && obj1.constructor === <span class="hljs-built_in">Object</span> ) {
newT = dc( obj1 );
} <span class="hljs-keyword">else</span> {
newT = {};
}
<span class="hljs-keyword">for</span> ( i <span class="hljs-keyword">in</span> obj2 ) {
<span class="hljs-keyword">if</span> ( v5.hop( obj2, i )) {
newT[i] = recurse( newT[i], obj2[i]);
}
}
<span class="hljs-keyword">return</span> newT;
}
<span class="hljs-keyword">case</span> <span class="hljs-built_in">Array</span>: {
<span class="hljs-keyword">if</span> ( !isNA( obj1 ) && obj1.constructor === <span class="hljs-built_in">Array</span> ) {
newT = dc( obj1 );
} <span class="hljs-keyword">else</span> {
newT = [];
}
<span class="hljs-keyword">for</span> ( i <span class="hljs-keyword">in</span> obj2 ) {
<span class="hljs-keyword">if</span> ( v5.hop( obj2, i )) {
newT[i] = recurse( newT[i], obj2[i]);
}
}
<span class="hljs-keyword">return</span> newT;
}
<span class="hljs-keyword">default</span>: {
<span class="hljs-keyword">return</span> obj2;
}
}
} <span class="hljs-keyword">else</span> {
<span class="hljs-keyword">return</span> obj2;
}
};
<span class="hljs-keyword">for</span> ( j <span class="hljs-keyword">in</span> objects ) {
curObj = objects[j];
<span class="hljs-keyword">if</span> ( !isNA( curObj ) && ( curObj.constructor === <span class="hljs-built_in">Object</span> || curObj.constructor === <span class="hljs-built_in">Array</span> )) {
newObj = recurse( newObj, curObj );
}
}
<span class="hljs-keyword">return</span> newObj;
};
v5.docWidth = <span class="hljs-function"><span class="hljs-params">()</span> =></span> {
<span class="hljs-keyword">return</span> w.innerWidth ||
w.documentElement.clientWidth ||
w.body.clientWidth ||
w.body.offsetWidth;
};
v5.docHeight = <span class="hljs-function"><span class="hljs-params">()</span> =></span> {
<span class="hljs-keyword">return</span> w.innerHeight ||
w.documentElement.clientHeight ||
w.body.clientHeight ||
w.body.offsetHeight;
};
<span class="hljs-comment">/**
* @function gei
* @description Minification shorthand for {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById Document.getElementById}
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {string} s The id of the searched element
* @param {Element} [e=document] Element to search in
* @returns {Element|null} The Element, or null if not found
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
*/</span>
v5.gei = <span class="hljs-function">(<span class="hljs-params"> s, e </span>) =></span> {
<span class="hljs-keyword">return</span> ( e||d ).getElementById( s );
};
<span class="hljs-comment">/**
* @function qs
* @description Minification shorthand for {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector Element.querySelector}
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {string} s The selector of the searched element
* @param {Element} [e=document] Element to search in
* @returns {Element|null} The Element, or null if not found
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector
*/</span>
v5.qs = <span class="hljs-function">(<span class="hljs-params"> s, e </span>) =></span> {
<span class="hljs-keyword">return</span> ( e||d ).querySelector( s );
};
<span class="hljs-comment">/**
* @function qsa
* @description Minification shorthand for {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll Element.querySelectorAll}
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {string} s The selector of the searched element
* @param {Element} [e=document] Element to search in
* @returns {NodeList} The NodeList containing every elements matching the selector
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll
*/</span>
v5.qsa = <span class="hljs-function">(<span class="hljs-params"> s, e </span>) =></span> {
<span class="hljs-keyword">return</span> ( e||d ).querySelectorAll( s );
};
<span class="hljs-comment">/**
* @function geiN
* @description Like {@link Document.gei}, but returns an empty object instead of null to allow 1lvl attribute definition without tests
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {string} s The selector of the searched element
* @param {Element} [e=document] Element to search in
* @returns {Element|{}} The Element, or an empty object if not found
*/</span>
v5.geiN = <span class="hljs-function">(<span class="hljs-params"> s, e </span>) =></span> {
<span class="hljs-keyword">return</span> v5.gei( s, e ) || {};
};
<span class="hljs-comment">/**
* @function qsN
* @description Like {@link Element.qsN}, but returns an empty object instead of null to allow 1lvl attribute definition without tests
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {string} s The selector of the searched element
* @param {Element} [e=document] Element to search in
* @returns {Element|{}} The Element, or an empty object if not found
*/</span>
v5.qsN = <span class="hljs-function">(<span class="hljs-params"> s, e </span>) =></span> {
<span class="hljs-keyword">return</span> v5.qs( s, e ) || {};
};
<span class="hljs-comment">/**
* @function hop
* @description Minification shorthand for {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty Object.hasOwnProperty}
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {Object} s The object to check
* @param {string} v The name of the attribute
* @returns {Boolean} Returns the same than {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty Object.hasOwnProperty}
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
*/</span>
v5.hop = <span class="hljs-function">(<span class="hljs-params"> s, v </span>) =></span> {
<span class="hljs-keyword">return</span> s.hasOwnProperty( v );
};
<span class="hljs-comment">/**
* @function waitUntil
* @description Minification shorthand for {@link HTMLDocument}.getElementById
* @author Gerkin
* @memberof iThoughts.v5
* @instance
* @param {Function} fct Function executed on resolution.
* @param {Function} until Function executed on each loop.
* @param {Number} every Time to wait between each test.
* @param {Number|false} [max=false] Time after which `fct` will be executed even if `until` still returns false. Set it to false to not set max timeout
* @returns {undefined}
*/</span>
v5.waitUntil = <span class="hljs-function">(<span class="hljs-params"> fct, until, every, max </span>) =></span> {
<span class="hljs-keyword">if</span> ( isNA( until ) || until.constructor.name !== <span class="hljs-string">'Function'</span> ) {
<span class="hljs-keyword">throw</span> <span class="hljs-built_in">TypeError</span>( <span class="hljs-string">'Calling "Function.waitUntil" without test function. Call setTimeout instead'</span> );
}
max = !isNA( max ) && !<span class="hljs-built_in">isNaN</span>( <span class="hljs-built_in">parseInt</span>( max )) ? <span class="hljs-built_in">parseInt</span>( max ) : <span class="hljs-literal">false</span>;
setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =></span> {
until() || ( max !== <span class="hljs-literal">false</span> && max < <span class="hljs-number">1</span> ) ? fct() : v5.waitUntil( fct, until, every, max ? max - every : max );
}, every );
};
<span class="hljs-comment">/**
* @function on
* @description Bind events with specified functions on specified elements
* @memberof iThoughts.v5
* @alias iThoughts.v5.attachEvent
* @param {EventTarget|EventTarget[]} a EventTarget to bind
* @param {string|string[]} b Events to bind
* @param {EventFunction|EventFunction[]} c Functions to attach
* @returns {undefined}
* @since 0.1.0
*/</span>
v5.on = v5.attachEvent = <span class="hljs-function">(<span class="hljs-params"> a, b, c </span>) =></span> {
<span class="hljs-comment">/**
* @function _on
* @description Same as {@link EventTarget#on}
* @alias EventTarget.on
* @param {Element} s Subject of the binding
* @param {string} e Event to bind
* @param {EventFunction} f Function to attach
* @returns {undefined}
* @private
* @see iThoughts.v5#on
* @since 0.1.0
*/</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_on</span>(<span class="hljs-params"> s, e, f </span>) </span>{
e && f && ( s.addEventListener || s.attachEvent ).call( s, e, f );
}
<span class="hljs-keyword">if</span> ( isNA( a ) || a.constructor.name !== <span class="hljs-string">'Array'</span> ) {
a = [ a ];
}
<span class="hljs-keyword">if</span> ( isNA( b ) || b.constructor.name !== <span class="hljs-string">'Array'</span> ) {
b = [ b ];
}
<span class="hljs-keyword">if</span> ( isNA( c ) || c.constructor.name !== <span class="hljs-string">'Array'</span> ) {
c = [ c ];
}
<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, j = <span class="hljs-number">0</span>, k = <span class="hljs-number">0</span>, I = a.length, J = b.length, K = c.length;
<span class="hljs-keyword">for</span> ( i = <span class="hljs-number">0</span>; i < I; i++ ) {
<span class="hljs-keyword">for</span> ( j = <span class="hljs-number">0</span>; j < J; j++ ) {
<span class="hljs-keyword">for</span> ( k = <span class="hljs-number">0</span>; k < K; k++ ) {
a[i] <span class="hljs-keyword">instanceof</span> et && _on( a[i], b[j], c[k]);
}
}
}
};
<span class="hljs-comment">/**
* @function off
* @description Unbind events with specified functions on specified elements
* @memberof iThoughts.v5
* @alias iThoughts.v5.detachEvent
* @param {EventTarget|EventTarget[]} a EventTarget to unbind
* @param {string|string[]} b Events to unbind
* @param {EventFunction|EventFunction[]} c Functions to detach
* @returns {undefined}
* @since 0.1.0
*/</span>
v5.off = v5.detachEvent = <span class="hljs-function">(<span class="hljs-params"> a, b, c </span>) =></span> {
<span class="hljs-comment">/**
* @function _off
* @description Same as {@link EventTarget#off}
* @param {Element} s Subject of the unbinding
* @param {string} e Event to unbind
* @param {EventFunction} f Function to detach
* @returns {undefined}
* @private
* @see iThoughts.v5#off
* @since 0.1.0
*/</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_off</span>(<span class="hljs-params"> s, e, f </span>) </span>{
e && f && ( s.removeEventListener || s.detachEvent ).call( s, e, f );
}
<span class="hljs-keyword">if</span> ( isNA( a ) || a.constructor.name !== <span class="hljs-string">'Array'</span> ) {
a = [ a ];
}
<span class="hljs-keyword">if</span> ( isNA( b ) || b.constructor.name !== <span class="hljs-string">'Array'</span> ) {
b = [ b ];
}
<span class="hljs-keyword">if</span> ( isNA( c ) || c.constructor.name !== <span class="hljs-string">'Array'</span> ) {
c = [ c ];
}
<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, j = <span class="hljs-number">0</span>, k = <span class="hljs-number">0</span>, I = a.length, J = b.length, K = c.length;
<span class="hljs-keyword">for</span> ( i = <span class="hljs-number">0</span>; i < I; i++ ) {
<span class="hljs-keyword">for</span> ( j = <span class="hljs-number">0</span>; j < J; j++ ) {
<span class="hljs-keyword">for</span> ( k = <span class="hljs-number">0</span>; k < K; k++ ) {
a[i] <span class="hljs-keyword">instanceof</span> et && _off( a[i], b[j], c[k]);
}
}
}
};
<span class="hljs-comment">/**
* @function go
* @description Unbind events with specified functions on specified elements
* @memberof iThoughts.v5
* @alias iThoughts.v5.triggerEvent
* @param {EventTarget|EventTarget[]} a EventTarget to trigger event on
* @param {string|string[]} b Name of the events
* @returns {undefined}
* @since 0.1.0
*/</span>
v5.go = v5.triggerEvent = <span class="hljs-function">(<span class="hljs-params"> a, b </span>) =></span> {
<span class="hljs-comment">/**
* @function _go
* @description Same as {@link EventTarget#go}
* @param {Element} s Subject of the trigger
* @param {string} b Event name
* @returns {undefined}
* @private
* @see iThoughts.v5#go
* @since 0.1.0
*/</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_go</span>(<span class="hljs-params"> s, b </span>) </span>{
<span class="hljs-keyword">let</span> e;
<span class="hljs-keyword">if</span> ( b ) {
<span class="hljs-keyword">if</span> ( d.createEvent ) {
e = <span class="hljs-keyword">new</span> Event( b );
s.dispatchEvent( e );
} <span class="hljs-keyword">else</span> {
e = d.createEventObject();
s.fireEvent( <span class="hljs-string">`on<span class="hljs-subst">${ b }</span>`</span>, e );
}
}
}
<span class="hljs-keyword">if</span> ( isNA( a ) || a.constructor.name !== <span class="hljs-string">'Array'</span> ) {
a = [ a ];
}
<span class="hljs-keyword">if</span> ( isNA( b ) || b.constructor.name !== <span class="hljs-string">'Array'</span> ) {
b = [ b ];
}
<span class="hljs-keyword">for</span> ( <span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, I = a.length; i < I; i++ ) {
<span class="hljs-keyword">for</span> ( <span class="hljs-keyword">var</span> j = <span class="hljs-number">0</span>, J = b.length; j < J; j++ ) {
a[i] <span class="hljs-keyword">instanceof</span> et && _go( a[i], b[j]);
}
}
};
<span class="hljs-keyword">if</span> ( <span class="hljs-built_in">window</span>.jQuery ) {
<span class="hljs-keyword">var</span> $ = v5.$ = <span class="hljs-built_in">window</span>.jQuery;
v5.$d = $( <span class="hljs-built_in">document</span> );
v5.$w = $( <span class="hljs-built_in">window</span> );
}
v5.isIos = navigator.userAgent.match( <span class="hljs-regexp">/(iPad|iPhone|iPod)/g</span> ); <span class="hljs-comment">// Used to enable some iOS specific piece of code to catch click on body, for example</span>
v5.baseTouch = ( v5.isIos || navigator.userAgent.match( <span class="hljs-regexp">/(Android|webOS|BlackBerry)/i</span> )) ? <span class="hljs-number">1</span> : <span class="hljs-number">0</span>;
v5.initLoggers = <span class="hljs-function">(<span class="hljs-params">(</span>) =></span> {
<span class="hljs-keyword">const</span> generateLogArray = <span class="hljs-function">(<span class="hljs-params"> prefix, mode, args </span>) =></span> {
args.unshift( <span class="hljs-string">`<span class="hljs-subst">${ mode }</span>`</span> );
args.unshift( <span class="hljs-string">`<span class="hljs-subst">${ prefix }</span> => `</span> );
<span class="hljs-keyword">return</span> args;
};
<span class="hljs-keyword">return</span> <span class="hljs-function">(<span class="hljs-params"> pluginCore, textPrefix, verbosity </span>) =></span> {
<span class="hljs-keyword">if</span> ( <span class="hljs-string">'string'</span> == <span class="hljs-keyword">typeof</span> verbosity ) {
verbosity = <span class="hljs-built_in">parseInt</span>( verbosity );
}
<span class="hljs-keyword">var</span> modes = [ <span class="hljs-string">'error'</span>, <span class="hljs-string">'warn'</span>, <span class="hljs-string">'info'</span>, <span class="hljs-string">'log'</span> ],
mode;
<span class="hljs-keyword">for</span> ( <span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, I = modes.length; i < I; i++ ) {
mode = modes[i];
<span class="hljs-keyword">if</span> ( !pluginCore.hasOwnProperty( mode )) {
pluginCore[mode] = verbosity > i ? <span class="hljs-function">(<span class="hljs-params">( modeIn, ...args </span>) =></span> {
<span class="hljs-built_in">console</span>[modeIn].apply( <span class="hljs-literal">null</span>, generateLogArray( textPrefix, modeIn.toUpperCase(), args ));
}).bind( <span class="hljs-literal">null</span>, mode ) : <span class="hljs-function"><span class="hljs-params">()</span> =></span> {};
}
}
};
})();
v5.makeLoader = <span class="hljs-function"><span class="hljs-params">()</span> =></span> {
<span class="hljs-keyword">var</span> loader = $( $.parseHTML( <span class="hljs-string">'<div class="ithoughts_tt_gl-loader" data-loader-status="shown"><div class="centerer"><div class="loader"></div></div></div>'</span> ));
loader.find( <span class="hljs-string">'.loader,.loader:before,.loader:after'</span> ).css({
<span class="hljs-attr">borderTopColor</span>: $( <span class="hljs-string">'#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.current a.menu-top, .folded #adminmenu li.wp-has-current-submenu, .folded #adminmenu li.current.menu-top, #adminmenu .wp-menu-arrow, #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, #adminmenu .wp-menu-arrow div,#publish'</span> ).css( <span class="hljs-string">'background-color'</span> ),
});
loader.find( <span class="hljs-string">'.centerer'</span> ).css({
<span class="hljs-attr">backgroundColor</span>: $( <span class="hljs-string">'#wpadminbar'</span> ).css( <span class="hljs-string">'background-color'</span> ),
});
$( <span class="hljs-string">'body'</span> ).append( loader );
<span class="hljs-keyword">return</span> loader;
};
})( iThoughts );</pre></div></div>
</li>
</ul>
</div>
</body>
</html>