Version Description
- Update lazyload script to bring back compatibility with IE9/10
Download this release
Release Info
| Developer | wp_media |
| Plugin | |
| Version | 1.4.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.1 to 1.4.2
- assets/js/lazyload-3.0.js +0 -433
- assets/js/lazyload-3.0.min.js +0 -2
- assets/js/lazyload-8.0.3.min.js +0 -1
- assets/js/{lazyload-8.0.3.js → lazyload-8.2.js} +41 -13
- assets/js/lazyload-8.2.min.js +1 -0
- readme.txt +5 -2
- rocket-lazy-load.php +5 -5
assets/js/lazyload-3.0.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
| 1 |
-
(function(root, factory) {
|
| 2 |
-
if (typeof define === 'function' && define.amd) {
|
| 3 |
-
define([], factory);
|
| 4 |
-
} else if (typeof exports === 'object') {
|
| 5 |
-
module.exports = factory();
|
| 6 |
-
} else {
|
| 7 |
-
root.LazyLoad = factory();
|
| 8 |
-
}
|
| 9 |
-
}(this, function() {
|
| 10 |
-
|
| 11 |
-
var _defaultSettings,
|
| 12 |
-
_supportsAddEventListener,
|
| 13 |
-
_supportsAttachEvent,
|
| 14 |
-
_supportsClassList,
|
| 15 |
-
_isInitialized = false;
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* PRIVATE FUNCTIONS *NOT RELATED* TO A SPECIFIC INSTANCE OF LAZY LOAD
|
| 20 |
-
* -------------------------------------------------------------------
|
| 21 |
-
*/
|
| 22 |
-
|
| 23 |
-
function _init() {
|
| 24 |
-
if (!_isInitialized) {
|
| 25 |
-
_defaultSettings = {
|
| 26 |
-
elements_selector: "img",
|
| 27 |
-
container: window,
|
| 28 |
-
threshold: 300,
|
| 29 |
-
throttle: 50,
|
| 30 |
-
data_src: "original",
|
| 31 |
-
data_srcset: "original-set",
|
| 32 |
-
class_loading: "loading",
|
| 33 |
-
class_loaded: "loaded",
|
| 34 |
-
skip_invisible: true,
|
| 35 |
-
callback_load: null,
|
| 36 |
-
callback_error: null,
|
| 37 |
-
callback_set: null,
|
| 38 |
-
callback_processed: null
|
| 39 |
-
};
|
| 40 |
-
_supportsAddEventListener = !!window.addEventListener;
|
| 41 |
-
_supportsAttachEvent = !!window.attachEvent;
|
| 42 |
-
_supportsClassList = !!document.body.classList;
|
| 43 |
-
|
| 44 |
-
_isInitialized = true;
|
| 45 |
-
}
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
function _addEventListener(element, eventName, callback) {
|
| 49 |
-
// Use addEventListener if available
|
| 50 |
-
if (_supportsAddEventListener) {
|
| 51 |
-
element.addEventListener(eventName, callback);
|
| 52 |
-
return;
|
| 53 |
-
}
|
| 54 |
-
// Otherwise use attachEvent, set this and event
|
| 55 |
-
if (_supportsAttachEvent) {
|
| 56 |
-
element.attachEvent('on' + eventName, (function(el) {
|
| 57 |
-
return function() {
|
| 58 |
-
callback.call(el, window.event);
|
| 59 |
-
};
|
| 60 |
-
}(element)));
|
| 61 |
-
// Break closure and primary circular reference to element
|
| 62 |
-
element = null;
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
function _removeEventListener(element, eventName, callback) {
|
| 67 |
-
// Use removeEventListener if available
|
| 68 |
-
if (_supportsAddEventListener) {
|
| 69 |
-
element.removeEventListener(eventName, callback);
|
| 70 |
-
return;
|
| 71 |
-
}
|
| 72 |
-
// Otherwise use detachEvent
|
| 73 |
-
if (_supportsAttachEvent) {
|
| 74 |
-
element.detachEvent('on' + eventName, callback);
|
| 75 |
-
}
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
function _isInsideViewport(element, container, threshold) {
|
| 79 |
-
|
| 80 |
-
var ownerDocument, documentTop, documentLeft;
|
| 81 |
-
|
| 82 |
-
function _getDocumentWidth() {
|
| 83 |
-
return window.innerWidth || (ownerDocument.documentElement.clientWidth || document.body.clientWidth);
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
function _getDocumentHeight() {
|
| 87 |
-
return window.innerHeight || (ownerDocument.documentElement.clientHeight || document.body.clientHeight);
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
function _getTopOffset(element) {
|
| 91 |
-
return element.getBoundingClientRect().top + documentTop - ownerDocument.documentElement.clientTop;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
function _getLeftOffset(element) {
|
| 95 |
-
return element.getBoundingClientRect().left + documentLeft - ownerDocument.documentElement.clientLeft;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
function _isBelowViewport() {
|
| 99 |
-
var fold;
|
| 100 |
-
if (container === window) {
|
| 101 |
-
fold = _getDocumentHeight() + documentTop;
|
| 102 |
-
} else {
|
| 103 |
-
fold = _getTopOffset(container) + container.offsetHeight;
|
| 104 |
-
}
|
| 105 |
-
return fold <= _getTopOffset(element) - threshold;
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
function _isAtRightOfViewport() {
|
| 109 |
-
var fold;
|
| 110 |
-
if (container === window) {
|
| 111 |
-
fold = _getDocumentWidth() + window.pageXOffset;
|
| 112 |
-
} else {
|
| 113 |
-
fold = _getLeftOffset(container) + _getDocumentWidth();
|
| 114 |
-
}
|
| 115 |
-
return fold <= _getLeftOffset(element) - threshold;
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
function _isAboveViewport() {
|
| 119 |
-
var fold;
|
| 120 |
-
if (container === window) {
|
| 121 |
-
fold = documentTop;
|
| 122 |
-
} else {
|
| 123 |
-
fold = _getTopOffset(container);
|
| 124 |
-
}
|
| 125 |
-
return fold >= _getTopOffset(element) + threshold + element.offsetHeight;
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
function _isAtLeftOfViewport() {
|
| 129 |
-
var fold;
|
| 130 |
-
if (container === window) {
|
| 131 |
-
fold = documentLeft;
|
| 132 |
-
} else {
|
| 133 |
-
fold = _getLeftOffset(container);
|
| 134 |
-
}
|
| 135 |
-
return fold >= _getLeftOffset(element) + threshold + element.offsetWidth;
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
ownerDocument = element.ownerDocument;
|
| 139 |
-
documentTop = window.pageYOffset || ownerDocument.body.scrollTop;
|
| 140 |
-
documentLeft = window.pageXOffset || ownerDocument.body.scrollLeft;
|
| 141 |
-
|
| 142 |
-
return !_isBelowViewport() && !_isAboveViewport() && !_isAtRightOfViewport() && !_isAtLeftOfViewport();
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
function _now() {
|
| 146 |
-
var d = new Date();
|
| 147 |
-
return d.getTime();
|
| 148 |
-
}
|
| 149 |
-
|
| 150 |
-
function _merge_objects(obj1, obj2) {
|
| 151 |
-
var obj3 = {},
|
| 152 |
-
propertyName;
|
| 153 |
-
for (propertyName in obj1) {
|
| 154 |
-
if (obj1.hasOwnProperty(propertyName)) {
|
| 155 |
-
obj3[propertyName] = obj1[propertyName];
|
| 156 |
-
}
|
| 157 |
-
}
|
| 158 |
-
for (propertyName in obj2) {
|
| 159 |
-
if (obj2.hasOwnProperty(propertyName)) {
|
| 160 |
-
obj3[propertyName] = obj2[propertyName];
|
| 161 |
-
}
|
| 162 |
-
}
|
| 163 |
-
return obj3;
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
function _convertToArray(nodeSet) {
|
| 167 |
-
try {
|
| 168 |
-
return Array.prototype.slice.call(nodeSet);
|
| 169 |
-
} catch (e) {
|
| 170 |
-
var array = [],
|
| 171 |
-
i, l = nodeSet.length;
|
| 172 |
-
|
| 173 |
-
for (i = 0; i < l; i++) {
|
| 174 |
-
array.push(nodeSet[i]);
|
| 175 |
-
}
|
| 176 |
-
return array;
|
| 177 |
-
}
|
| 178 |
-
}
|
| 179 |
-
|
| 180 |
-
function _addClass(element, className) {
|
| 181 |
-
/* HTML 5 compliant browsers. */
|
| 182 |
-
if (_supportsClassList) {
|
| 183 |
-
element.classList.add(className);
|
| 184 |
-
return;
|
| 185 |
-
}
|
| 186 |
-
/* Legacy browsers (IE<10) support. */
|
| 187 |
-
element.className += (element.className ? ' ' : '') + className;
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
function _removeClass(element, className) {
|
| 191 |
-
/* HTML 5 compliant browsers. */
|
| 192 |
-
if (_supportsClassList) {
|
| 193 |
-
element.classList.remove(className);
|
| 194 |
-
return;
|
| 195 |
-
}
|
| 196 |
-
/* Legacy browsers (IE<10) support. */
|
| 197 |
-
element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').replace(/^\s+/, '').replace(/\s+$/, '');
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
function _setSourcesForPicture(element, srcsetDataAttribute) {
|
| 201 |
-
var parent = element.parentElement;
|
| 202 |
-
if (parent.tagName !== 'PICTURE') {
|
| 203 |
-
return;
|
| 204 |
-
}
|
| 205 |
-
for (var i = 0; i < parent.children.length; i++) {
|
| 206 |
-
var pictureChild = parent.children[i];
|
| 207 |
-
if (pictureChild.tagName === 'SOURCE') {
|
| 208 |
-
var sourceSrcset = pictureChild.getAttribute('data-' + srcsetDataAttribute);
|
| 209 |
-
if (sourceSrcset) {
|
| 210 |
-
pictureChild.setAttribute('srcset', sourceSrcset);
|
| 211 |
-
}
|
| 212 |
-
}
|
| 213 |
-
}
|
| 214 |
-
}
|
| 215 |
-
|
| 216 |
-
function _setSources(element, srcsetDataAttribute, srcDataAttribute) {
|
| 217 |
-
var tagName = element.tagName;
|
| 218 |
-
var elementSrc = element.getAttribute('data-' + srcDataAttribute);
|
| 219 |
-
if (tagName === "IMG") {
|
| 220 |
-
_setSourcesForPicture(element, srcsetDataAttribute);
|
| 221 |
-
var imgSrcset = element.getAttribute('data-' + srcsetDataAttribute);
|
| 222 |
-
if (imgSrcset) element.setAttribute("srcset", imgSrcset);
|
| 223 |
-
if (elementSrc) element.setAttribute("src", elementSrc);
|
| 224 |
-
return;
|
| 225 |
-
}
|
| 226 |
-
if (tagName === "IFRAME") {
|
| 227 |
-
if (elementSrc) element.setAttribute("src", elementSrc);
|
| 228 |
-
return;
|
| 229 |
-
}
|
| 230 |
-
element.style.backgroundImage = "url(" + elementSrc + ")";
|
| 231 |
-
}
|
| 232 |
-
|
| 233 |
-
function _bind(fn, obj) {
|
| 234 |
-
return function() {
|
| 235 |
-
return fn.apply(obj, arguments);
|
| 236 |
-
};
|
| 237 |
-
}
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
/*
|
| 241 |
-
* INITIALIZER
|
| 242 |
-
* -----------
|
| 243 |
-
*/
|
| 244 |
-
|
| 245 |
-
function LazyLoad(instanceSettings) {
|
| 246 |
-
_init();
|
| 247 |
-
|
| 248 |
-
this._settings = _merge_objects(_defaultSettings, instanceSettings);
|
| 249 |
-
this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
|
| 250 |
-
|
| 251 |
-
this._previousLoopTime = 0;
|
| 252 |
-
this._loopTimeout = null;
|
| 253 |
-
|
| 254 |
-
this._handleScrollFn = _bind(this.handleScroll, this);
|
| 255 |
-
|
| 256 |
-
_addEventListener(window, "resize", this._handleScrollFn);
|
| 257 |
-
this.update();
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
/*
|
| 262 |
-
* PRIVATE FUNCTIONS *RELATED* TO A SPECIFIC INSTANCE OF LAZY LOAD
|
| 263 |
-
* ---------------------------------------------------------------
|
| 264 |
-
*/
|
| 265 |
-
|
| 266 |
-
LazyLoad.prototype._showOnAppear = function(element) {
|
| 267 |
-
var settings = this._settings;
|
| 268 |
-
|
| 269 |
-
function loadCallback() {
|
| 270 |
-
/* As this method is asynchronous, it must be protected against external destroy() calls */
|
| 271 |
-
if (settings === null) {
|
| 272 |
-
return;
|
| 273 |
-
}
|
| 274 |
-
/* Calling LOAD callback */
|
| 275 |
-
if (settings.callback_load) {
|
| 276 |
-
settings.callback_load(element);
|
| 277 |
-
}
|
| 278 |
-
_removeClass(element, settings.class_loading);
|
| 279 |
-
_addClass(element, settings.class_loaded);
|
| 280 |
-
_removeEventListener(element, "load", loadCallback);
|
| 281 |
-
}
|
| 282 |
-
|
| 283 |
-
if (element.tagName === "IMG" || element.tagName === "IFRAME") {
|
| 284 |
-
_addEventListener(element, "load", loadCallback);
|
| 285 |
-
_addEventListener(element, "error", function () {
|
| 286 |
-
_removeEventListener(element, "load", loadCallback);
|
| 287 |
-
_removeClass(element, settings.class_loading);
|
| 288 |
-
if (settings.callback_error) {
|
| 289 |
-
settings.callback_error(element);
|
| 290 |
-
}
|
| 291 |
-
});
|
| 292 |
-
_addClass(element, settings.class_loading);
|
| 293 |
-
}
|
| 294 |
-
|
| 295 |
-
_setSources(element, settings.data_srcset, settings.data_src);
|
| 296 |
-
/* Calling SET callback */
|
| 297 |
-
if (settings.callback_set) {
|
| 298 |
-
settings.callback_set(element);
|
| 299 |
-
}
|
| 300 |
-
};
|
| 301 |
-
|
| 302 |
-
LazyLoad.prototype._loopThroughElements = function() {
|
| 303 |
-
var i, element,
|
| 304 |
-
settings = this._settings,
|
| 305 |
-
elements = this._elements,
|
| 306 |
-
elementsLength = (!elements) ? 0 : elements.length,
|
| 307 |
-
processedIndexes = [];
|
| 308 |
-
|
| 309 |
-
for (i = 0; i < elementsLength; i++) {
|
| 310 |
-
element = elements[i];
|
| 311 |
-
/* If must skip_invisible and element is invisible, skip it */
|
| 312 |
-
if (settings.skip_invisible && (element.offsetParent === null)) {
|
| 313 |
-
continue;
|
| 314 |
-
}
|
| 315 |
-
if (_isInsideViewport(element, settings.container, settings.threshold)) {
|
| 316 |
-
this._showOnAppear(element);
|
| 317 |
-
|
| 318 |
-
/* Marking the element as processed. */
|
| 319 |
-
processedIndexes.push(i);
|
| 320 |
-
element.wasProcessed = true;
|
| 321 |
-
}
|
| 322 |
-
}
|
| 323 |
-
/* Removing processed elements from this._elements. */
|
| 324 |
-
while (processedIndexes.length > 0) {
|
| 325 |
-
elements.splice(processedIndexes.pop(), 1);
|
| 326 |
-
/* Calling the end loop callback */
|
| 327 |
-
if (settings.callback_processed) {
|
| 328 |
-
settings.callback_processed(elements.length);
|
| 329 |
-
}
|
| 330 |
-
}
|
| 331 |
-
/* Stop listening to scroll event when 0 elements remains */
|
| 332 |
-
if (elementsLength === 0) {
|
| 333 |
-
this._stopScrollHandler();
|
| 334 |
-
}
|
| 335 |
-
};
|
| 336 |
-
|
| 337 |
-
LazyLoad.prototype._purgeElements = function() {
|
| 338 |
-
var i, element,
|
| 339 |
-
elements = this._elements,
|
| 340 |
-
elementsLength = elements.length,
|
| 341 |
-
elementsToPurge = [];
|
| 342 |
-
|
| 343 |
-
for (i = 0; i < elementsLength; i++) {
|
| 344 |
-
element = elements[i];
|
| 345 |
-
/* If the element has already been processed, skip it */
|
| 346 |
-
if (element.wasProcessed) {
|
| 347 |
-
elementsToPurge.push(i);
|
| 348 |
-
}
|
| 349 |
-
}
|
| 350 |
-
/* Removing elements to purge from this._elements. */
|
| 351 |
-
while (elementsToPurge.length > 0) {
|
| 352 |
-
elements.splice(elementsToPurge.pop(), 1);
|
| 353 |
-
}
|
| 354 |
-
};
|
| 355 |
-
|
| 356 |
-
LazyLoad.prototype._startScrollHandler = function() {
|
| 357 |
-
if (!this._isHandlingScroll) {
|
| 358 |
-
this._isHandlingScroll = true;
|
| 359 |
-
_addEventListener(this._settings.container, "scroll", this._handleScrollFn);
|
| 360 |
-
}
|
| 361 |
-
};
|
| 362 |
-
|
| 363 |
-
LazyLoad.prototype._stopScrollHandler = function() {
|
| 364 |
-
if (this._isHandlingScroll) {
|
| 365 |
-
this._isHandlingScroll = false;
|
| 366 |
-
_removeEventListener(this._settings.container, "scroll", this._handleScrollFn);
|
| 367 |
-
}
|
| 368 |
-
};
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
/*
|
| 372 |
-
* PUBLIC FUNCTIONS
|
| 373 |
-
* ----------------
|
| 374 |
-
*/
|
| 375 |
-
|
| 376 |
-
LazyLoad.prototype.handleScroll = function() {
|
| 377 |
-
var remainingTime,
|
| 378 |
-
now,
|
| 379 |
-
throttle;
|
| 380 |
-
|
| 381 |
-
// IE8 fix for destroy() malfunctioning
|
| 382 |
-
if (!this._settings) {
|
| 383 |
-
return;
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
now = _now();
|
| 387 |
-
throttle = this._settings.throttle;
|
| 388 |
-
|
| 389 |
-
if (throttle !== 0) {
|
| 390 |
-
remainingTime = throttle - (now - this._previousLoopTime);
|
| 391 |
-
if (remainingTime <= 0 || remainingTime > throttle) {
|
| 392 |
-
if (this._loopTimeout) {
|
| 393 |
-
clearTimeout(this._loopTimeout);
|
| 394 |
-
this._loopTimeout = null;
|
| 395 |
-
}
|
| 396 |
-
this._previousLoopTime = now;
|
| 397 |
-
this._loopThroughElements();
|
| 398 |
-
} else if (!this._loopTimeout) {
|
| 399 |
-
this._loopTimeout = setTimeout(_bind(function() {
|
| 400 |
-
this._previousLoopTime = _now();
|
| 401 |
-
this._loopTimeout = null;
|
| 402 |
-
this._loopThroughElements();
|
| 403 |
-
}, this), remainingTime);
|
| 404 |
-
}
|
| 405 |
-
} else {
|
| 406 |
-
this._loopThroughElements();
|
| 407 |
-
}
|
| 408 |
-
};
|
| 409 |
-
|
| 410 |
-
LazyLoad.prototype.update = function() {
|
| 411 |
-
this._elements = _convertToArray(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
|
| 412 |
-
this._purgeElements();
|
| 413 |
-
this._loopThroughElements();
|
| 414 |
-
this._startScrollHandler();
|
| 415 |
-
};
|
| 416 |
-
|
| 417 |
-
LazyLoad.prototype.destroy = function() {
|
| 418 |
-
_removeEventListener(window, "resize", this._handleScrollFn);
|
| 419 |
-
if (this._loopTimeout) {
|
| 420 |
-
clearTimeout(this._loopTimeout);
|
| 421 |
-
this._loopTimeout = null;
|
| 422 |
-
}
|
| 423 |
-
this._stopScrollHandler();
|
| 424 |
-
this._elements = null;
|
| 425 |
-
this._queryOriginNode = null;
|
| 426 |
-
this._settings = null;
|
| 427 |
-
};
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
return LazyLoad;
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/lazyload-3.0.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.LazyLoad=b()}(this,function(){function a(){r||(n={elements_selector:"img",container:window,threshold:300,throttle:50,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null},o=!!window.addEventListener,p=!!window.attachEvent,q=!!document.body.classList,r=!0)}function b(a,b,c){return o?void a.addEventListener(b,c):void(p&&(a.attachEvent("on"+b,function(a){return function(){c.call(a,window.event)}}(a)),a=null))}function c(a,b,c){return o?void a.removeEventListener(b,c):void(p&&a.detachEvent("on"+b,c))}function d(a,b,c){function d(){return window.innerWidth||l.documentElement.clientWidth||document.body.clientWidth}function e(){return window.innerHeight||l.documentElement.clientHeight||document.body.clientHeight}function f(a){return a.getBoundingClientRect().top+m-l.documentElement.clientTop}function g(a){return a.getBoundingClientRect().left+n-l.documentElement.clientLeft}function h(){var d;return d=b===window?e()+m:f(b)+b.offsetHeight,d<=f(a)-c}function i(){var e;return e=b===window?d()+window.pageXOffset:g(b)+d(),e<=g(a)-c}function j(){var d;return d=b===window?m:f(b),d>=f(a)+c+a.offsetHeight}function k(){var d;return d=b===window?n:g(b),d>=g(a)+c+a.offsetWidth}var l,m,n;return l=a.ownerDocument,m=window.pageYOffset||l.body.scrollTop,n=window.pageXOffset||l.body.scrollLeft,!(h()||j()||i()||k())}function e(){var a=new Date;return a.getTime()}function f(a,b){var c,d={};for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);for(c in b)b.hasOwnProperty(c)&&(d[c]=b[c]);return d}function g(a){try{return Array.prototype.slice.call(a)}catch(b){var c,d=[],e=a.length;for(c=0;e>c;c++)d.push(a[c]);return d}}function h(a,b){return q?void a.classList.add(b):void(a.className+=(a.className?" ":"")+b)}function i(a,b){return q?void a.classList.remove(b):void(a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,""))}function j(a,b){var c=a.parentElement;if("PICTURE"===c.tagName)for(var d=0;d<c.children.length;d++){var e=c.children[d];if("SOURCE"===e.tagName){var f=e.getAttribute("data-"+b);f&&e.setAttribute("srcset",f)}}}function k(a,b,c){var d=a.tagName,e=a.getAttribute("data-"+c);if("IMG"===d){j(a,b);var f=a.getAttribute("data-"+b);return f&&a.setAttribute("srcset",f),void(e&&a.setAttribute("src",e))}return"IFRAME"===d?void(e&&a.setAttribute("src",e)):void(a.style.backgroundImage="url("+e+")")}function l(a,b){return function(){return a.apply(b,arguments)}}function m(c){a(),this._settings=f(n,c),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._handleScrollFn=l(this.handleScroll,this),b(window,"resize",this._handleScrollFn),this.update()}var n,o,p,q,r=!1;return m.prototype._showOnAppear=function(a){function d(){null!==e&&(e.callback_load&&e.callback_load(a),i(a,e.class_loading),h(a,e.class_loaded),c(a,"load",d))}var e=this._settings;("IMG"===a.tagName||"IFRAME"===a.tagName)&&(b(a,"load",d),b(a,"error",function(){c(a,"load",d),i(a,e.class_loading),e.callback_error&&e.callback_error(a)}),h(a,e.class_loading)),k(a,e.data_srcset,e.data_src),e.callback_set&&e.callback_set(a)},m.prototype._loopThroughElements=function(){var a,b,c=this._settings,e=this._elements,f=e?e.length:0,g=[];for(a=0;f>a;a++)b=e[a],c.skip_invisible&&null===b.offsetParent||d(b,c.container,c.threshold)&&(this._showOnAppear(b),g.push(a),b.wasProcessed=!0);for(;g.length>0;)e.splice(g.pop(),1),c.callback_processed&&c.callback_processed(e.length);0===f&&this._stopScrollHandler()},m.prototype._purgeElements=function(){var a,b,c=this._elements,d=c.length,e=[];for(a=0;d>a;a++)b=c[a],b.wasProcessed&&e.push(a);for(;e.length>0;)c.splice(e.pop(),1)},m.prototype._startScrollHandler=function(){this._isHandlingScroll||(this._isHandlingScroll=!0,b(this._settings.container,"scroll",this._handleScrollFn))},m.prototype._stopScrollHandler=function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,c(this._settings.container,"scroll",this._handleScrollFn))},m.prototype.handleScroll=function(){var a,b,c;this._settings&&(b=e(),c=this._settings.throttle,0!==c?(a=c-(b-this._previousLoopTime),0>=a||a>c?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=b,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(l(function(){this._previousLoopTime=e(),this._loopTimeout=null,this._loopThroughElements()},this),a))):this._loopThroughElements())},m.prototype.update=function(){this._elements=g(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},m.prototype.destroy=function(){c(window,"resize",this._handleScrollFn),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null},m});
|
| 2 |
-
//# sourceMappingURL=lazyload.min.js.map
|
|
|
|
|
|
assets/js/lazyload-8.0.3.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
var _extends=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};!function(a,b){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.LazyLoad=b()}(this,function(){"use strict";var a={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"originalSet",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null},b=!("onscroll"in window)||/glebot/.test(navigator.userAgent),c=function(a,b){a&&a(b)},d=function(a){return a.getBoundingClientRect().top+window.pageYOffset-a.ownerDocument.documentElement.clientTop},e=function(a,b,c){return(b===window?window.innerHeight+window.pageYOffset:d(b)+b.offsetHeight)<=d(a)-c},f=function(a){return a.getBoundingClientRect().left+window.pageXOffset-a.ownerDocument.documentElement.clientLeft},g=function(a,b,c){var d=window.innerWidth;return(b===window?d+window.pageXOffset:f(b)+d)<=f(a)-c},h=function(a,b,c){return(b===window?window.pageYOffset:d(b))>=d(a)+c+a.offsetHeight},i=function(a,b,c){return(b===window?window.pageXOffset:f(b))>=f(a)+c+a.offsetWidth},j=function(a,b,c){return!(e(a,b,c)||h(a,b,c)||g(a,b,c)||i(a,b,c))},k=function(a,b){var c=new a(b),d=new CustomEvent("LazyLoad::Initialized",{detail:{instance:c}});window.dispatchEvent(d)},l=function(a,b){var c=a.parentElement;if("PICTURE"===c.tagName)for(var d=0;d<c.children.length;d++){var e=c.children[d];if("SOURCE"===e.tagName){var f=e.dataset[b];f&&e.setAttribute("srcset",f)}}},m=function(a,b,c){var d=a.tagName,e=a.dataset[c];if("IMG"===d){l(a,b);var f=a.dataset[b];return f&&a.setAttribute("srcset",f),void(e&&a.setAttribute("src",e))}if("IFRAME"===d)return void(e&&a.setAttribute("src",e));e&&(a.style.backgroundImage='url("'+e+'")')},n=function(b){this._settings=_extends({},a,b),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};n.prototype={_reveal:function(a){var b=this._settings,d=function d(){b&&(a.removeEventListener("load",e),a.removeEventListener("error",d),a.classList.remove(b.class_loading),a.classList.add(b.class_error),c(b.callback_error,a))},e=function e(){b&&(a.classList.remove(b.class_loading),a.classList.add(b.class_loaded),a.removeEventListener("load",e),a.removeEventListener("error",d),c(b.callback_load,a))};"IMG"!==a.tagName&&"IFRAME"!==a.tagName||(a.addEventListener("load",e),a.addEventListener("error",d),a.classList.add(b.class_loading)),m(a,b.data_srcset,b.data_src),c(b.callback_set,a)},_loopThroughElements:function(){var a=this._settings,d=this._elements,e=d?d.length:0,f=void 0,g=[],h=this._isFirstLoop;for(f=0;f<e;f++){var i=d[f];a.skip_invisible&&null===i.offsetParent||(b||j(i,a.container,a.threshold))&&(h&&i.classList.add(a.class_initial),this._reveal(i),g.push(f),i.dataset.wasProcessed=!0)}for(;g.length;)d.splice(g.pop(),1),c(a.callback_processed,d.length);0===e&&this._stopScrollHandler(),h&&(this._isFirstLoop=!1)},_purgeElements:function(){var a=this._elements,b=a.length,c=void 0,d=[];for(c=0;c<b;c++){a[c].dataset.wasProcessed&&d.push(c)}for(;d.length>0;)a.splice(d.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var a=this._settings.throttle;if(0!==a){var b=Date.now(),c=a-(b-this._previousLoopTime);c<=0||c>a?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=b,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),c))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var o=window.lazyLoadOptions;return o&&function(a,b){var c=b.length;if(c)for(var d=0;d<c;d++)k(a,b[d]);else k(a,b)}(n,o),n});
|
|
|
assets/js/{lazyload-8.0.3.js → lazyload-8.2.js}
RENAMED
|
@@ -13,7 +13,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 13 |
threshold: 300,
|
| 14 |
throttle: 150,
|
| 15 |
data_src: "original",
|
| 16 |
-
data_srcset: "
|
| 17 |
class_loading: "loading",
|
| 18 |
class_loaded: "loaded",
|
| 19 |
class_error: "error",
|
|
@@ -88,6 +88,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 88 |
}
|
| 89 |
};
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) {
|
| 92 |
var parent = element.parentElement;
|
| 93 |
if (parent.tagName !== "PICTURE") {
|
|
@@ -96,7 +106,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 96 |
for (var i = 0; i < parent.children.length; i++) {
|
| 97 |
var pictureChild = parent.children[i];
|
| 98 |
if (pictureChild.tagName === "SOURCE") {
|
| 99 |
-
var sourceSrcset = pictureChild
|
| 100 |
if (sourceSrcset) {
|
| 101 |
pictureChild.setAttribute("srcset", sourceSrcset);
|
| 102 |
}
|
|
@@ -106,10 +116,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 106 |
|
| 107 |
var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) {
|
| 108 |
var tagName = element.tagName;
|
| 109 |
-
var elementSrc = element
|
| 110 |
if (tagName === "IMG") {
|
| 111 |
setSourcesForPicture(element, srcsetDataAttribute);
|
| 112 |
-
var imgSrcset = element
|
| 113 |
if (imgSrcset) {
|
| 114 |
element.setAttribute("srcset", imgSrcset);
|
| 115 |
}
|
|
@@ -129,6 +139,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 129 |
}
|
| 130 |
};
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
/*
|
| 133 |
* Constructor
|
| 134 |
*/
|
|
@@ -162,8 +190,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 162 |
}
|
| 163 |
element.removeEventListener("load", loadCallback);
|
| 164 |
element.removeEventListener("error", errorCallback);
|
| 165 |
-
element
|
| 166 |
-
element
|
| 167 |
callCallback(settings.callback_error, element);
|
| 168 |
};
|
| 169 |
|
|
@@ -172,8 +200,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 172 |
if (!settings) {
|
| 173 |
return;
|
| 174 |
}
|
| 175 |
-
element
|
| 176 |
-
element
|
| 177 |
element.removeEventListener("load", loadCallback);
|
| 178 |
element.removeEventListener("error", errorCallback);
|
| 179 |
/* Calling LOAD callback */
|
|
@@ -183,7 +211,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 183 |
if (element.tagName === "IMG" || element.tagName === "IFRAME") {
|
| 184 |
element.addEventListener("load", loadCallback);
|
| 185 |
element.addEventListener("error", errorCallback);
|
| 186 |
-
element
|
| 187 |
}
|
| 188 |
|
| 189 |
setSources(element, settings.data_srcset, settings.data_src);
|
|
@@ -208,13 +236,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 208 |
|
| 209 |
if (isBot || isInsideViewport(element, settings.container, settings.threshold)) {
|
| 210 |
if (firstLoop) {
|
| 211 |
-
element
|
| 212 |
}
|
| 213 |
/* Start loading the image */
|
| 214 |
this._reveal(element);
|
| 215 |
/* Marking the element as processed. */
|
| 216 |
processedIndexes.push(i);
|
| 217 |
-
element
|
| 218 |
}
|
| 219 |
}
|
| 220 |
/* Removing processed elements from this._elements. */
|
|
@@ -242,7 +270,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 242 |
for (i = 0; i < elementsLength; i++) {
|
| 243 |
var element = elements[i];
|
| 244 |
/* If the element has already been processed, skip it */
|
| 245 |
-
if (element
|
| 246 |
elementsToPurge.push(i);
|
| 247 |
}
|
| 248 |
}
|
|
@@ -323,4 +351,4 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
| 323 |
}
|
| 324 |
|
| 325 |
return LazyLoad;
|
| 326 |
-
});
|
| 13 |
threshold: 300,
|
| 14 |
throttle: 150,
|
| 15 |
data_src: "original",
|
| 16 |
+
data_srcset: "original-set",
|
| 17 |
class_loading: "loading",
|
| 18 |
class_loaded: "loaded",
|
| 19 |
class_error: "error",
|
| 88 |
}
|
| 89 |
};
|
| 90 |
|
| 91 |
+
var dataPrefix = "data-";
|
| 92 |
+
|
| 93 |
+
var getData = function getData(element, attribute) {
|
| 94 |
+
return element.getAttribute(dataPrefix + attribute);
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
var setData = function setData(element, attribute, value) {
|
| 98 |
+
return element.setAttribute(dataPrefix + attribute, value);
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) {
|
| 102 |
var parent = element.parentElement;
|
| 103 |
if (parent.tagName !== "PICTURE") {
|
| 106 |
for (var i = 0; i < parent.children.length; i++) {
|
| 107 |
var pictureChild = parent.children[i];
|
| 108 |
if (pictureChild.tagName === "SOURCE") {
|
| 109 |
+
var sourceSrcset = getData(pictureChild, srcsetDataAttribute);
|
| 110 |
if (sourceSrcset) {
|
| 111 |
pictureChild.setAttribute("srcset", sourceSrcset);
|
| 112 |
}
|
| 116 |
|
| 117 |
var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) {
|
| 118 |
var tagName = element.tagName;
|
| 119 |
+
var elementSrc = getData(element, srcDataAttribute);
|
| 120 |
if (tagName === "IMG") {
|
| 121 |
setSourcesForPicture(element, srcsetDataAttribute);
|
| 122 |
+
var imgSrcset = getData(element, srcsetDataAttribute);
|
| 123 |
if (imgSrcset) {
|
| 124 |
element.setAttribute("srcset", imgSrcset);
|
| 125 |
}
|
| 139 |
}
|
| 140 |
};
|
| 141 |
|
| 142 |
+
var supportsClassList = !!document.body.classList;
|
| 143 |
+
|
| 144 |
+
var addClass = function addClass(element, className) {
|
| 145 |
+
if (supportsClassList) {
|
| 146 |
+
element.classList.add(className);
|
| 147 |
+
return;
|
| 148 |
+
}
|
| 149 |
+
element.className += (element.className ? " " : "") + className;
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
var removeClass = function removeClass(element, className) {
|
| 153 |
+
if (supportsClassList) {
|
| 154 |
+
element.classList.remove(className);
|
| 155 |
+
return;
|
| 156 |
+
}
|
| 157 |
+
element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
|
| 158 |
+
};
|
| 159 |
+
|
| 160 |
/*
|
| 161 |
* Constructor
|
| 162 |
*/
|
| 190 |
}
|
| 191 |
element.removeEventListener("load", loadCallback);
|
| 192 |
element.removeEventListener("error", errorCallback);
|
| 193 |
+
removeClass(element, settings.class_loading);
|
| 194 |
+
addClass(element, settings.class_error);
|
| 195 |
callCallback(settings.callback_error, element);
|
| 196 |
};
|
| 197 |
|
| 200 |
if (!settings) {
|
| 201 |
return;
|
| 202 |
}
|
| 203 |
+
removeClass(element, settings.class_loading);
|
| 204 |
+
addClass(element, settings.class_loaded);
|
| 205 |
element.removeEventListener("load", loadCallback);
|
| 206 |
element.removeEventListener("error", errorCallback);
|
| 207 |
/* Calling LOAD callback */
|
| 211 |
if (element.tagName === "IMG" || element.tagName === "IFRAME") {
|
| 212 |
element.addEventListener("load", loadCallback);
|
| 213 |
element.addEventListener("error", errorCallback);
|
| 214 |
+
addClass(element, settings.class_loading);
|
| 215 |
}
|
| 216 |
|
| 217 |
setSources(element, settings.data_srcset, settings.data_src);
|
| 236 |
|
| 237 |
if (isBot || isInsideViewport(element, settings.container, settings.threshold)) {
|
| 238 |
if (firstLoop) {
|
| 239 |
+
addClass(element, settings.class_initial);
|
| 240 |
}
|
| 241 |
/* Start loading the image */
|
| 242 |
this._reveal(element);
|
| 243 |
/* Marking the element as processed. */
|
| 244 |
processedIndexes.push(i);
|
| 245 |
+
setData(element, "was-processed", true);
|
| 246 |
}
|
| 247 |
}
|
| 248 |
/* Removing processed elements from this._elements. */
|
| 270 |
for (i = 0; i < elementsLength; i++) {
|
| 271 |
var element = elements[i];
|
| 272 |
/* If the element has already been processed, skip it */
|
| 273 |
+
if (getData(element, "was-processed")) {
|
| 274 |
elementsToPurge.push(i);
|
| 275 |
}
|
| 276 |
}
|
| 351 |
}
|
| 352 |
|
| 353 |
return LazyLoad;
|
| 354 |
+
});
|
assets/js/lazyload-8.2.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null},t=!("onscroll"in window)||/glebot/.test(navigator.userAgent),n=function(e,t){e&&e(t)},o=function(e){return e.getBoundingClientRect().top+window.pageYOffset-e.ownerDocument.documentElement.clientTop},i=function(e,t,n){return(t===window?window.innerHeight+window.pageYOffset:o(t)+t.offsetHeight)<=o(e)-n},s=function(e){return e.getBoundingClientRect().left+window.pageXOffset-e.ownerDocument.documentElement.clientLeft},r=function(e,t,n){var o=window.innerWidth;return(t===window?o+window.pageXOffset:s(t)+o)<=s(e)-n},l=function(e,t,n){return(t===window?window.pageYOffset:o(t))>=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n=new e(t),o=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(o)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentElement;if("PICTURE"===n.tagName)for(var o=0;o<n.children.length;o++){var i=n.children[o];if("SOURCE"===i.tagName){var s=d(i,t);s&&i.setAttribute("srcset",s)}}},_=function(e,t,n){var o=e.tagName,i=d(e,n);if("IMG"===o){f(e,t);var s=d(e,t);return s&&e.setAttribute("srcset",s),void(i&&e.setAttribute("src",i))}"IFRAME"!==o?i&&(e.style.backgroundImage='url("'+i+'")'):i&&e.setAttribute("src",i)},p=!!document.body.classList,m=function(e,t){p?e.classList.add(t):e.className+=(e.className?" ":"")+t},g=function(e,t){p?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},v=function(t){this._settings=_extends({},e,t),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};v.prototype={_reveal:function(e){var t=this._settings,o=function o(){t&&(e.removeEventListener("load",i),e.removeEventListener("error",o),g(e,t.class_loading),m(e,t.class_error),n(t.callback_error,e))},i=function i(){t&&(g(e,t.class_loading),m(e,t.class_loaded),e.removeEventListener("load",i),e.removeEventListener("error",o),n(t.callback_load,e))};"IMG"!==e.tagName&&"IFRAME"!==e.tagName||(e.addEventListener("load",i),e.addEventListener("error",o),m(e,t.class_loading)),_(e,t.data_srcset,t.data_src),n(t.callback_set,e)},_loopThroughElements:function(){var e=this._settings,o=this._elements,i=o?o.length:0,s=void 0,r=[],l=this._isFirstLoop;for(s=0;s<i;s++){var a=o[s];e.skip_invisible&&null===a.offsetParent||(t||c(a,e.container,e.threshold))&&(l&&m(a,e.class_initial),this._reveal(a),r.push(s),h(a,"was-processed",!0))}for(;r.length;)o.splice(r.pop(),1),n(e.callback_processed,o.length);0===i&&this._stopScrollHandler(),l&&(this._isFirstLoop=!1)},_purgeElements:function(){var e=this._elements,t=e.length,n=void 0,o=[];for(n=0;n<t;n++){var i=e[n];d(i,"was-processed")&&o.push(n)}for(;o.length>0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o<n;o++)u(e,t[o]);else u(e,t)}(v,w),v});
|
readme.txt
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
Contributors: creativejuiz, tabrisrp, wp_media
|
| 3 |
Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
|
| 4 |
Requires at least: 3.0
|
| 5 |
-
Tested up to: 4.8
|
| 6 |
-
Stable tag: 1.4.
|
| 7 |
|
| 8 |
The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
|
| 9 |
|
|
@@ -51,6 +51,9 @@ Some plugins are not compatible without lazy loading. Please open a support thre
|
|
| 51 |
|
| 52 |
== Changelog ==
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
= 1.4.1 =
|
| 55 |
* Fix bug caused by a too aggressive cleanup
|
| 56 |
|
| 2 |
Contributors: creativejuiz, tabrisrp, wp_media
|
| 3 |
Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
|
| 4 |
Requires at least: 3.0
|
| 5 |
+
Tested up to: 4.8
|
| 6 |
+
Stable tag: 1.4.2
|
| 7 |
|
| 8 |
The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
|
| 9 |
|
| 51 |
|
| 52 |
== Changelog ==
|
| 53 |
|
| 54 |
+
= 1.4.2 =
|
| 55 |
+
* Update lazyload script to bring back compatibility with IE9/10
|
| 56 |
+
|
| 57 |
= 1.4.1 =
|
| 58 |
* Fix bug caused by a too aggressive cleanup
|
| 59 |
|
rocket-lazy-load.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: Lazy Load by WP Rocket
|
| 4 |
* Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
|
| 5 |
* Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
|
| 6 |
-
* Version: 1.4.
|
| 7 |
* Requires PHP: 5.4
|
| 8 |
* Author: WP Media
|
| 9 |
* Author URI: https://wp-rocket.me
|
|
@@ -34,12 +34,12 @@ use PHPHtmlParser\Dom\Tag;
|
|
| 34 |
|
| 35 |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
|
| 36 |
|
| 37 |
-
define( 'ROCKET_LL_VERSION', '1.4.
|
| 38 |
define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
|
| 39 |
define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
|
| 40 |
define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
|
| 41 |
define( 'ROCKET_LL_FRONT_JS_URL', ROCKET_LL_ASSETS_URL . 'js/' );
|
| 42 |
-
define( 'ROCKET_LL_JS_VERSION' , '8.
|
| 43 |
|
| 44 |
|
| 45 |
/**
|
|
@@ -117,8 +117,8 @@ function rocket_lazyload_script() {
|
|
| 117 |
echo <<<HTML
|
| 118 |
<script>window.lazyLoadOptions = {
|
| 119 |
elements_selector: "img, iframe",
|
| 120 |
-
data_src: "
|
| 121 |
-
data_srcset: "
|
| 122 |
class_loading: "lazyloading",
|
| 123 |
class_loaded: "lazyloaded",
|
| 124 |
threshold: $threshold,
|
| 3 |
* Plugin Name: Lazy Load by WP Rocket
|
| 4 |
* Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
|
| 5 |
* Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
|
| 6 |
+
* Version: 1.4.2
|
| 7 |
* Requires PHP: 5.4
|
| 8 |
* Author: WP Media
|
| 9 |
* Author URI: https://wp-rocket.me
|
| 34 |
|
| 35 |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
|
| 36 |
|
| 37 |
+
define( 'ROCKET_LL_VERSION', '1.4.2' );
|
| 38 |
define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
|
| 39 |
define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
|
| 40 |
define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
|
| 41 |
define( 'ROCKET_LL_FRONT_JS_URL', ROCKET_LL_ASSETS_URL . 'js/' );
|
| 42 |
+
define( 'ROCKET_LL_JS_VERSION' , '8.2' );
|
| 43 |
|
| 44 |
|
| 45 |
/**
|
| 117 |
echo <<<HTML
|
| 118 |
<script>window.lazyLoadOptions = {
|
| 119 |
elements_selector: "img, iframe",
|
| 120 |
+
data_src: "lazy-src",
|
| 121 |
+
data_srcset: "lazy-srcset",
|
| 122 |
class_loading: "lazyloading",
|
| 123 |
class_loaded: "lazyloaded",
|
| 124 |
threshold: $threshold,
|
