|
1 | 1 | /*!
|
2 |
| - * jQuery & Zepto Lazy - v1.7.2 |
| 2 | + * jQuery & Zepto Lazy - v1.7.3 |
3 | 3 | * http://jquery.eisbehr.de/lazy/
|
4 | 4 | *
|
5 | 5 | * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern
|
|
250 | 250 | tag = _getElementTagName(this);
|
251 | 251 |
|
252 | 252 | return !element.data(config.handledName) &&
|
253 |
| - (element.attr(config.attribute) || element.attr(srcsetAttribute) || element.attr(loaderAttribute) || forcedTags[tag] != undefined); |
| 253 | + (element.attr(config.attribute) || element.attr(srcsetAttribute) || element.attr(loaderAttribute) || forcedTags[tag] !== undefined); |
254 | 254 | })
|
255 | 255 |
|
256 | 256 | // append plugin instance to all elements
|
|
266 | 266 | element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));
|
267 | 267 |
|
268 | 268 | // add loader to forced element types
|
269 |
| - if( forcedTags[tag] != undefined && !element.attr(loaderAttribute) ) |
| 269 | + if( forcedTags[tag] !== undefined && !element.attr(loaderAttribute) ) |
270 | 270 | element.attr(loaderAttribute, forcedTags[tag]);
|
271 | 271 |
|
272 | 272 | // set default image on every element without source
|
|
302 | 302 | handledName = config.handledName;
|
303 | 303 |
|
304 | 304 | // loop all available items
|
305 |
| - for( var i = 0, l = items.length; i < l; i++ ) |
306 |
| - (function(item) { |
307 |
| - // item is at least in loadable area |
308 |
| - if( allItems || _isInLoadableArea(item) ) { |
309 |
| - var element = $(item), |
310 |
| - tag = _getElementTagName(item), |
311 |
| - attribute = element.attr(config.attribute), |
312 |
| - elementImageBase = element.attr(config.imageBaseAttribute) || imageBase, |
313 |
| - customLoader = element.attr(config.loaderAttribute); |
314 |
| - |
315 |
| - // is not already handled |
316 |
| - if( !element.data(handledName) && |
317 |
| - // and is visible or visibility doesn't matter |
318 |
| - (!config.visibleOnly || element.is(":visible")) && ( |
319 |
| - // and image source or source set attribute is available |
320 |
| - (attribute || element.attr(srcsetAttribute)) && ( |
321 |
| - // and is image tag where attribute is not equal source or source set |
322 |
| - (tag == _img && (elementImageBase + attribute != element.attr(_src) || element.attr(srcsetAttribute) != element.attr(_srcset))) || |
323 |
| - // or is non image tag where attribute is not equal background |
324 |
| - (tag != _img && elementImageBase + attribute != element.css(_backgroundImage)) |
325 |
| - ) || |
326 |
| - // or custom loader is available |
327 |
| - customLoader )) |
328 |
| - { |
329 |
| - // mark element always as handled as this point to prevent double handling |
330 |
| - loadTriggered = true; |
331 |
| - element.data(handledName, true); |
332 |
| - |
333 |
| - // load item |
334 |
| - _handleItem(element, tag, elementImageBase, customLoader); |
335 |
| - } |
| 305 | + for( var i = 0; i < items.length; i++ ) { |
| 306 | + // item is at least in loadable area |
| 307 | + if( allItems || _isInLoadableArea(items[i]) ) { |
| 308 | + var element = $(items[i]), |
| 309 | + tag = _getElementTagName(items[i]), |
| 310 | + attribute = element.attr(config.attribute), |
| 311 | + elementImageBase = element.attr(config.imageBaseAttribute) || imageBase, |
| 312 | + customLoader = element.attr(config.loaderAttribute); |
| 313 | + |
| 314 | + // is not already handled |
| 315 | + if( !element.data(handledName) && |
| 316 | + // and is visible or visibility doesn't matter |
| 317 | + (!config.visibleOnly || element.is(":visible")) && ( |
| 318 | + // and image source or source set attribute is available |
| 319 | + (attribute || element.attr(srcsetAttribute)) && ( |
| 320 | + // and is image tag where attribute is not equal source or source set |
| 321 | + (tag == _img && (elementImageBase + attribute != element.attr(_src) || element.attr(srcsetAttribute) != element.attr(_srcset))) || |
| 322 | + // or is non image tag where attribute is not equal background |
| 323 | + (tag != _img && elementImageBase + attribute != element.css(_backgroundImage)) |
| 324 | + ) || |
| 325 | + // or custom loader is available |
| 326 | + customLoader )) |
| 327 | + { |
| 328 | + // mark element always as handled as this point to prevent double handling |
| 329 | + loadTriggered = true; |
| 330 | + element.data(handledName, true); |
| 331 | + |
| 332 | + // load item |
| 333 | + _handleItem(element, tag, elementImageBase, customLoader); |
336 | 334 | }
|
337 |
| - })(items[i]); |
| 335 | + } |
| 336 | + } |
338 | 337 |
|
339 | 338 | // when something was loaded remove them from remaining items
|
340 | 339 | if( loadTriggered )
|
|
473 | 472 | .attr(_src, imageSrc ? imageBase + imageSrc : null);
|
474 | 473 |
|
475 | 474 | // call after load even on cached image
|
476 |
| - imageObj.complete && imageObj.load(); |
| 475 | + imageObj.complete && imageObj.load(); // jshint ignore : line |
477 | 476 | }
|
478 | 477 | }
|
479 | 478 |
|
|
569 | 568 | callback.call(instance, event);
|
570 | 569 | }
|
571 | 570 |
|
572 |
| - timeout && clearTimeout(timeout); |
| 571 | + timeout && clearTimeout(timeout); // jshint ignore : line |
573 | 572 |
|
574 | 573 | if( elapsed > delay || !config.enableThrottle || ignoreThrottle ) run();
|
575 | 574 | else timeout = setTimeout(run, delay - elapsed);
|
|
652 | 651 | * @access private
|
653 | 652 | * @type {string}
|
654 | 653 | */
|
655 |
| - _namespace = _config.name + "-" + ++lazyInstanceId; |
| 654 | + _namespace = _config.name + "-" + (++lazyInstanceId); |
656 | 655 |
|
657 | 656 | // noinspection JSUndefinedPropertyAssignment
|
658 | 657 | /**
|
|
680 | 679 | * @return {LazyPlugin}
|
681 | 680 | */
|
682 | 681 | _instance.addItems = function(items) {
|
683 |
| - _events.a && _events.a($.type(items) === "string" ? $(items) : items); |
| 682 | + _events.a && _events.a($.type(items) === "string" ? $(items) : items); // jshint ignore : line |
684 | 683 | return _instance;
|
685 | 684 | };
|
686 | 685 |
|
|
704 | 703 | * @return {LazyPlugin}
|
705 | 704 | */
|
706 | 705 | _instance.update = function(useThrottle) {
|
707 |
| - _events.e && _events.e({}, !useThrottle); |
| 706 | + _events.e && _events.e({}, !useThrottle); // jshint ignore : line |
708 | 707 | return _instance;
|
709 | 708 | };
|
710 | 709 |
|
|
717 | 716 | * @return {LazyPlugin}
|
718 | 717 | */
|
719 | 718 | _instance.loadAll = function() {
|
720 |
| - _events.e && _events.e({all: true}, true); |
| 719 | + _events.e && _events.e({all: true}, true); // jshint ignore : line |
721 | 720 | return _instance;
|
722 | 721 | };
|
723 | 722 |
|
|
0 commit comments