phcthemes_admin_panel_pack 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/common/lazysizes/lazysizes.js +754 -0
- data/app/assets/javascripts/common/scrollme/jquery.scrollme.js +455 -0
- data/app/assets/javascripts/common/slick/slick.js +3004 -0
- data/app/assets/javascripts/common/wow/wow.js +508 -0
- data/lib/phcthemes_admin_panel_pack/engine.rb +1 -0
- data/lib/phcthemes_admin_panel_pack/version.rb +1 -1
- metadata +30 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6308499eab7d247b9705b7e76c2dbf3cc4d863ff277181cd23ee6c6a430804e3
|
4
|
+
data.tar.gz: 68eef15131d5bf1129afcb8995fb0ae37410ff8325e663b911b23f70d3fd511a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a6e07219661d6fecd4cc550315c572deeb815783d0cfe082a048aa37db00ba3794863530929fb7647b0baea1587a05d7ccb510a38c24541636caa1feb29ed52
|
7
|
+
data.tar.gz: 592dd7d4c92371e20e04f404fc14cb644ec7c8cb2ab874d998dd22dfaa90eb9d6de0348126fd3e1078502e008785e8563bcaf147976bc2e5d8f1e544b42a7aa2
|
@@ -0,0 +1,754 @@
|
|
1
|
+
(function(window, factory) {
|
2
|
+
var lazySizes = factory(window, window.document, Date);
|
3
|
+
window.lazySizes = lazySizes;
|
4
|
+
if(typeof module == 'object' && module.exports){
|
5
|
+
module.exports = lazySizes;
|
6
|
+
}
|
7
|
+
}(typeof window != 'undefined' ?
|
8
|
+
window : {}, function l(window, document, Date) { // Pass in the windoe Date function also for SSR because the Date class can be lost
|
9
|
+
'use strict';
|
10
|
+
/*jshint eqnull:true */
|
11
|
+
|
12
|
+
var lazysizes, lazySizesCfg;
|
13
|
+
|
14
|
+
(function(){
|
15
|
+
var prop;
|
16
|
+
|
17
|
+
var lazySizesDefaults = {
|
18
|
+
lazyClass: 'lazyload',
|
19
|
+
loadedClass: 'lazyloaded',
|
20
|
+
loadingClass: 'lazyloading',
|
21
|
+
preloadClass: 'lazypreload',
|
22
|
+
errorClass: 'lazyerror',
|
23
|
+
//strictClass: 'lazystrict',
|
24
|
+
autosizesClass: 'lazyautosizes',
|
25
|
+
srcAttr: 'data-src',
|
26
|
+
srcsetAttr: 'data-srcset',
|
27
|
+
sizesAttr: 'data-sizes',
|
28
|
+
//preloadAfterLoad: false,
|
29
|
+
minSize: 40,
|
30
|
+
customMedia: {},
|
31
|
+
init: true,
|
32
|
+
expFactor: 1.5,
|
33
|
+
hFac: 0.8,
|
34
|
+
loadMode: 2,
|
35
|
+
loadHidden: true,
|
36
|
+
ricTimeout: 0,
|
37
|
+
throttleDelay: 125,
|
38
|
+
};
|
39
|
+
|
40
|
+
lazySizesCfg = window.lazySizesConfig || window.lazysizesConfig || {};
|
41
|
+
|
42
|
+
for(prop in lazySizesDefaults){
|
43
|
+
if(!(prop in lazySizesCfg)){
|
44
|
+
lazySizesCfg[prop] = lazySizesDefaults[prop];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
})();
|
48
|
+
|
49
|
+
if (!document || !document.getElementsByClassName) {
|
50
|
+
return {
|
51
|
+
init: function () {},
|
52
|
+
cfg: lazySizesCfg,
|
53
|
+
noSupport: true,
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
var docElem = document.documentElement;
|
58
|
+
|
59
|
+
var supportPicture = window.HTMLPictureElement;
|
60
|
+
|
61
|
+
var _addEventListener = 'addEventListener';
|
62
|
+
|
63
|
+
var _getAttribute = 'getAttribute';
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Update to bind to window because 'this' becomes null during SSR
|
67
|
+
* builds.
|
68
|
+
*/
|
69
|
+
var addEventListener = window[_addEventListener].bind(window);
|
70
|
+
|
71
|
+
var setTimeout = window.setTimeout;
|
72
|
+
|
73
|
+
var requestAnimationFrame = window.requestAnimationFrame || setTimeout;
|
74
|
+
|
75
|
+
var requestIdleCallback = window.requestIdleCallback;
|
76
|
+
|
77
|
+
var regPicture = /^picture$/i;
|
78
|
+
|
79
|
+
var loadEvents = ['load', 'error', 'lazyincluded', '_lazyloaded'];
|
80
|
+
|
81
|
+
var regClassCache = {};
|
82
|
+
|
83
|
+
var forEach = Array.prototype.forEach;
|
84
|
+
|
85
|
+
var hasClass = function(ele, cls) {
|
86
|
+
if(!regClassCache[cls]){
|
87
|
+
regClassCache[cls] = new RegExp('(\\s|^)'+cls+'(\\s|$)');
|
88
|
+
}
|
89
|
+
return regClassCache[cls].test(ele[_getAttribute]('class') || '') && regClassCache[cls];
|
90
|
+
};
|
91
|
+
|
92
|
+
var addClass = function(ele, cls) {
|
93
|
+
if (!hasClass(ele, cls)){
|
94
|
+
ele.setAttribute('class', (ele[_getAttribute]('class') || '').trim() + ' ' + cls);
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
var removeClass = function(ele, cls) {
|
99
|
+
var reg;
|
100
|
+
if ((reg = hasClass(ele,cls))) {
|
101
|
+
ele.setAttribute('class', (ele[_getAttribute]('class') || '').replace(reg, ' '));
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
var addRemoveLoadEvents = function(dom, fn, add){
|
106
|
+
var action = add ? _addEventListener : 'removeEventListener';
|
107
|
+
if(add){
|
108
|
+
addRemoveLoadEvents(dom, fn);
|
109
|
+
}
|
110
|
+
loadEvents.forEach(function(evt){
|
111
|
+
dom[action](evt, fn);
|
112
|
+
});
|
113
|
+
};
|
114
|
+
|
115
|
+
var triggerEvent = function(elem, name, detail, noBubbles, noCancelable){
|
116
|
+
var event = document.createEvent('Event');
|
117
|
+
|
118
|
+
if(!detail){
|
119
|
+
detail = {};
|
120
|
+
}
|
121
|
+
|
122
|
+
detail.instance = lazysizes;
|
123
|
+
|
124
|
+
event.initEvent(name, !noBubbles, !noCancelable);
|
125
|
+
|
126
|
+
event.detail = detail;
|
127
|
+
|
128
|
+
elem.dispatchEvent(event);
|
129
|
+
return event;
|
130
|
+
};
|
131
|
+
|
132
|
+
var updatePolyfill = function (el, full){
|
133
|
+
var polyfill;
|
134
|
+
if( !supportPicture && ( polyfill = (window.picturefill || lazySizesCfg.pf) ) ){
|
135
|
+
if(full && full.src && !el[_getAttribute]('srcset')){
|
136
|
+
el.setAttribute('srcset', full.src);
|
137
|
+
}
|
138
|
+
polyfill({reevaluate: true, elements: [el]});
|
139
|
+
} else if(full && full.src){
|
140
|
+
el.src = full.src;
|
141
|
+
}
|
142
|
+
};
|
143
|
+
|
144
|
+
var getCSS = function (elem, style){
|
145
|
+
return (getComputedStyle(elem, null) || {})[style];
|
146
|
+
};
|
147
|
+
|
148
|
+
var getWidth = function(elem, parent, width){
|
149
|
+
width = width || elem.offsetWidth;
|
150
|
+
|
151
|
+
while(width < lazySizesCfg.minSize && parent && !elem._lazysizesWidth){
|
152
|
+
width = parent.offsetWidth;
|
153
|
+
parent = parent.parentNode;
|
154
|
+
}
|
155
|
+
|
156
|
+
return width;
|
157
|
+
};
|
158
|
+
|
159
|
+
var rAF = (function(){
|
160
|
+
var running, waiting;
|
161
|
+
var firstFns = [];
|
162
|
+
var secondFns = [];
|
163
|
+
var fns = firstFns;
|
164
|
+
|
165
|
+
var run = function(){
|
166
|
+
var runFns = fns;
|
167
|
+
|
168
|
+
fns = firstFns.length ? secondFns : firstFns;
|
169
|
+
|
170
|
+
running = true;
|
171
|
+
waiting = false;
|
172
|
+
|
173
|
+
while(runFns.length){
|
174
|
+
runFns.shift()();
|
175
|
+
}
|
176
|
+
|
177
|
+
running = false;
|
178
|
+
};
|
179
|
+
|
180
|
+
var rafBatch = function(fn, queue){
|
181
|
+
if(running && !queue){
|
182
|
+
fn.apply(this, arguments);
|
183
|
+
} else {
|
184
|
+
fns.push(fn);
|
185
|
+
|
186
|
+
if(!waiting){
|
187
|
+
waiting = true;
|
188
|
+
(document.hidden ? setTimeout : requestAnimationFrame)(run);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
};
|
192
|
+
|
193
|
+
rafBatch._lsFlush = run;
|
194
|
+
|
195
|
+
return rafBatch;
|
196
|
+
})();
|
197
|
+
|
198
|
+
var rAFIt = function(fn, simple){
|
199
|
+
return simple ?
|
200
|
+
function() {
|
201
|
+
rAF(fn);
|
202
|
+
} :
|
203
|
+
function(){
|
204
|
+
var that = this;
|
205
|
+
var args = arguments;
|
206
|
+
rAF(function(){
|
207
|
+
fn.apply(that, args);
|
208
|
+
});
|
209
|
+
}
|
210
|
+
;
|
211
|
+
};
|
212
|
+
|
213
|
+
var throttle = function(fn){
|
214
|
+
var running;
|
215
|
+
var lastTime = 0;
|
216
|
+
var gDelay = lazySizesCfg.throttleDelay;
|
217
|
+
var rICTimeout = lazySizesCfg.ricTimeout;
|
218
|
+
var run = function(){
|
219
|
+
running = false;
|
220
|
+
lastTime = Date.now();
|
221
|
+
fn();
|
222
|
+
};
|
223
|
+
var idleCallback = requestIdleCallback && rICTimeout > 49 ?
|
224
|
+
function(){
|
225
|
+
requestIdleCallback(run, {timeout: rICTimeout});
|
226
|
+
|
227
|
+
if(rICTimeout !== lazySizesCfg.ricTimeout){
|
228
|
+
rICTimeout = lazySizesCfg.ricTimeout;
|
229
|
+
}
|
230
|
+
} :
|
231
|
+
rAFIt(function(){
|
232
|
+
setTimeout(run);
|
233
|
+
}, true)
|
234
|
+
;
|
235
|
+
|
236
|
+
return function(isPriority){
|
237
|
+
var delay;
|
238
|
+
|
239
|
+
if((isPriority = isPriority === true)){
|
240
|
+
rICTimeout = 33;
|
241
|
+
}
|
242
|
+
|
243
|
+
if(running){
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
|
247
|
+
running = true;
|
248
|
+
|
249
|
+
delay = gDelay - (Date.now() - lastTime);
|
250
|
+
|
251
|
+
if(delay < 0){
|
252
|
+
delay = 0;
|
253
|
+
}
|
254
|
+
|
255
|
+
if(isPriority || delay < 9){
|
256
|
+
idleCallback();
|
257
|
+
} else {
|
258
|
+
setTimeout(idleCallback, delay);
|
259
|
+
}
|
260
|
+
};
|
261
|
+
};
|
262
|
+
|
263
|
+
//based on http://modernjavascript.blogspot.de/2013/08/building-better-debounce.html
|
264
|
+
var debounce = function(func) {
|
265
|
+
var timeout, timestamp;
|
266
|
+
var wait = 99;
|
267
|
+
var run = function(){
|
268
|
+
timeout = null;
|
269
|
+
func();
|
270
|
+
};
|
271
|
+
var later = function() {
|
272
|
+
var last = Date.now() - timestamp;
|
273
|
+
|
274
|
+
if (last < wait) {
|
275
|
+
setTimeout(later, wait - last);
|
276
|
+
} else {
|
277
|
+
(requestIdleCallback || run)(run);
|
278
|
+
}
|
279
|
+
};
|
280
|
+
|
281
|
+
return function() {
|
282
|
+
timestamp = Date.now();
|
283
|
+
|
284
|
+
if (!timeout) {
|
285
|
+
timeout = setTimeout(later, wait);
|
286
|
+
}
|
287
|
+
};
|
288
|
+
};
|
289
|
+
|
290
|
+
var loader = (function(){
|
291
|
+
var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;
|
292
|
+
|
293
|
+
var eLvW, elvH, eLtop, eLleft, eLright, eLbottom, isBodyHidden;
|
294
|
+
|
295
|
+
var regImg = /^img$/i;
|
296
|
+
var regIframe = /^iframe$/i;
|
297
|
+
|
298
|
+
var supportScroll = ('onscroll' in window) && !(/(gle|ing)bot/.test(navigator.userAgent));
|
299
|
+
|
300
|
+
var shrinkExpand = 0;
|
301
|
+
var currentExpand = 0;
|
302
|
+
|
303
|
+
var isLoading = 0;
|
304
|
+
var lowRuns = -1;
|
305
|
+
|
306
|
+
var resetPreloading = function(e){
|
307
|
+
isLoading--;
|
308
|
+
if(!e || isLoading < 0 || !e.target){
|
309
|
+
isLoading = 0;
|
310
|
+
}
|
311
|
+
};
|
312
|
+
|
313
|
+
var isVisible = function (elem) {
|
314
|
+
if (isBodyHidden == null) {
|
315
|
+
isBodyHidden = getCSS(document.body, 'visibility') == 'hidden';
|
316
|
+
}
|
317
|
+
|
318
|
+
return isBodyHidden || !(getCSS(elem.parentNode, 'visibility') == 'hidden' && getCSS(elem, 'visibility') == 'hidden');
|
319
|
+
};
|
320
|
+
|
321
|
+
var isNestedVisible = function(elem, elemExpand){
|
322
|
+
var outerRect;
|
323
|
+
var parent = elem;
|
324
|
+
var visible = isVisible(elem);
|
325
|
+
|
326
|
+
eLtop -= elemExpand;
|
327
|
+
eLbottom += elemExpand;
|
328
|
+
eLleft -= elemExpand;
|
329
|
+
eLright += elemExpand;
|
330
|
+
|
331
|
+
while(visible && (parent = parent.offsetParent) && parent != document.body && parent != docElem){
|
332
|
+
visible = ((getCSS(parent, 'opacity') || 1) > 0);
|
333
|
+
|
334
|
+
if(visible && getCSS(parent, 'overflow') != 'visible'){
|
335
|
+
outerRect = parent.getBoundingClientRect();
|
336
|
+
visible = eLright > outerRect.left &&
|
337
|
+
eLleft < outerRect.right &&
|
338
|
+
eLbottom > outerRect.top - 1 &&
|
339
|
+
eLtop < outerRect.bottom + 1
|
340
|
+
;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
return visible;
|
345
|
+
};
|
346
|
+
|
347
|
+
var checkElements = function() {
|
348
|
+
var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal,
|
349
|
+
beforeExpandVal, defaultExpand, preloadExpand, hFac;
|
350
|
+
var lazyloadElems = lazysizes.elements;
|
351
|
+
|
352
|
+
if((loadMode = lazySizesCfg.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
|
353
|
+
|
354
|
+
i = 0;
|
355
|
+
|
356
|
+
lowRuns++;
|
357
|
+
|
358
|
+
for(; i < eLlen; i++){
|
359
|
+
|
360
|
+
if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
|
361
|
+
|
362
|
+
if(!supportScroll || (lazysizes.prematureUnveil && lazysizes.prematureUnveil(lazyloadElems[i]))){unveilElement(lazyloadElems[i]);continue;}
|
363
|
+
|
364
|
+
if(!(elemExpandVal = lazyloadElems[i][_getAttribute]('data-expand')) || !(elemExpand = elemExpandVal * 1)){
|
365
|
+
elemExpand = currentExpand;
|
366
|
+
}
|
367
|
+
|
368
|
+
if (!defaultExpand) {
|
369
|
+
defaultExpand = (!lazySizesCfg.expand || lazySizesCfg.expand < 1) ?
|
370
|
+
docElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370 :
|
371
|
+
lazySizesCfg.expand;
|
372
|
+
|
373
|
+
lazysizes._defEx = defaultExpand;
|
374
|
+
|
375
|
+
preloadExpand = defaultExpand * lazySizesCfg.expFactor;
|
376
|
+
hFac = lazySizesCfg.hFac;
|
377
|
+
isBodyHidden = null;
|
378
|
+
|
379
|
+
if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden){
|
380
|
+
currentExpand = preloadExpand;
|
381
|
+
lowRuns = 0;
|
382
|
+
} else if(loadMode > 1 && lowRuns > 1 && isLoading < 6){
|
383
|
+
currentExpand = defaultExpand;
|
384
|
+
} else {
|
385
|
+
currentExpand = shrinkExpand;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
if(beforeExpandVal !== elemExpand){
|
390
|
+
eLvW = innerWidth + (elemExpand * hFac);
|
391
|
+
elvH = innerHeight + elemExpand;
|
392
|
+
elemNegativeExpand = elemExpand * -1;
|
393
|
+
beforeExpandVal = elemExpand;
|
394
|
+
}
|
395
|
+
|
396
|
+
rect = lazyloadElems[i].getBoundingClientRect();
|
397
|
+
|
398
|
+
if ((eLbottom = rect.bottom) >= elemNegativeExpand &&
|
399
|
+
(eLtop = rect.top) <= elvH &&
|
400
|
+
(eLright = rect.right) >= elemNegativeExpand * hFac &&
|
401
|
+
(eLleft = rect.left) <= eLvW &&
|
402
|
+
(eLbottom || eLright || eLleft || eLtop) &&
|
403
|
+
(lazySizesCfg.loadHidden || isVisible(lazyloadElems[i])) &&
|
404
|
+
((isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4)) || isNestedVisible(lazyloadElems[i], elemExpand))){
|
405
|
+
unveilElement(lazyloadElems[i]);
|
406
|
+
loadedSomething = true;
|
407
|
+
if(isLoading > 9){break;}
|
408
|
+
} else if(!loadedSomething && isCompleted && !autoLoadElem &&
|
409
|
+
isLoading < 4 && lowRuns < 4 && loadMode > 2 &&
|
410
|
+
(preloadElems[0] || lazySizesCfg.preloadAfterLoad) &&
|
411
|
+
(preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesCfg.sizesAttr) != 'auto')))){
|
412
|
+
autoLoadElem = preloadElems[0] || lazyloadElems[i];
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
if(autoLoadElem && !loadedSomething){
|
417
|
+
unveilElement(autoLoadElem);
|
418
|
+
}
|
419
|
+
}
|
420
|
+
};
|
421
|
+
|
422
|
+
var throttledCheckElements = throttle(checkElements);
|
423
|
+
|
424
|
+
var switchLoadingClass = function(e){
|
425
|
+
var elem = e.target;
|
426
|
+
|
427
|
+
if (elem._lazyCache) {
|
428
|
+
delete elem._lazyCache;
|
429
|
+
return;
|
430
|
+
}
|
431
|
+
|
432
|
+
resetPreloading(e);
|
433
|
+
addClass(elem, lazySizesCfg.loadedClass);
|
434
|
+
removeClass(elem, lazySizesCfg.loadingClass);
|
435
|
+
addRemoveLoadEvents(elem, rafSwitchLoadingClass);
|
436
|
+
triggerEvent(elem, 'lazyloaded');
|
437
|
+
};
|
438
|
+
var rafedSwitchLoadingClass = rAFIt(switchLoadingClass);
|
439
|
+
var rafSwitchLoadingClass = function(e){
|
440
|
+
rafedSwitchLoadingClass({target: e.target});
|
441
|
+
};
|
442
|
+
|
443
|
+
var changeIframeSrc = function(elem, src){
|
444
|
+
try {
|
445
|
+
elem.contentWindow.location.replace(src);
|
446
|
+
} catch(e){
|
447
|
+
elem.src = src;
|
448
|
+
}
|
449
|
+
};
|
450
|
+
|
451
|
+
var handleSources = function(source){
|
452
|
+
var customMedia;
|
453
|
+
|
454
|
+
var sourceSrcset = source[_getAttribute](lazySizesCfg.srcsetAttr);
|
455
|
+
|
456
|
+
if( (customMedia = lazySizesCfg.customMedia[source[_getAttribute]('data-media') || source[_getAttribute]('media')]) ){
|
457
|
+
source.setAttribute('media', customMedia);
|
458
|
+
}
|
459
|
+
|
460
|
+
if(sourceSrcset){
|
461
|
+
source.setAttribute('srcset', sourceSrcset);
|
462
|
+
}
|
463
|
+
};
|
464
|
+
|
465
|
+
var lazyUnveil = rAFIt(function (elem, detail, isAuto, sizes, isImg){
|
466
|
+
var src, srcset, parent, isPicture, event, firesLoad;
|
467
|
+
|
468
|
+
if(!(event = triggerEvent(elem, 'lazybeforeunveil', detail)).defaultPrevented){
|
469
|
+
|
470
|
+
if(sizes){
|
471
|
+
if(isAuto){
|
472
|
+
addClass(elem, lazySizesCfg.autosizesClass);
|
473
|
+
} else {
|
474
|
+
elem.setAttribute('sizes', sizes);
|
475
|
+
}
|
476
|
+
}
|
477
|
+
|
478
|
+
srcset = elem[_getAttribute](lazySizesCfg.srcsetAttr);
|
479
|
+
src = elem[_getAttribute](lazySizesCfg.srcAttr);
|
480
|
+
|
481
|
+
if(isImg) {
|
482
|
+
parent = elem.parentNode;
|
483
|
+
isPicture = parent && regPicture.test(parent.nodeName || '');
|
484
|
+
}
|
485
|
+
|
486
|
+
firesLoad = detail.firesLoad || (('src' in elem) && (srcset || src || isPicture));
|
487
|
+
|
488
|
+
event = {target: elem};
|
489
|
+
|
490
|
+
addClass(elem, lazySizesCfg.loadingClass);
|
491
|
+
|
492
|
+
if(firesLoad){
|
493
|
+
clearTimeout(resetPreloadingTimer);
|
494
|
+
resetPreloadingTimer = setTimeout(resetPreloading, 2500);
|
495
|
+
addRemoveLoadEvents(elem, rafSwitchLoadingClass, true);
|
496
|
+
}
|
497
|
+
|
498
|
+
if(isPicture){
|
499
|
+
forEach.call(parent.getElementsByTagName('source'), handleSources);
|
500
|
+
}
|
501
|
+
|
502
|
+
if(srcset){
|
503
|
+
elem.setAttribute('srcset', srcset);
|
504
|
+
} else if(src && !isPicture){
|
505
|
+
if(regIframe.test(elem.nodeName)){
|
506
|
+
changeIframeSrc(elem, src);
|
507
|
+
} else {
|
508
|
+
elem.src = src;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
|
512
|
+
if(isImg && (srcset || isPicture)){
|
513
|
+
updatePolyfill(elem, {src: src});
|
514
|
+
}
|
515
|
+
}
|
516
|
+
|
517
|
+
if(elem._lazyRace){
|
518
|
+
delete elem._lazyRace;
|
519
|
+
}
|
520
|
+
removeClass(elem, lazySizesCfg.lazyClass);
|
521
|
+
|
522
|
+
rAF(function(){
|
523
|
+
// Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015)
|
524
|
+
var isLoaded = elem.complete && elem.naturalWidth > 1;
|
525
|
+
|
526
|
+
if( !firesLoad || isLoaded){
|
527
|
+
if (isLoaded) {
|
528
|
+
addClass(elem, 'ls-is-cached');
|
529
|
+
}
|
530
|
+
switchLoadingClass(event);
|
531
|
+
elem._lazyCache = true;
|
532
|
+
setTimeout(function(){
|
533
|
+
if ('_lazyCache' in elem) {
|
534
|
+
delete elem._lazyCache;
|
535
|
+
}
|
536
|
+
}, 9);
|
537
|
+
}
|
538
|
+
if (elem.loading == 'lazy') {
|
539
|
+
isLoading--;
|
540
|
+
}
|
541
|
+
}, true);
|
542
|
+
});
|
543
|
+
|
544
|
+
var unveilElement = function (elem){
|
545
|
+
if (elem._lazyRace) {return;}
|
546
|
+
var detail;
|
547
|
+
|
548
|
+
var isImg = regImg.test(elem.nodeName);
|
549
|
+
|
550
|
+
//allow using sizes="auto", but don't use. it's invalid. Use data-sizes="auto" or a valid value for sizes instead (i.e.: sizes="80vw")
|
551
|
+
var sizes = isImg && (elem[_getAttribute](lazySizesCfg.sizesAttr) || elem[_getAttribute]('sizes'));
|
552
|
+
var isAuto = sizes == 'auto';
|
553
|
+
|
554
|
+
if( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesCfg.errorClass) && hasClass(elem, lazySizesCfg.lazyClass)){return;}
|
555
|
+
|
556
|
+
detail = triggerEvent(elem, 'lazyunveilread').detail;
|
557
|
+
|
558
|
+
if(isAuto){
|
559
|
+
autoSizer.updateElem(elem, true, elem.offsetWidth);
|
560
|
+
}
|
561
|
+
|
562
|
+
elem._lazyRace = true;
|
563
|
+
isLoading++;
|
564
|
+
|
565
|
+
lazyUnveil(elem, detail, isAuto, sizes, isImg);
|
566
|
+
};
|
567
|
+
|
568
|
+
var afterScroll = debounce(function(){
|
569
|
+
lazySizesCfg.loadMode = 3;
|
570
|
+
throttledCheckElements();
|
571
|
+
});
|
572
|
+
|
573
|
+
var altLoadmodeScrollListner = function(){
|
574
|
+
if(lazySizesCfg.loadMode == 3){
|
575
|
+
lazySizesCfg.loadMode = 2;
|
576
|
+
}
|
577
|
+
afterScroll();
|
578
|
+
};
|
579
|
+
|
580
|
+
var onload = function(){
|
581
|
+
if(isCompleted){return;}
|
582
|
+
if(Date.now() - started < 999){
|
583
|
+
setTimeout(onload, 999);
|
584
|
+
return;
|
585
|
+
}
|
586
|
+
|
587
|
+
|
588
|
+
isCompleted = true;
|
589
|
+
|
590
|
+
lazySizesCfg.loadMode = 3;
|
591
|
+
|
592
|
+
throttledCheckElements();
|
593
|
+
|
594
|
+
addEventListener('scroll', altLoadmodeScrollListner, true);
|
595
|
+
};
|
596
|
+
|
597
|
+
return {
|
598
|
+
_: function(){
|
599
|
+
started = Date.now();
|
600
|
+
|
601
|
+
lazysizes.elements = document.getElementsByClassName(lazySizesCfg.lazyClass);
|
602
|
+
preloadElems = document.getElementsByClassName(lazySizesCfg.lazyClass + ' ' + lazySizesCfg.preloadClass);
|
603
|
+
|
604
|
+
addEventListener('scroll', throttledCheckElements, true);
|
605
|
+
|
606
|
+
addEventListener('resize', throttledCheckElements, true);
|
607
|
+
|
608
|
+
addEventListener('pageshow', function (e) {
|
609
|
+
if (e.persisted) {
|
610
|
+
var loadingElements = document.querySelectorAll('.' + lazySizesCfg.loadingClass);
|
611
|
+
|
612
|
+
if (loadingElements.length && loadingElements.forEach) {
|
613
|
+
requestAnimationFrame(function () {
|
614
|
+
loadingElements.forEach( function (img) {
|
615
|
+
if (img.complete) {
|
616
|
+
unveilElement(img);
|
617
|
+
}
|
618
|
+
});
|
619
|
+
});
|
620
|
+
}
|
621
|
+
}
|
622
|
+
});
|
623
|
+
|
624
|
+
if(window.MutationObserver){
|
625
|
+
new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
|
626
|
+
} else {
|
627
|
+
docElem[_addEventListener]('DOMNodeInserted', throttledCheckElements, true);
|
628
|
+
docElem[_addEventListener]('DOMAttrModified', throttledCheckElements, true);
|
629
|
+
setInterval(throttledCheckElements, 999);
|
630
|
+
}
|
631
|
+
|
632
|
+
addEventListener('hashchange', throttledCheckElements, true);
|
633
|
+
|
634
|
+
//, 'fullscreenchange'
|
635
|
+
['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend'].forEach(function(name){
|
636
|
+
document[_addEventListener](name, throttledCheckElements, true);
|
637
|
+
});
|
638
|
+
|
639
|
+
if((/d$|^c/.test(document.readyState))){
|
640
|
+
onload();
|
641
|
+
} else {
|
642
|
+
addEventListener('load', onload);
|
643
|
+
document[_addEventListener]('DOMContentLoaded', throttledCheckElements);
|
644
|
+
setTimeout(onload, 20000);
|
645
|
+
}
|
646
|
+
|
647
|
+
if(lazysizes.elements.length){
|
648
|
+
checkElements();
|
649
|
+
rAF._lsFlush();
|
650
|
+
} else {
|
651
|
+
throttledCheckElements();
|
652
|
+
}
|
653
|
+
},
|
654
|
+
checkElems: throttledCheckElements,
|
655
|
+
unveil: unveilElement,
|
656
|
+
_aLSL: altLoadmodeScrollListner,
|
657
|
+
};
|
658
|
+
})();
|
659
|
+
|
660
|
+
|
661
|
+
var autoSizer = (function(){
|
662
|
+
var autosizesElems;
|
663
|
+
|
664
|
+
var sizeElement = rAFIt(function(elem, parent, event, width){
|
665
|
+
var sources, i, len;
|
666
|
+
elem._lazysizesWidth = width;
|
667
|
+
width += 'px';
|
668
|
+
|
669
|
+
elem.setAttribute('sizes', width);
|
670
|
+
|
671
|
+
if(regPicture.test(parent.nodeName || '')){
|
672
|
+
sources = parent.getElementsByTagName('source');
|
673
|
+
for(i = 0, len = sources.length; i < len; i++){
|
674
|
+
sources[i].setAttribute('sizes', width);
|
675
|
+
}
|
676
|
+
}
|
677
|
+
|
678
|
+
if(!event.detail.dataAttr){
|
679
|
+
updatePolyfill(elem, event.detail);
|
680
|
+
}
|
681
|
+
});
|
682
|
+
var getSizeElement = function (elem, dataAttr, width){
|
683
|
+
var event;
|
684
|
+
var parent = elem.parentNode;
|
685
|
+
|
686
|
+
if(parent){
|
687
|
+
width = getWidth(elem, parent, width);
|
688
|
+
event = triggerEvent(elem, 'lazybeforesizes', {width: width, dataAttr: !!dataAttr});
|
689
|
+
|
690
|
+
if(!event.defaultPrevented){
|
691
|
+
width = event.detail.width;
|
692
|
+
|
693
|
+
if(width && width !== elem._lazysizesWidth){
|
694
|
+
sizeElement(elem, parent, event, width);
|
695
|
+
}
|
696
|
+
}
|
697
|
+
}
|
698
|
+
};
|
699
|
+
|
700
|
+
var updateElementsSizes = function(){
|
701
|
+
var i;
|
702
|
+
var len = autosizesElems.length;
|
703
|
+
if(len){
|
704
|
+
i = 0;
|
705
|
+
|
706
|
+
for(; i < len; i++){
|
707
|
+
getSizeElement(autosizesElems[i]);
|
708
|
+
}
|
709
|
+
}
|
710
|
+
};
|
711
|
+
|
712
|
+
var debouncedUpdateElementsSizes = debounce(updateElementsSizes);
|
713
|
+
|
714
|
+
return {
|
715
|
+
_: function(){
|
716
|
+
autosizesElems = document.getElementsByClassName(lazySizesCfg.autosizesClass);
|
717
|
+
addEventListener('resize', debouncedUpdateElementsSizes);
|
718
|
+
},
|
719
|
+
checkElems: debouncedUpdateElementsSizes,
|
720
|
+
updateElem: getSizeElement
|
721
|
+
};
|
722
|
+
})();
|
723
|
+
|
724
|
+
var init = function(){
|
725
|
+
if(!init.i && document.getElementsByClassName){
|
726
|
+
init.i = true;
|
727
|
+
autoSizer._();
|
728
|
+
loader._();
|
729
|
+
}
|
730
|
+
};
|
731
|
+
|
732
|
+
setTimeout(function(){
|
733
|
+
if(lazySizesCfg.init){
|
734
|
+
init();
|
735
|
+
}
|
736
|
+
});
|
737
|
+
|
738
|
+
lazysizes = {
|
739
|
+
cfg: lazySizesCfg,
|
740
|
+
autoSizer: autoSizer,
|
741
|
+
loader: loader,
|
742
|
+
init: init,
|
743
|
+
uP: updatePolyfill,
|
744
|
+
aC: addClass,
|
745
|
+
rC: removeClass,
|
746
|
+
hC: hasClass,
|
747
|
+
fire: triggerEvent,
|
748
|
+
gW: getWidth,
|
749
|
+
rAF: rAF,
|
750
|
+
};
|
751
|
+
|
752
|
+
return lazysizes;
|
753
|
+
}
|
754
|
+
));
|