From f77f8eaef3bb67c035e1e6c0981e6a32e48c2089 Mon Sep 17 00:00:00 2001 From: Eisbehr Date: Wed, 26 Apr 2017 13:52:59 +0200 Subject: [PATCH] 1.7.5 - strict checks for all comparisons - fixed bug with 'filter' for Zepto on 'force' function - fixed examples in picture plugin file - added 'jshint' for dependencies - fixed version for bower - fixed version in plugins file - updated year in all files --- README.md | 8 ++--- bower.json | 2 +- jquery.lazy.js | 29 ++++++++------- jquery.lazy.min.js | 4 +-- jquery.lazy.plugins.js | 58 +++++++++++++++--------------- jquery.lazy.plugins.min.js | 4 +-- package.json | 5 +-- plugins/jquery.lazy.ajax.js | 2 +- plugins/jquery.lazy.ajax.min.js | 2 +- plugins/jquery.lazy.av.js | 12 +++---- plugins/jquery.lazy.av.min.js | 4 +-- plugins/jquery.lazy.iframe.js | 12 +++---- plugins/jquery.lazy.iframe.min.js | 4 +-- plugins/jquery.lazy.noop.js | 2 +- plugins/jquery.lazy.noop.min.js | 2 +- plugins/jquery.lazy.picture.js | 16 ++++----- plugins/jquery.lazy.picture.min.js | 4 +-- plugins/jquery.lazy.script.js | 2 +- plugins/jquery.lazy.script.min.js | 2 +- plugins/jquery.lazy.vimeo.js | 6 ++-- plugins/jquery.lazy.vimeo.min.js | 4 +-- plugins/jquery.lazy.youtube.js | 6 ++-- plugins/jquery.lazy.youtube.min.js | 4 +-- 23 files changed, 100 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 09188e3..e1ce008 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,12 @@ Some examples below: Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page. ```HTML - - + + - - + + ``` #### Self-Hosted diff --git a/bower.json b/bower.json index 5253e4b..50bba14 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "jquery-lazy", "description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery and Zepto. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view. You can use Lazy in all vertical and horizontal scroll ways. It supports images in 'img' tags and backgrounds, supplied with css like 'background-image', by default. On those elements Lazy can set an default image or a placeholder while loading and supports retina displays as well. But Lazy is even able to load any other content you want by plugins and custom loaders.", - "version": "1.7.3", + "version": "1.7.5", "main": "jquery.lazy.min.js", "license": [ "MIT", diff --git a/jquery.lazy.js b/jquery.lazy.js index 73a95e8..fd6fd36 100644 --- a/jquery.lazy.js +++ b/jquery.lazy.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - v1.7.4 + * jQuery & Zepto Lazy - v1.7.5 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -224,7 +224,12 @@ events.f = function(forcedItems) { for( var i = 0; i < forcedItems.length; i++ ) { // only handle item if available in current instance - var item = items.filter(forcedItems[i]); + // use a compare function, because Zepto can't handle object parameter for filter + // var item = items.filter(forcedItems[i]); + /* jshint loopfunc: true */ + var item = items.filter(function() { + return this === forcedItems[i]; + }); if( item.length ) { _lazyLoadItems(false, item); @@ -274,7 +279,7 @@ elementImageBase = element.attr(config.imageBaseAttribute) || imageBase; // generate and update source set if an image base is set - if( tag == _img && elementImageBase && element.attr(srcsetAttribute) ) + if( tag === _img && elementImageBase && element.attr(srcsetAttribute) ) element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase)); // add loader to forced element types @@ -282,11 +287,11 @@ element.attr(loaderAttribute, forcedTags[tag]); // set default image on every element without source - if( tag == _img && defaultImage && !element.attr(_src) ) + if( tag === _img && defaultImage && !element.attr(_src) ) element.attr(_src, defaultImage); // set placeholder on every element without background image - else if( tag != _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) == "none") ) + else if( tag !== _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) === "none") ) element.css(_backgroundImage, "url('" + placeholder + "')"); } } @@ -332,9 +337,9 @@ // and image source or source set attribute is available (attribute || element.attr(srcsetAttribute)) && ( // and is image tag where attribute is not equal source or source set - (tag == _img && (elementImageBase + attribute != element.attr(_src) || element.attr(srcsetAttribute) != element.attr(_srcset))) || + (tag === _img && (elementImageBase + attribute !== element.attr(_src) || element.attr(srcsetAttribute) !== element.attr(_srcset))) || // or is non image tag where attribute is not equal background - (tag != _img && elementImageBase + attribute != element.css(_backgroundImage)) + (tag !== _img && elementImageBase + attribute !== element.css(_backgroundImage)) ) || // or custom loader is available customLoader )) @@ -446,7 +451,7 @@ // set image back to element // do it as single 'attr' calls, to be sure 'src' is set after 'srcset' - if( tag == _img ) + if( tag === _img ) element.attr(_sizes, imageObj.attr(_sizes)) .attr(_srcset, imageObj.attr(_srcset)) .attr(_src, imageObj.attr(_src)); @@ -509,8 +514,8 @@ // check if element is even in loadable area from right (-threshold < elementBound.right); - if( direction == "vertical" ) return vertical; - else if( direction == "horizontal" ) return horizontal; + if( direction === "vertical" ) return vertical; + else if( direction === "horizontal" ) return horizontal; return vertical && horizontal; } @@ -621,7 +626,7 @@ } // if event driven or window is already loaded don't wait for page loading - if( config.bind == "event" || windowLoaded ) + if( config.bind === "event" || windowLoaded ) _initialize(); // otherwise load initial items and start lazy after page load diff --git a/jquery.lazy.min.js b/jquery.lazy.min.js index 60d4776..59aab4d 100644 --- a/jquery.lazy.min.js +++ b/jquery.lazy.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy v1.7.4 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t,e){"use strict";function r(r,a,i,l,u){function f(){L=t.devicePixelRatio>1,c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(l.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),l.a=function(t){c(t),i.push.apply(i,t)},l.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},l.f=function(t){for(var e=0;ee.top&&-ne.left&&-n=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;at||!a.enableThrottle||l?u():n=setTimeout(u,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"==a.bind||o?f():n(t).on(D+"."+u,f)}function a(a,o){var l=this,u=n.extend({},l.config,o),f={},c=u.name+"-"+ ++i;return l.config=function(t,r){return r===e?u[t]:(u[t]=r,l)},l.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),l},l.getItems=function(){return f.g?f.g():{}},l.update=function(t){return f.e&&f.e({},!t),l},l.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),l},l.loadAll=function(){return f.e&&f.e({all:!0},!0),l},l.destroy=function(){return n(u.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(l,u,a,f,c),u.chainable?a:l}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,l=o._f||(o._f={}),u=0,f=t.length;u1,c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(l.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),l.a=function(t){c(t),i.push.apply(i,t)},l.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},l.f=function(t){for(var e=0;ee.top&&-ne.left&&-n=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;at||!a.enableThrottle||l?u():n=setTimeout(u,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"===a.bind||o?f():n(t).on(D+"."+u,f)}function a(a,o){var l=this,u=n.extend({},l.config,o),f={},c=u.name+"-"+ ++i;return l.config=function(t,r){return r===e?u[t]:(u[t]=r,l)},l.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),l},l.getItems=function(){return f.g?f.g():{}},l.update=function(t){return f.e&&f.e({},!t),l},l.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),l},l.loadAll=function(){return f.e&&f.e({all:!0},!0),l},l.destroy=function(){return n(u.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(l,u,a,f,c),u.chainable?a:l}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,l=o._f||(o._f={}),u=0,f=t.length;u" : ""); + target = $(type === srcAttr ? "" : ""); - if( type == srcAttr ) + if( type === srcAttr ) target.one("error", onError); $.each(attributes, function(index, attribute) { @@ -189,10 +189,10 @@ })(window.jQuery || window.Zepto); /*! - * jQuery & Zepto Lazy - iFrame Plugin - v1.4 + * jQuery & Zepto Lazy - iFrame Plugin - v1.5 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -205,15 +205,15 @@ // enable content error check with: // $.lazy(["frame", "iframe"], "iframe", function(element, response) { - var instance = this; + var instance = this; - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { var srcAttr = "data-src", - errorDetectAttr = "data-error-detect", + errorDetectAttr = "data-error-detect", errorDetect = element.attr(errorDetectAttr); // default way, just replace the 'src' attribute - if( errorDetect != "true" && errorDetect != "1" ) { + if( errorDetect !== "true" && errorDetect !== "1" ) { // set iframe source element.attr("src", element.attr(srcAttr)); @@ -274,7 +274,7 @@ * jQuery & Zepto Lazy - NOOP Plugin - v1.2 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -302,10 +302,10 @@ })(window.jQuery || window.Zepto); /*! - * jQuery & Zepto Lazy - Picture Plugin - v1.0 + * jQuery & Zepto Lazy - Picture Plugin - v1.1 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -314,15 +314,15 @@ ;(function($) { // loads picture elements like: // - // - // + // + // // // // // or: // - // - // + // + // // // // or just with attributes in one line: @@ -330,7 +330,7 @@ $.lazy(["pic", "picture"], ["picture"], function(element, response) { var elementTagName = element[0].tagName.toLowerCase(); - if( elementTagName == "picture" ) { + if( elementTagName === "picture" ) { var srcAttr = "data-src", srcsetAttr = "data-srcset", mediaAttr = "data-media", @@ -346,7 +346,7 @@ }); // create img tag from child - if( image.length == 1 ) { + if( image.length === 1 ) { image = renameElementTag(image, "img"); // bind event callbacks to new image tag @@ -463,7 +463,7 @@ * jQuery & Zepto Lazy - Script Plugin - v1.2 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -488,10 +488,10 @@ })(window.jQuery || window.Zepto); /*! - * jQuery & Zepto Lazy - Vimeo Plugin - v1.0 + * jQuery & Zepto Lazy - Vimeo Plugin - v1.1 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -501,7 +501,7 @@ // load vimeo video iframe, like: // $.lazy("vimeo", function(element, response) { - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { // pass source to iframe element.attr("src", "https://player.vimeo.com/video/" + element.attr("data-src")); @@ -519,10 +519,10 @@ })(window.jQuery || window.Zepto); /*! - * jQuery & Zepto Lazy - YouTube Plugin - v1.3 + * jQuery & Zepto Lazy - YouTube Plugin - v1.4 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -532,7 +532,7 @@ // load youtube video iframe, like: // $.lazy(["yt", "youtube"], function(element, response) { - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { // pass source to iframe element.attr("src", "https://www.youtube.com/embed/" + element.attr("data-src") + "?rel=0&showinfo=0"); diff --git a/jquery.lazy.plugins.min.js b/jquery.lazy.plugins.min.js index 1b6885c..0da5049 100644 --- a/jquery.lazy.plugins.min.js +++ b/jquery.lazy.plugins.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - All Plugins v1.7.3 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){function e(e,r,a,o){t.ajax({url:r.attr("data-src"),type:o||"get",dataType:r.attr("data-type")||"html",success:function(t){r.html(t),a(!0),e.config("removeAttribute")&&r.removeAttr("data-src data-method data-type")},error:function(){a(!1)}})}t.lazy("ajax",function(t,r){e(this,t,r,t.attr("data-method"))}),t.lazy("get",function(t,r){e(this,t,r,"get")}),t.lazy("post",function(t,r){e(this,t,r,"post")})}(window.jQuery||window.Zepto),function(t){t.lazy(["av","audio","video"],["audio","video"],function(e,r){var a=e[0].tagName.toLowerCase();if("audio"==a||"video"==a){var o="data-src",i=e.find(o),n=e.find("data-track"),c=0,s=function(){++c==i.length&&r(!1)},u=function(){var e=t(this),r=e[0].tagName.toLowerCase(),a=e.prop("attributes"),i=t(r==o?"":"");r==o&&i.one("error",s),t.each(a,function(t,e){i.attr(e.name,e.value)}),e.replaceWith(i)};e.one("loadedmetadata",function(){r(!0)}).off("load error").attr("poster",e.attr("data-poster")),i.length?i.each(u):e.attr(o)?(t.each(e.attr(o).split(","),function(r,a){var o=a.split("|");e.append(t("").one("error",s).attr({src:o[0].trim(),type:o[1].trim()}))}),this.config("removeAttribute")&&e.removeAttr(o)):r(!1),n.length&&n.each(u)}else r(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["frame","iframe"],"iframe",function(e,r){var a=this;if("iframe"==e[0].tagName.toLowerCase()){var o="data-src",i="data-error-detect",n=e.attr(i);"true"!=n&&"1"!=n?(e.attr("src",e.attr(o)),a.config("removeAttribute")&&e.removeAttr(o+" "+i)):t.ajax({url:e.attr(o),dataType:"html",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(t){e.html(t).attr("src",e.attr(o)),a.config("removeAttribute")&&e.removeAttr(o+" "+i)},error:function(){r(!1)}})}else r(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy("noop",function(){}),t.lazy("noop-success",function(t,e){e(!0)}),t.lazy("noop-error",function(t,e){e(!1)})}(window.jQuery||window.Zepto),function(t){function e(e,r){var a=e.prop("attributes"),o=t("<"+r+">");return t.each(a,function(t,e){o.attr(e.name,e.value)}),e.replaceWith(o),o}function r(e,r,a){var o=t("").one("load",function(){a(!0)}).one("error",function(){a(!1)}).appendTo(e).attr("src",r);o.complete&&o.load()}t.lazy(["pic","picture"],["picture"],function(a,o){var i=a[0].tagName.toLowerCase();if("picture"==i){var n="data-src",c="data-srcset",s="data-media",u="data-sizes",d="data-type",f=a.find(n),m=a.find("data-img");f.length?(f.each(function(){e(t(this),"source")}),1==m.length?(m=e(m,"img"),m.on("load",function(){o(!0)}).on("error",function(){o(!1)}),m.attr("src",m.attr(n)),this.config("removeAttribute")&&m.removeAttr(n)):a.attr(n)?(r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n)):o(!1)):a.attr(c)?(t("").attr({media:a.attr(s),sizes:a.attr(u),type:a.attr(d),srcset:a.attr(c)}).appendTo(a),r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n+" "+c+" "+s+" "+u+" "+d)):o(!1)}else o(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["js","javascript","script"],"script",function(t,e){"script"==t[0].tagName.toLowerCase()?(t.attr("src",t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy("vimeo",function(t,e){"iframe"==t[0].tagName.toLowerCase()?(t.attr("src","https://player.vimeo.com/video/"+t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["yt","youtube"],function(t,e){"iframe"==t[0].tagName.toLowerCase()?(t.attr("src","https://www.youtube.com/embed/"+t.attr("data-src")+"?rel=0&showinfo=0"),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - All Plugins v1.7.5 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){function e(e,r,a,o){t.ajax({url:r.attr("data-src"),type:o||"get",dataType:r.attr("data-type")||"html",success:function(t){r.html(t),a(!0),e.config("removeAttribute")&&r.removeAttr("data-src data-method data-type")},error:function(){a(!1)}})}t.lazy("ajax",function(t,r){e(this,t,r,t.attr("data-method"))}),t.lazy("get",function(t,r){e(this,t,r,"get")}),t.lazy("post",function(t,r){e(this,t,r,"post")})}(window.jQuery||window.Zepto),function(t){t.lazy(["av","audio","video"],["audio","video"],function(e,r){var a=e[0].tagName.toLowerCase();if("audio"===a||"video"===a){var o="data-src",i=e.find(o),n=e.find("data-track"),c=0,s=function(){++c===i.length&&r(!1)},u=function(){var e=t(this),r=e[0].tagName.toLowerCase(),a=e.prop("attributes"),i=t(r===o?"":"");r===o&&i.one("error",s),t.each(a,function(t,e){i.attr(e.name,e.value)}),e.replaceWith(i)};e.one("loadedmetadata",function(){r(!0)}).off("load error").attr("poster",e.attr("data-poster")),i.length?i.each(u):e.attr(o)?(t.each(e.attr(o).split(","),function(r,a){var o=a.split("|");e.append(t("").one("error",s).attr({src:o[0].trim(),type:o[1].trim()}))}),this.config("removeAttribute")&&e.removeAttr(o)):r(!1),n.length&&n.each(u)}else r(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["frame","iframe"],"iframe",function(e,r){var a=this;if("iframe"===e[0].tagName.toLowerCase()){var o="data-src",i="data-error-detect",n=e.attr(i);"true"!==n&&"1"!==n?(e.attr("src",e.attr(o)),a.config("removeAttribute")&&e.removeAttr(o+" "+i)):t.ajax({url:e.attr(o),dataType:"html",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(t){e.html(t).attr("src",e.attr(o)),a.config("removeAttribute")&&e.removeAttr(o+" "+i)},error:function(){r(!1)}})}else r(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy("noop",function(){}),t.lazy("noop-success",function(t,e){e(!0)}),t.lazy("noop-error",function(t,e){e(!1)})}(window.jQuery||window.Zepto),function(t){function e(e,r){var a=e.prop("attributes"),o=t("<"+r+">");return t.each(a,function(t,e){o.attr(e.name,e.value)}),e.replaceWith(o),o}function r(e,r,a){var o=t("").one("load",function(){a(!0)}).one("error",function(){a(!1)}).appendTo(e).attr("src",r);o.complete&&o.load()}t.lazy(["pic","picture"],["picture"],function(a,o){var i=a[0].tagName.toLowerCase();if("picture"===i){var n="data-src",c="data-srcset",s="data-media",u="data-sizes",d="data-type",f=a.find(n),m=a.find("data-img");f.length?(f.each(function(){e(t(this),"source")}),1===m.length?(m=e(m,"img"),m.on("load",function(){o(!0)}).on("error",function(){o(!1)}),m.attr("src",m.attr(n)),this.config("removeAttribute")&&m.removeAttr(n)):a.attr(n)?(r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n)):o(!1)):a.attr(c)?(t("").attr({media:a.attr(s),sizes:a.attr(u),type:a.attr(d),srcset:a.attr(c)}).appendTo(a),r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n+" "+c+" "+s+" "+u+" "+d)):o(!1)}else o(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["js","javascript","script"],"script",function(t,e){"script"==t[0].tagName.toLowerCase()?(t.attr("src",t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy("vimeo",function(t,e){"iframe"===t[0].tagName.toLowerCase()?(t.attr("src","https://player.vimeo.com/video/"+t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto),function(t){t.lazy(["yt","youtube"],function(t,e){"iframe"===t[0].tagName.toLowerCase()?(t.attr("src","https://www.youtube.com/embed/"+t.attr("data-src")+"?rel=0&showinfo=0"),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/package.json b/package.json index 171d99d..1384571 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jquery-lazy", "title": "jQuery & Zepto Lazy - Delayed Content, Image and Background Loader", - "version": "1.7.4", + "version": "1.7.5", "description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery and Zepto. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view.", "main": "jquery.lazy.js", "homepage": "http://jquery.eisbehr.de/lazy", @@ -51,11 +51,12 @@ "gulp-concat-util": "^0.5.5", "gulp-data": "^1.2.1", "gulp-header": "^1.8.8", - "gulp-jshint": "^2.0.1", + "gulp-jshint": "^2.0.4", "gulp-noop": "^1.0.0", "gulp-rename": "^1.2.2", "gulp-uglify": "^1.5.4", "gulp-util": "^3.0.7", + "jshint": "^2.9.4", "jshint-stylish": "^2.2.0" }, "scripts": { diff --git a/plugins/jquery.lazy.ajax.js b/plugins/jquery.lazy.ajax.js index 83a95ab..519c454 100644 --- a/plugins/jquery.lazy.ajax.js +++ b/plugins/jquery.lazy.ajax.js @@ -2,7 +2,7 @@ * jQuery & Zepto Lazy - AJAX Plugin - v1.2 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php diff --git a/plugins/jquery.lazy.ajax.min.js b/plugins/jquery.lazy.ajax.min.js index 6afef4d..720f4ee 100644 --- a/plugins/jquery.lazy.ajax.min.js +++ b/plugins/jquery.lazy.ajax.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - AJAX Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ +/*! jQuery & Zepto Lazy - AJAX Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ !function(t){function a(a,e,o,n){t.ajax({url:e.attr("data-src"),type:n||"get",dataType:e.attr("data-type")||"html",success:function(t){e.html(t),o(!0),a.config("removeAttribute")&&e.removeAttr("data-src data-method data-type")},error:function(){o(!1)}})}t.lazy("ajax",function(t,e){a(this,t,e,t.attr("data-method"))}),t.lazy("get",function(t,e){a(this,t,e,"get")}),t.lazy("post",function(t,e){a(this,t,e,"post")})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.av.js b/plugins/jquery.lazy.av.js index 55f9440..1229103 100644 --- a/plugins/jquery.lazy.av.js +++ b/plugins/jquery.lazy.av.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - AV Plugin - v1.3 + * jQuery & Zepto Lazy - AV Plugin - v1.4 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -33,7 +33,7 @@ $.lazy(["av", "audio", "video"], ["audio", "video"], function(element, response) { var elementTagName = element[0].tagName.toLowerCase(); - if( elementTagName == "audio" || elementTagName == "video" ) { + if( elementTagName === "audio" || elementTagName === "video" ) { var srcAttr = "data-src", sources = element.find(srcAttr), tracks = element.find("data-track"), @@ -41,7 +41,7 @@ // create on error callback for sources onError = function() { - if( ++sourcesInError == sources.length ) + if( ++sourcesInError === sources.length ) response(false); }, @@ -50,9 +50,9 @@ var source = $(this), type = source[0].tagName.toLowerCase(), attributes = source.prop("attributes"), - target = $(type == srcAttr ? "" : ""); + target = $(type === srcAttr ? "" : ""); - if( type == srcAttr ) + if( type === srcAttr ) target.one("error", onError); $.each(attributes, function(index, attribute) { diff --git a/plugins/jquery.lazy.av.min.js b/plugins/jquery.lazy.av.min.js index e28f6a5..99a33f5 100644 --- a/plugins/jquery.lazy.av.min.js +++ b/plugins/jquery.lazy.av.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - AV Plugin v1.3 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){t.lazy(["av","audio","video"],["audio","video"],function(e,a){var r=e[0].tagName.toLowerCase();if("audio"==r||"video"==r){var o="data-src",i=e.find(o),n=e.find("data-track"),c=0,d=function(){++c==i.length&&a(!1)},u=function(){var e=t(this),a=e[0].tagName.toLowerCase(),r=e.prop("attributes"),i=t(a==o?"":"");a==o&&i.one("error",d),t.each(r,function(t,e){i.attr(e.name,e.value)}),e.replaceWith(i)};e.one("loadedmetadata",function(){a(!0)}).off("load error").attr("poster",e.attr("data-poster")),i.length?i.each(u):e.attr(o)?(t.each(e.attr(o).split(","),function(a,r){var o=r.split("|");e.append(t("").one("error",d).attr({src:o[0].trim(),type:o[1].trim()}))}),this.config("removeAttribute")&&e.removeAttr(o)):a(!1),n.length&&n.each(u)}else a(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - AV Plugin v1.4 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){t.lazy(["av","audio","video"],["audio","video"],function(e,a){var r=e[0].tagName.toLowerCase();if("audio"===r||"video"===r){var o="data-src",i=e.find(o),n=e.find("data-track"),c=0,d=function(){++c===i.length&&a(!1)},u=function(){var e=t(this),a=e[0].tagName.toLowerCase(),r=e.prop("attributes"),i=t(a===o?"":"");a===o&&i.one("error",d),t.each(r,function(t,e){i.attr(e.name,e.value)}),e.replaceWith(i)};e.one("loadedmetadata",function(){a(!0)}).off("load error").attr("poster",e.attr("data-poster")),i.length?i.each(u):e.attr(o)?(t.each(e.attr(o).split(","),function(a,r){var o=r.split("|");e.append(t("").one("error",d).attr({src:o[0].trim(),type:o[1].trim()}))}),this.config("removeAttribute")&&e.removeAttr(o)):a(!1),n.length&&n.each(u)}else a(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.iframe.js b/plugins/jquery.lazy.iframe.js index 41bd4de..7dba729 100644 --- a/plugins/jquery.lazy.iframe.js +++ b/plugins/jquery.lazy.iframe.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - iFrame Plugin - v1.4 + * jQuery & Zepto Lazy - iFrame Plugin - v1.5 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -15,15 +15,15 @@ // enable content error check with: // $.lazy(["frame", "iframe"], "iframe", function(element, response) { - var instance = this; + var instance = this; - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { var srcAttr = "data-src", - errorDetectAttr = "data-error-detect", + errorDetectAttr = "data-error-detect", errorDetect = element.attr(errorDetectAttr); // default way, just replace the 'src' attribute - if( errorDetect != "true" && errorDetect != "1" ) { + if( errorDetect !== "true" && errorDetect !== "1" ) { // set iframe source element.attr("src", element.attr(srcAttr)); diff --git a/plugins/jquery.lazy.iframe.min.js b/plugins/jquery.lazy.iframe.min.js index 1524f0c..018cc07 100644 --- a/plugins/jquery.lazy.iframe.min.js +++ b/plugins/jquery.lazy.iframe.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - iFrame Plugin v1.4 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){t.lazy(["frame","iframe"],"iframe",function(r,e){var a=this;if("iframe"==r[0].tagName.toLowerCase()){var i="data-src",o="data-error-detect",n=r.attr(o);"true"!=n&&"1"!=n?(r.attr("src",r.attr(i)),a.config("removeAttribute")&&r.removeAttr(i+" "+o)):t.ajax({url:r.attr(i),dataType:"html",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(t){r.html(t).attr("src",r.attr(i)),a.config("removeAttribute")&&r.removeAttr(i+" "+o)},error:function(){e(!1)}})}else e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - iFrame Plugin v1.5 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){t.lazy(["frame","iframe"],"iframe",function(r,e){var a=this;if("iframe"===r[0].tagName.toLowerCase()){var i="data-src",o="data-error-detect",n=r.attr(o);"true"!==n&&"1"!==n?(r.attr("src",r.attr(i)),a.config("removeAttribute")&&r.removeAttr(i+" "+o)):t.ajax({url:r.attr(i),dataType:"html",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(t){r.html(t).attr("src",r.attr(i)),a.config("removeAttribute")&&r.removeAttr(i+" "+o)},error:function(){e(!1)}})}else e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.noop.js b/plugins/jquery.lazy.noop.js index 0c3c181..e2b02a2 100644 --- a/plugins/jquery.lazy.noop.js +++ b/plugins/jquery.lazy.noop.js @@ -2,7 +2,7 @@ * jQuery & Zepto Lazy - NOOP Plugin - v1.2 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php diff --git a/plugins/jquery.lazy.noop.min.js b/plugins/jquery.lazy.noop.min.js index 234ec37..e783aeb 100644 --- a/plugins/jquery.lazy.noop.min.js +++ b/plugins/jquery.lazy.noop.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - NOOP Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ +/*! jQuery & Zepto Lazy - NOOP Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ !function(o){o.lazy("noop",function(){}),o.lazy("noop-success",function(o,n){n(!0)}),o.lazy("noop-error",function(o,n){n(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.picture.js b/plugins/jquery.lazy.picture.js index e58114f..e4fc078 100644 --- a/plugins/jquery.lazy.picture.js +++ b/plugins/jquery.lazy.picture.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - Picture Plugin - v1.0 + * jQuery & Zepto Lazy - Picture Plugin - v1.1 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -11,15 +11,15 @@ ;(function($) { // loads picture elements like: // - // - // + // + // // // // // or: // - // - // + // + // // // // or just with attributes in one line: @@ -27,7 +27,7 @@ $.lazy(["pic", "picture"], ["picture"], function(element, response) { var elementTagName = element[0].tagName.toLowerCase(); - if( elementTagName == "picture" ) { + if( elementTagName === "picture" ) { var srcAttr = "data-src", srcsetAttr = "data-srcset", mediaAttr = "data-media", @@ -43,7 +43,7 @@ }); // create img tag from child - if( image.length == 1 ) { + if( image.length === 1 ) { image = renameElementTag(image, "img"); // bind event callbacks to new image tag diff --git a/plugins/jquery.lazy.picture.min.js b/plugins/jquery.lazy.picture.min.js index b023def..f631862 100644 --- a/plugins/jquery.lazy.picture.min.js +++ b/plugins/jquery.lazy.picture.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - Picture Plugin v1.0 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){function e(e,r){var a=e.prop("attributes"),o=t("<"+r+">");return t.each(a,function(t,e){o.attr(e.name,e.value)}),e.replaceWith(o),o}function r(e,r,a){var o=t("").one("load",function(){a(!0)}).one("error",function(){a(!1)}).appendTo(e).attr("src",r);o.complete&&o.load()}t.lazy(["pic","picture"],["picture"],function(a,o){var i=a[0].tagName.toLowerCase();if("picture"==i){var n="data-src",c="data-srcset",u="data-media",s="data-sizes",d="data-type",f=a.find(n),p=a.find("data-img");f.length?(f.each(function(){e(t(this),"source")}),1==p.length?(p=e(p,"img"),p.on("load",function(){o(!0)}).on("error",function(){o(!1)}),p.attr("src",p.attr(n)),this.config("removeAttribute")&&p.removeAttr(n)):a.attr(n)?(r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n)):o(!1)):a.attr(c)?(t("").attr({media:a.attr(u),sizes:a.attr(s),type:a.attr(d),srcset:a.attr(c)}).appendTo(a),r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n+" "+c+" "+u+" "+s+" "+d)):o(!1)}else o(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - Picture Plugin v1.1 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){function e(e,r){var a=e.prop("attributes"),o=t("<"+r+">");return t.each(a,function(t,e){o.attr(e.name,e.value)}),e.replaceWith(o),o}function r(e,r,a){var o=t("").one("load",function(){a(!0)}).one("error",function(){a(!1)}).appendTo(e).attr("src",r);o.complete&&o.load()}t.lazy(["pic","picture"],["picture"],function(a,o){var i=a[0].tagName.toLowerCase();if("picture"===i){var n="data-src",c="data-srcset",u="data-media",s="data-sizes",d="data-type",f=a.find(n),p=a.find("data-img");f.length?(f.each(function(){e(t(this),"source")}),1===p.length?(p=e(p,"img"),p.on("load",function(){o(!0)}).on("error",function(){o(!1)}),p.attr("src",p.attr(n)),this.config("removeAttribute")&&p.removeAttr(n)):a.attr(n)?(r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n)):o(!1)):a.attr(c)?(t("").attr({media:a.attr(u),sizes:a.attr(s),type:a.attr(d),srcset:a.attr(c)}).appendTo(a),r(a,a.attr(n),o),this.config("removeAttribute")&&a.removeAttr(n+" "+c+" "+u+" "+s+" "+d)):o(!1)}else o(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.script.js b/plugins/jquery.lazy.script.js index 22fea19..9d6c23b 100644 --- a/plugins/jquery.lazy.script.js +++ b/plugins/jquery.lazy.script.js @@ -2,7 +2,7 @@ * jQuery & Zepto Lazy - Script Plugin - v1.2 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php diff --git a/plugins/jquery.lazy.script.min.js b/plugins/jquery.lazy.script.min.js index 06bd633..c840456 100644 --- a/plugins/jquery.lazy.script.min.js +++ b/plugins/jquery.lazy.script.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - Script Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ +/*! jQuery & Zepto Lazy - Script Plugin v1.2 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ !function(t){t.lazy(["js","javascript","script"],"script",function(t,r){"script"==t[0].tagName.toLowerCase()?(t.attr("src",t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):r(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.vimeo.js b/plugins/jquery.lazy.vimeo.js index c6463dc..d6efbd1 100644 --- a/plugins/jquery.lazy.vimeo.js +++ b/plugins/jquery.lazy.vimeo.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - Vimeo Plugin - v1.0 + * jQuery & Zepto Lazy - Vimeo Plugin - v1.1 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -12,7 +12,7 @@ // load vimeo video iframe, like: // $.lazy("vimeo", function(element, response) { - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { // pass source to iframe element.attr("src", "https://player.vimeo.com/video/" + element.attr("data-src")); diff --git a/plugins/jquery.lazy.vimeo.min.js b/plugins/jquery.lazy.vimeo.min.js index 490bbee..0b15ea2 100644 --- a/plugins/jquery.lazy.vimeo.min.js +++ b/plugins/jquery.lazy.vimeo.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - Vimeo Plugin v1.0 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){t.lazy("vimeo",function(t,e){"iframe"==t[0].tagName.toLowerCase()?(t.attr("src","https://player.vimeo.com/video/"+t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - Vimeo Plugin v1.1 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){t.lazy("vimeo",function(t,e){"iframe"===t[0].tagName.toLowerCase()?(t.attr("src","https://player.vimeo.com/video/"+t.attr("data-src")),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/plugins/jquery.lazy.youtube.js b/plugins/jquery.lazy.youtube.js index 5c3a8a2..bf9f076 100644 --- a/plugins/jquery.lazy.youtube.js +++ b/plugins/jquery.lazy.youtube.js @@ -1,8 +1,8 @@ /*! - * jQuery & Zepto Lazy - YouTube Plugin - v1.3 + * jQuery & Zepto Lazy - YouTube Plugin - v1.4 * http://jquery.eisbehr.de/lazy/ * - * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern + * Copyright 2012 - 2017, Daniel 'Eisbehr' Kern * * Dual licensed under the MIT and GPL-2.0 licenses: * http://www.opensource.org/licenses/mit-license.php @@ -12,7 +12,7 @@ // load youtube video iframe, like: // $.lazy(["yt", "youtube"], function(element, response) { - if( element[0].tagName.toLowerCase() == "iframe" ) { + if( element[0].tagName.toLowerCase() === "iframe" ) { // pass source to iframe element.attr("src", "https://www.youtube.com/embed/" + element.attr("data-src") + "?rel=0&showinfo=0"); diff --git a/plugins/jquery.lazy.youtube.min.js b/plugins/jquery.lazy.youtube.min.js index 23ac716..846f298 100644 --- a/plugins/jquery.lazy.youtube.min.js +++ b/plugins/jquery.lazy.youtube.min.js @@ -1,2 +1,2 @@ -/*! jQuery & Zepto Lazy - YouTube Plugin v1.3 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */ -!function(t){t.lazy(["yt","youtube"],function(t,e){"iframe"==t[0].tagName.toLowerCase()?(t.attr("src","https://www.youtube.com/embed/"+t.attr("data-src")+"?rel=0&showinfo=0"),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file +/*! jQuery & Zepto Lazy - YouTube Plugin v1.4 - http://jquery.eisbehr.de/lazy - MIT&GPL-2.0 license - Copyright 2012-2017 Daniel 'Eisbehr' Kern */ +!function(t){t.lazy(["yt","youtube"],function(t,e){"iframe"===t[0].tagName.toLowerCase()?(t.attr("src","https://www.youtube.com/embed/"+t.attr("data-src")+"?rel=0&showinfo=0"),this.config("removeAttribute")&&t.removeAttr("data-src")):e(!1)})}(window.jQuery||window.Zepto); \ No newline at end of file