diff --git a/.gitignore b/.gitignore index 2ccbe46..7aa7fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules/ +.idea \ No newline at end of file diff --git a/dist/jqlight.lazyloadxt.js b/dist/jqlight.lazyloadxt.js index 767e07d..47187f4 100644 --- a/dist/jqlight.lazyloadxt.js +++ b/dist/jqlight.lazyloadxt.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function (window, document, Element, undefined) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else { + factory(root, document, Element.prototype); + } +}(typeof window !== "undefined" ? window : this, function(window, document, Element) { function Wrapper(collection) { if (collection) { for (var i = 0, length = collection.length; i < length; i++) { @@ -21,13 +28,12 @@ : (selector && (selector === window || selector.nodeType) ? [selector] : selector)); } - $.fn = { + Wrapper.prototype = $.fn = { constructor: Wrapper, length: 0 }; - Wrapper.prototype = $.fn; - $.extend = function (target) { + $.fn.extend = $.extend = function (target) { var options, name, copy, i = 0, length = arguments.length; if (length <= 1) { target = this; @@ -45,7 +51,6 @@ } return target; }; - $.fn.extend = $.extend; var prev_$ = window.$; window.$ = $; @@ -69,36 +74,34 @@ return false; }, each: function (array, callback) { - var value, i = 0, length = array.length; - for (; i < length; i++) { - value = array[i]; - if (callback.call(value, i, value) === false) { + for (var i = 0, length = array.length ; i < length; i++) { + if (callback(i, array[i]) === false) { return false; } } return true; }, - grep: function (elems, callback, invert) { + grep: function (array, callback, invert) { var callbackInverse, matches = [], i = 0, - length = elems.length, + length = array.length, callbackExpect = !invert; for (; i < length; i++) { - callbackInverse = !callback(i, elems[i]); + callbackInverse = !callback(i, array[i]); if (callbackInverse !== callbackExpect) { - matches.push(elems[i]); + matches.push(array[i]); } } return matches; }, - map: function (elems, callback) { + map: function (array, callback) { var value, i = 0, - length = elems.length, + length = array.length, ret = []; for (; i < length; i++) { - value = callback(i, elems[i]); + value = callback(array[i], i); if (value != null) { ret.push(value); } @@ -109,10 +112,22 @@ var DATAKEYPROP = '__jqlight_data__'; $.fn.extend({ - each: function (callback, args) { - $.each(this, callback, args); + each: function (callback) { + $.each(this, function (index, elem) { + return callback.call(elem, index, elem); + }); return this; }, + map: function (callback) { + return $($.map(this, function (elem, index) { + return callback.call(elem, index, elem); + })); + }, + filter: function (callback) { + return $($.grep(this, function (index, elem) { + return callback.call(elem, index, elem); + })); + }, ready: function (fn) { if (/complete|loaded|interactive/.test(document.readyState) && document.body) { fn(); @@ -138,7 +153,7 @@ selector = undefined; } types = types.split(' '); - return this.each(function (i, elem) { + return this.each(function (index, elem) { var listener = selector ? delegateHandler.bind(elem, selector, fn) : fn; $.each(types, function (j, eventName) { if (eventName) { @@ -148,13 +163,14 @@ }); }, off: function (types, selector, fn) { + // Note: off() for delegated events is not supported if (selector === false || $.isFunction(selector)) { // ( types [, fn] ) fn = selector; - selector = undefined; + // selector = undefined; } types = types.split(' '); - return this.each(function (i, elem) { + return this.each(function (index, elem) { $.each(types, function (j, eventName) { if (eventName) { elem.removeEventListener(eventName, fn); @@ -179,24 +195,18 @@ var elem = this[0]; return elem && elem[DATAKEYPROP] ? elem[DATAKEYPROP][key] : undefined; } - this.each(function (i, elem) { + this.each(function (index, elem) { elem[DATAKEYPROP] = elem[DATAKEYPROP] || {}; elem[DATAKEYPROP][key] = value; }); return this; }, - map: function (callback) { - return $($.map(this, callback)); - }, - filter: function (callback) { - return $($.grep(this, callback)); - }, attr: function (name, value) { if (value === undefined) { return this.length ? this[0].getAttribute(name) : undefined; } - $.each(this, function (i, elem) { - elem.setAttribute(name, value + ''); + this.each(function () { + this.setAttribute(name, value + ''); }); return this; } @@ -212,8 +222,7 @@ if (elem.nodeType === 1) { origValue = elem.className; cur = origValue ? ( ' ' + origValue + ' ' ).replace(/[\t\r\n\f]/g, ' ') : ' '; - j = 0; - while ((clazz = classes[j++])) { + for (j = 0; (clazz = classes[j++]); ) { cur = callback(cur, clazz, cur.indexOf(' ' + clazz + ' ') >= 0); } finalValue = cur.slice(1, -1); @@ -225,28 +234,15 @@ return obj; } - function delegateHandler(selector, handler, event) { - var currentTarget = closest.call([event.target], selector, this)[0]; - if (currentTarget && currentTarget !== this) { - handler.call(currentTarget, event); - } - } - var matches = Element.matches || Element.matchesSelector || Element.mozMatchesSelector || Element.msMatchesSelector || Element.oMatchesSelector || Element.webkitMatchesSelector; - function closest(selector, context) { - var nodes = []; - $.each(this, function (i, node) { - while (node && node !== context) { - if (matches.call(node, selector)) { - nodes.push(node); - break; - } - node = node.parentElement; + function delegateHandler(selector, handler, event) { + var node = event.target; + while (node && node !== this) { + if (matches.call(node, selector)) { + return handler.call(node, event); } - }); - return $($.grep(nodes, function (index, item) { - return nodes.indexOf(item) === index; - })); + node = node.parentElement; + } } -})(window, document, Element.prototype); +})); diff --git a/dist/jqlight.lazyloadxt.min.js b/dist/jqlight.lazyloadxt.min.js index aca0c3d..957eef7 100644 --- a/dist/jqlight.lazyloadxt.min.js +++ b/dist/jqlight.lazyloadxt.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b,c,d){function e(a){if(a){for(var b=0,c=a.length;c>b;b++)this[b]=a[b];this.length=c}}function f(c){return c instanceof e?c:new e("string"==typeof c?b.querySelectorAll(c):c&&(c===a||c.nodeType)?[c]:c)}function g(a,b,c){for(var d,e,f,g,h,i,j=(b||"").match(/\S+/g)||[],k=0,l=a.length;l>k;)if(d=a[k++],1===d.nodeType){for(h=d.className,e=h?(" "+h+" ").replace(/[\t\r\n\f]/g," "):" ",g=0;f=j[g++];)e=c(e,f,e.indexOf(" "+f+" ")>=0);i=e.slice(1,-1),h!==i&&(d.className=i)}return a}function h(a,b,c){var d=i.call([c.target],a,this)[0];d&&d!==this&&b.call(d,c)}function i(a,b){var c=[];return f.each(this,function(d,e){for(;e&&e!==b;){if(l.call(e,a)){c.push(e);break}e=e.parentElement}}),f(f.grep(c,function(a,b){return c.indexOf(b)===a}))}f.fn={constructor:e,length:0},e.prototype=f.fn,f.extend=function(a){var b,c,e,f=0,g=arguments.length;for(1>=g?a=this:f=1;g>f;f++){b=arguments[f];for(c in b)e=b[c],e!==d&&e!==a&&(a[c]=e)}return a},f.fn.extend=f.extend;var j=a.$;a.$=f,f.extend({noConflict:function(){return a.$=j,f},isFunction:function(a){return"function"==typeof a},contains:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},each:function(a,b){for(var c,d=0,e=a.length;e>d;d++)if(c=a[d],b.call(c,d,c)===!1)return!1;return!0},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(f,a[f]),d!==h&&e.push(a[f]);return e},map:function(a,b){for(var c,d=0,e=a.length,f=[];e>d;d++)c=b(d,a[d]),null!=c&&f.push(c);return f}});var k="__jqlight_data__";f.fn.extend({each:function(a,b){return f.each(this,a,b),this},ready:function(a){return/complete|loaded|interactive/.test(b.readyState)&&b.body?a():f(b).on("DOMContentLoaded",a),this},addClass:function(a){return g(this,a,function(a,b,c){return c?a:a+b+" "})},removeClass:function(a){return g(this,a,function(a,b,c){return c?a.replace(" "+b+" "," "):a})},on:function(a,b,c){return null==c&&(c=b,b=d),a=a.split(" "),this.each(function(d,e){var g=b?h.bind(e,b,c):c;f.each(a,function(a,b){b&&e.addEventListener(b,g)})})},off:function(a,b,c){return(b===!1||f.isFunction(b))&&(c=b,b=d),a=a.split(" "),this.each(function(b,d){f.each(a,function(a,b){b&&d.removeEventListener(b,c)})})},trigger:function(c,d){return this.each(function(){var e;a.CustomEvent?e=new CustomEvent(c,{detail:d}):(e=b.createEvent("CustomEvent"),e.initCustomEvent(c,!0,!0,d)),this.dispatchEvent(e)})},data:function(a,b){if("string"==typeof a&&b===d){var c=this[0];return c&&c[k]?c[k][a]:d}return this.each(function(c,d){d[k]=d[k]||{},d[k][a]=b}),this},map:function(a){return f(f.map(this,a))},filter:function(a){return f(f.grep(this,a))},attr:function(a,b){return b===d?this.length?this[0].getAttribute(a):d:(f.each(this,function(c,d){d.setAttribute(a,b+"")}),this)}});var l=c.matches||c.matchesSelector||c.mozMatchesSelector||c.msMatchesSelector||c.oMatchesSelector||c.webkitMatchesSelector}(window,document,Element.prototype); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define([],b):b(a,document,Element.prototype)}("undefined"!=typeof window?window:this,function(a,b,c){function d(a){if(a){for(var b=0,c=a.length;c>b;b++)this[b]=a[b];this.length=c}}function e(c){return c instanceof d?c:new d("string"==typeof c?b.querySelectorAll(c):c&&(c===a||c.nodeType)?[c]:c)}function f(a,b,c){for(var d,e,f,g,h,i,j=(b||"").match(/\S+/g)||[],k=0,l=a.length;l>k;)if(d=a[k++],1===d.nodeType){for(h=d.className,e=h?(" "+h+" ").replace(/[\t\r\n\f]/g," "):" ",g=0;f=j[g++];)e=c(e,f,e.indexOf(" "+f+" ")>=0);i=e.slice(1,-1),h!==i&&(d.className=i)}return a}function g(a,b,c){for(var d=c.target;d&&d!==this;){if(j.call(d,a))return b.call(d,c);d=d.parentElement}}d.prototype=e.fn={constructor:d,length:0},e.fn.extend=e.extend=function(a){var b,c,d,e=0,f=arguments.length;for(1>=f?a=this:e=1;f>e;e++){b=arguments[e];for(c in b)d=b[c],void 0!==d&&d!==a&&(a[c]=d)}return a};var h=a.$;a.$=e,e.extend({noConflict:function(){return a.$=h,e},isFunction:function(a){return"function"==typeof a},contains:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},each:function(a,b){for(var c=0,d=a.length;d>c;c++)if(b(c,a[c])===!1)return!1;return!0},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(f,a[f]),d!==h&&e.push(a[f]);return e},map:function(a,b){for(var c,d=0,e=a.length,f=[];e>d;d++)c=b(a[d],d),null!=c&&f.push(c);return f}});var i="__jqlight_data__";e.fn.extend({each:function(a){return e.each(this,function(b,c){return a.call(c,b,c)}),this},map:function(a){return e(e.map(this,function(b,c){return a.call(b,c,b)}))},filter:function(a){return e(e.grep(this,function(b,c){return a.call(c,b,c)}))},ready:function(a){return/complete|loaded|interactive/.test(b.readyState)&&b.body?a():e(b).on("DOMContentLoaded",a),this},addClass:function(a){return f(this,a,function(a,b,c){return c?a:a+b+" "})},removeClass:function(a){return f(this,a,function(a,b,c){return c?a.replace(" "+b+" "," "):a})},on:function(a,b,c){return null==c&&(c=b,b=void 0),a=a.split(" "),this.each(function(d,f){var h=b?g.bind(f,b,c):c;e.each(a,function(a,b){b&&f.addEventListener(b,h)})})},off:function(a,b,c){return(b===!1||e.isFunction(b))&&(c=b),a=a.split(" "),this.each(function(b,d){e.each(a,function(a,b){b&&d.removeEventListener(b,c)})})},trigger:function(c,d){return this.each(function(){var e;a.CustomEvent?e=new CustomEvent(c,{detail:d}):(e=b.createEvent("CustomEvent"),e.initCustomEvent(c,!0,!0,d)),this.dispatchEvent(e)})},data:function(a,b){if("string"==typeof a&&void 0===b){var c=this[0];return c&&c[i]?c[i][a]:void 0}return this.each(function(c,d){d[i]=d[i]||{},d[i][a]=b}),this},attr:function(a,b){return void 0===b?this.length?this[0].getAttribute(a):void 0:(this.each(function(){this.setAttribute(a,b+"")}),this)}});var j=c.matches||c.matchesSelector||c.mozMatchesSelector||c.msMatchesSelector||c.oMatchesSelector||c.webkitMatchesSelector}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.autoload.js b/dist/jquery.lazyloadxt.autoload.js index 7b08959..539fc61 100644 --- a/dist/jquery.lazyloadxt.autoload.js +++ b/dist/jquery.lazyloadxt.autoload.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT; options.forceEvent += ' lazyautoload'; @@ -15,4 +22,4 @@ }, options.autoLoadTime); }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.autoload.min.js b/dist/jquery.lazyloadxt.autoload.min.js index e48d710..eb842ed 100644 --- a/dist/jquery.lazyloadxt.autoload.min.js +++ b/dist/jquery.lazyloadxt.autoload.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){var b=a.lazyLoadXT;b.forceEvent+=" lazyautoload",b.autoLoadTime=b.autoLoadTime||50,a(document).ready(function(){setTimeout(function(){a(window).trigger("lazyautoload")},b.autoLoadTime)})}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){var b=a.lazyLoadXT;b.forceEvent+=" lazyautoload",b.autoLoadTime=b.autoLoadTime||50,a(document).ready(function(){setTimeout(function(){a(window).trigger("lazyautoload")},b.autoLoadTime)})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.bg.js b/dist/jquery.lazyloadxt.bg.js index 5ef149c..d8e0346 100644 --- a/dist/jquery.lazyloadxt.bg.js +++ b/dist/jquery.lazyloadxt.bg.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT, bgAttr = options.bgAttr || 'data-bg'; @@ -20,4 +27,4 @@ } }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.bg.min.js b/dist/jquery.lazyloadxt.bg.min.js index 174eee3..942354e 100644 --- a/dist/jquery.lazyloadxt.bg.min.js +++ b/dist/jquery.lazyloadxt.bg.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){var b=a.lazyLoadXT,c=b.bgAttr||"data-bg";b.selector+=",["+c+"]",a(document).on("lazyshow",function(b){var d=a(b.target),e=d.attr(c);e&&d.css("background-image","url('"+e+"')").removeAttr(c).triggerHandler("load")})}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){var b=a.lazyLoadXT,c=b.bgAttr||"data-bg";b.selector+=",["+c+"]",a(document).on("lazyshow",function(b){var d=a(b.target),e=d.attr(c);e&&d.css("background-image","url('"+e+"')").removeAttr(c).triggerHandler("load")})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.bootstrap.js b/dist/jquery.lazyloadxt.bootstrap.js index 0e10aad..8a87a23 100644 --- a/dist/jquery.lazyloadxt.bootstrap.js +++ b/dist/jquery.lazyloadxt.bootstrap.js @@ -1,8 +1,15 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { $.lazyLoadXT.updateEvent += ' shown.bs.modal shown.bs.dropdown shown.bs.tab shown.bs.tooltip shown.bs.popover shown.bs.collapse slid.bs.carousel'; -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.bootstrap.min.js b/dist/jquery.lazyloadxt.bootstrap.min.js index 816b1ae..38e2f49 100644 --- a/dist/jquery.lazyloadxt.bootstrap.min.js +++ b/dist/jquery.lazyloadxt.bootstrap.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){a.lazyLoadXT.updateEvent+=" shown.bs.modal shown.bs.dropdown shown.bs.tab shown.bs.tooltip shown.bs.popover shown.bs.collapse slid.bs.carousel"}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){a.lazyLoadXT.updateEvent+=" shown.bs.modal shown.bs.dropdown shown.bs.tab shown.bs.tooltip shown.bs.popover shown.bs.collapse slid.bs.carousel"}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.extra.js b/dist/jquery.lazyloadxt.extra.js index 8743e19..c0d5f56 100644 --- a/dist/jquery.lazyloadxt.extra.js +++ b/dist/jquery.lazyloadxt.extra.js @@ -1,9 +1,17 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ - -(function ($, window, document, undefined) { +/*global define*/ + +// UMD dance - https://github.com/umdjs/umd +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { // options var lazyLoadXT = 'lazyLoadXT', dataLazied = 'lazied', @@ -309,10 +317,17 @@ } }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT; options.selector += ',video,iframe[data-src]'; @@ -340,4 +355,4 @@ } }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.extra.min.js b/dist/jquery.lazyloadxt.extra.min.js index 09c810f..01be0c5 100644 --- a/dist/jquery.lazyloadxt.extra.min.js +++ b/dist/jquery.lazyloadxt.extra.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b,c,d){function e(a,b){return a[b]===d?t[b]:a[b]}function f(){var a=b.pageYOffset;return a===d?r.scrollTop:a}function g(a,b){var c=t["on"+a];c&&(w(c)?c.call(b[0]):(c.addClass&&b.addClass(c.addClass),c.removeClass&&b.removeClass(c.removeClass))),b.trigger("lazy"+a,[b]),k()}function h(b){g(b.type,a(this).off(p,h))}function i(c){if(z.length){c=c||t.forceLoad,A=1/0;var d,e,i=f(),j=b.innerHeight||r.clientHeight,k=b.innerWidth||r.clientWidth;for(d=0,e=z.length;e>d;d++){var l,m=z[d],q=m[0],s=m[n],u=!1,v=c||y(q,o)<0;if(a.contains(r,q)){if(c||!s.visibleOnly||q.offsetWidth||q.offsetHeight){if(!v){var x=q.getBoundingClientRect(),B=s.edgeX,C=s.edgeY;l=x.top+i-C-j,v=i>=l&&x.bottom>-C&&x.left<=k+B&&x.right>-B}if(v){m.on(p,h),g("show",m);var D=s.srcAttr,E=w(D)?D(m):q.getAttribute(D);E&&(q.src=E),u=!0}else A>l&&(A=l)}}else u=!0;u&&(y(q,o,0),z.splice(d--,1),e--)}e||g("complete",a(r))}}function j(){B>1?(B=1,i(),setTimeout(j,t.throttle)):B=0}function k(a){z.length&&(a&&"scroll"===a.type&&a.currentTarget===b&&A>=f()||(B||setTimeout(j,0),B=2))}function l(){v.lazyLoadXT()}function m(){i(!0)}var n="lazyLoadXT",o="lazied",p="load error",q="lazy-hidden",r=c.documentElement||c.body,s=b.onscroll===d||!!b.operamini||!r.getBoundingClientRect,t={autoInit:!0,selector:"img[data-src]",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,forceLoad:s,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove focus",forceEvent:"lazyloadall",oninit:{removeClass:"lazy"},onshow:{addClass:q},onload:{removeClass:q,addClass:"lazy-loaded"},onerror:{removeClass:q},checkDuplicates:!0},u={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},v=a(b),w=a.isFunction,x=a.extend,y=a.data||function(b,c){return a(b).data(c)},z=[],A=0,B=0;a[n]=x(t,u,a[n]),a.fn[n]=function(c){c=c||{};var d,f=e(c,"blankImage"),h=e(c,"checkDuplicates"),i=e(c,"scrollContainer"),j=e(c,"show"),l={};a(i).on("scroll",k);for(d in u)l[d]=e(c,d);return this.each(function(d,e){if(e===b)a(t.selector).lazyLoadXT(c);else{var i=h&&y(e,o),m=a(e).data(o,j?-1:1);if(i)return void k();f&&"IMG"===e.tagName&&!e.src&&(e.src=f),m[n]=x({},l),g("init",m),z.push(m),k()}})},a(c).ready(function(){g("start",v),v.on(t.updateEvent,k).on(t.forceEvent,m),a(c).on(t.updateEvent,k),t.autoInit&&(v.on(t.loadEvent,l),l())})}(window.jQuery||window.Zepto||window.$,window,document),function(a){var b=a.lazyLoadXT;b.selector+=",video,iframe[data-src]",b.videoPoster="data-poster",a(document).on("lazyshow","video",function(c,d){var e=d.lazyLoadXT.srcAttr,f=a.isFunction(e),g=!1;d.attr("poster",d.attr(b.videoPoster)),d.children("source,track").each(function(b,c){var d=a(c),h=f?e(d):d.attr(e);h&&(d.attr("src",h),g=!0)}),g&&this.load()})}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){function b(a,b){return void 0===a[b]?q[b]:a[b]}function c(){var a=window.pageYOffset;return void 0===a?o.scrollTop:a}function d(a,b){var c=q["on"+a];c&&(t(c)?c.call(b[0]):(c.addClass&&b.addClass(c.addClass),c.removeClass&&b.removeClass(c.removeClass))),b.trigger("lazy"+a,[b]),h()}function e(b){d(b.type,a(this).off(m,e))}function f(b){if(w.length){b=b||q.forceLoad,x=1/0;var f,g,h=c(),i=window.innerHeight||o.clientHeight,j=window.innerWidth||o.clientWidth;for(f=0,g=w.length;g>f;f++){var n,p=w[f],r=p[0],s=p[k],u=!1,y=b||v(r,l)<0;if(a.contains(o,r)){if(b||!s.visibleOnly||r.offsetWidth||r.offsetHeight){if(!y){var z=r.getBoundingClientRect(),A=s.edgeX,B=s.edgeY;n=z.top+h-B-i,y=h>=n&&z.bottom>-B&&z.left<=j+A&&z.right>-A}if(y){p.on(m,e),d("show",p);var C=s.srcAttr,D=t(C)?C(p):r.getAttribute(C);D&&(r.src=D),u=!0}else x>n&&(x=n)}}else u=!0;u&&(v(r,l,0),w.splice(f--,1),g--)}g||d("complete",a(o))}}function g(){y>1?(y=1,f(),setTimeout(g,q.throttle)):y=0}function h(a){w.length&&(a&&"scroll"===a.type&&a.currentTarget===window&&x>=c()||(y||setTimeout(g,0),y=2))}function i(){s.lazyLoadXT()}function j(){f(!0)}var k="lazyLoadXT",l="lazied",m="load error",n="lazy-hidden",o=document.documentElement||document.body,p=void 0===window.onscroll||!!window.operamini||!o.getBoundingClientRect,q={autoInit:!0,selector:"img[data-src]",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,forceLoad:p,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove focus",forceEvent:"lazyloadall",oninit:{removeClass:"lazy"},onshow:{addClass:n},onload:{removeClass:n,addClass:"lazy-loaded"},onerror:{removeClass:n},checkDuplicates:!0},r={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},s=a(window),t=a.isFunction,u=a.extend,v=a.data||function(b,c){return a(b).data(c)},w=[],x=0,y=0;a[k]=u(q,r,a[k]),a.fn[k]=function(c){c=c||{};var e,f=b(c,"blankImage"),g=b(c,"checkDuplicates"),i=b(c,"scrollContainer"),j=b(c,"show"),m={};a(i).on("scroll",h);for(e in r)m[e]=b(c,e);return this.each(function(b,e){if(e===window)a(q.selector).lazyLoadXT(c);else{var i=g&&v(e,l),n=a(e).data(l,j?-1:1);if(i)return void h();f&&"IMG"===e.tagName&&!e.src&&(e.src=f),n[k]=u({},m),d("init",n),w.push(n),h()}})},a(document).ready(function(){d("start",s),s.on(q.updateEvent,h).on(q.forceEvent,j),a(document).on(q.updateEvent,h),q.autoInit&&(s.on(q.loadEvent,i),i())})}),function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){var b=a.lazyLoadXT;b.selector+=",video,iframe[data-src]",b.videoPoster="data-poster",a(document).on("lazyshow","video",function(c,d){var e=d.lazyLoadXT.srcAttr,f=a.isFunction(e),g=!1;d.attr("poster",d.attr(b.videoPoster)),d.children("source,track").each(function(b,c){var d=a(c),h=f?e(d):d.attr(e);h&&(d.attr("src",h),g=!0)}),g&&this.load()})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.fadein.css b/dist/jquery.lazyloadxt.fadein.css index 2cd2d36..a07ad80 100644 --- a/dist/jquery.lazyloadxt.fadein.css +++ b/dist/jquery.lazyloadxt.fadein.css @@ -1,4 +1,4 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ diff --git a/dist/jquery.lazyloadxt.jquerymobile.js b/dist/jquery.lazyloadxt.jquerymobile.js index 9ba0a59..57f5ec3 100644 --- a/dist/jquery.lazyloadxt.jquerymobile.js +++ b/dist/jquery.lazyloadxt.jquerymobile.js @@ -1,8 +1,15 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { $.lazyLoadXT.updateEvent += ' collapsibleexpand filterablefilter pagechange panelopen popupafteropen tabsactivate'; -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.jquerymobile.min.js b/dist/jquery.lazyloadxt.jquerymobile.min.js index c1e69db..03f3891 100644 --- a/dist/jquery.lazyloadxt.jquerymobile.min.js +++ b/dist/jquery.lazyloadxt.jquerymobile.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){a.lazyLoadXT.updateEvent+=" collapsibleexpand filterablefilter pagechange panelopen popupafteropen tabsactivate"}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){a.lazyLoadXT.updateEvent+=" collapsibleexpand filterablefilter pagechange panelopen popupafteropen tabsactivate"}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.js b/dist/jquery.lazyloadxt.js index 6bc7c9d..0e266ea 100644 --- a/dist/jquery.lazyloadxt.js +++ b/dist/jquery.lazyloadxt.js @@ -1,9 +1,17 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ - -(function ($, window, document, undefined) { +/*global define*/ + +// UMD dance - https://github.com/umdjs/umd +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { // options var lazyLoadXT = 'lazyLoadXT', dataLazied = 'lazied', @@ -309,4 +317,4 @@ } }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/dist/jquery.lazyloadxt.min.js b/dist/jquery.lazyloadxt.min.js index 099662b..42942d3 100644 --- a/dist/jquery.lazyloadxt.min.js +++ b/dist/jquery.lazyloadxt.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b,c,d){function e(a,b){return a[b]===d?t[b]:a[b]}function f(){var a=b.pageYOffset;return a===d?r.scrollTop:a}function g(a,b){var c=t["on"+a];c&&(w(c)?c.call(b[0]):(c.addClass&&b.addClass(c.addClass),c.removeClass&&b.removeClass(c.removeClass))),b.trigger("lazy"+a,[b]),k()}function h(b){g(b.type,a(this).off(p,h))}function i(c){if(z.length){c=c||t.forceLoad,A=1/0;var d,e,i=f(),j=b.innerHeight||r.clientHeight,k=b.innerWidth||r.clientWidth;for(d=0,e=z.length;e>d;d++){var l,m=z[d],q=m[0],s=m[n],u=!1,v=c||y(q,o)<0;if(a.contains(r,q)){if(c||!s.visibleOnly||q.offsetWidth||q.offsetHeight){if(!v){var x=q.getBoundingClientRect(),B=s.edgeX,C=s.edgeY;l=x.top+i-C-j,v=i>=l&&x.bottom>-C&&x.left<=k+B&&x.right>-B}if(v){m.on(p,h),g("show",m);var D=s.srcAttr,E=w(D)?D(m):q.getAttribute(D);E&&(q.src=E),u=!0}else A>l&&(A=l)}}else u=!0;u&&(y(q,o,0),z.splice(d--,1),e--)}e||g("complete",a(r))}}function j(){B>1?(B=1,i(),setTimeout(j,t.throttle)):B=0}function k(a){z.length&&(a&&"scroll"===a.type&&a.currentTarget===b&&A>=f()||(B||setTimeout(j,0),B=2))}function l(){v.lazyLoadXT()}function m(){i(!0)}var n="lazyLoadXT",o="lazied",p="load error",q="lazy-hidden",r=c.documentElement||c.body,s=b.onscroll===d||!!b.operamini||!r.getBoundingClientRect,t={autoInit:!0,selector:"img[data-src]",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,forceLoad:s,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove focus",forceEvent:"lazyloadall",oninit:{removeClass:"lazy"},onshow:{addClass:q},onload:{removeClass:q,addClass:"lazy-loaded"},onerror:{removeClass:q},checkDuplicates:!0},u={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},v=a(b),w=a.isFunction,x=a.extend,y=a.data||function(b,c){return a(b).data(c)},z=[],A=0,B=0;a[n]=x(t,u,a[n]),a.fn[n]=function(c){c=c||{};var d,f=e(c,"blankImage"),h=e(c,"checkDuplicates"),i=e(c,"scrollContainer"),j=e(c,"show"),l={};a(i).on("scroll",k);for(d in u)l[d]=e(c,d);return this.each(function(d,e){if(e===b)a(t.selector).lazyLoadXT(c);else{var i=h&&y(e,o),m=a(e).data(o,j?-1:1);if(i)return void k();f&&"IMG"===e.tagName&&!e.src&&(e.src=f),m[n]=x({},l),g("init",m),z.push(m),k()}})},a(c).ready(function(){g("start",v),v.on(t.updateEvent,k).on(t.forceEvent,m),a(c).on(t.updateEvent,k),t.autoInit&&(v.on(t.loadEvent,l),l())})}(window.jQuery||window.Zepto||window.$,window,document); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){function b(a,b){return void 0===a[b]?q[b]:a[b]}function c(){var a=window.pageYOffset;return void 0===a?o.scrollTop:a}function d(a,b){var c=q["on"+a];c&&(t(c)?c.call(b[0]):(c.addClass&&b.addClass(c.addClass),c.removeClass&&b.removeClass(c.removeClass))),b.trigger("lazy"+a,[b]),h()}function e(b){d(b.type,a(this).off(m,e))}function f(b){if(w.length){b=b||q.forceLoad,x=1/0;var f,g,h=c(),i=window.innerHeight||o.clientHeight,j=window.innerWidth||o.clientWidth;for(f=0,g=w.length;g>f;f++){var n,p=w[f],r=p[0],s=p[k],u=!1,y=b||v(r,l)<0;if(a.contains(o,r)){if(b||!s.visibleOnly||r.offsetWidth||r.offsetHeight){if(!y){var z=r.getBoundingClientRect(),A=s.edgeX,B=s.edgeY;n=z.top+h-B-i,y=h>=n&&z.bottom>-B&&z.left<=j+A&&z.right>-A}if(y){p.on(m,e),d("show",p);var C=s.srcAttr,D=t(C)?C(p):r.getAttribute(C);D&&(r.src=D),u=!0}else x>n&&(x=n)}}else u=!0;u&&(v(r,l,0),w.splice(f--,1),g--)}g||d("complete",a(o))}}function g(){y>1?(y=1,f(),setTimeout(g,q.throttle)):y=0}function h(a){w.length&&(a&&"scroll"===a.type&&a.currentTarget===window&&x>=c()||(y||setTimeout(g,0),y=2))}function i(){s.lazyLoadXT()}function j(){f(!0)}var k="lazyLoadXT",l="lazied",m="load error",n="lazy-hidden",o=document.documentElement||document.body,p=void 0===window.onscroll||!!window.operamini||!o.getBoundingClientRect,q={autoInit:!0,selector:"img[data-src]",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,forceLoad:p,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove focus",forceEvent:"lazyloadall",oninit:{removeClass:"lazy"},onshow:{addClass:n},onload:{removeClass:n,addClass:"lazy-loaded"},onerror:{removeClass:n},checkDuplicates:!0},r={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},s=a(window),t=a.isFunction,u=a.extend,v=a.data||function(b,c){return a(b).data(c)},w=[],x=0,y=0;a[k]=u(q,r,a[k]),a.fn[k]=function(c){c=c||{};var e,f=b(c,"blankImage"),g=b(c,"checkDuplicates"),i=b(c,"scrollContainer"),j=b(c,"show"),m={};a(i).on("scroll",h);for(e in r)m[e]=b(c,e);return this.each(function(b,e){if(e===window)a(q.selector).lazyLoadXT(c);else{var i=g&&v(e,l),n=a(e).data(l,j?-1:1);if(i)return void h();f&&"IMG"===e.tagName&&!e.src&&(e.src=f),n[k]=u({},m),d("init",n),w.push(n),h()}})},a(document).ready(function(){d("start",s),s.on(q.updateEvent,h).on(q.forceEvent,j),a(document).on(q.updateEvent,h),q.autoInit&&(s.on(q.loadEvent,i),i())})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.picture.js b/dist/jquery.lazyloadxt.picture.js index 22f3038..f6d10fe 100644 --- a/dist/jquery.lazyloadxt.picture.js +++ b/dist/jquery.lazyloadxt.picture.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($, window, document) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT, matchMedia = window.matchMedia; @@ -65,4 +72,4 @@ elOptions.srcAttr = parsePicture; }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/dist/jquery.lazyloadxt.picture.min.js b/dist/jquery.lazyloadxt.picture.min.js index 28cd29d..8cd7d1b 100644 --- a/dist/jquery.lazyloadxt.picture.min.js +++ b/dist/jquery.lazyloadxt.picture.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b,c){function d(b){var c=b.lazyLoadXT.srcAttr,d=a.isFunction(c),e=b.children("img"),g=d?c(e):e.attr(c);return f&&b.children("br").each(function(b,e){var h=a(e),i=d?c(h):h.attr(c),j=h.attr("media");!i||j&&!f(j).matches||(g=i)}),e.attr("src",g),g}var e=a.lazyLoadXT,f=b.matchMedia;e.selector+=",picture",a(c).on("lazyinit","img",function(a,b){b.parent("picture").length&&(b.lazyLoadXT.srcAttr="")}).on("lazyinit","picture",function(b,c){if(c[0].firstChild){var d=c.children("img");d.length||(d=a("").appendTo(c)),d.attr("width",c.attr("width")),d.attr("height",c.attr("height"))}}).on("lazyshow","picture",function(a,b){if(b[0].firstChild){var c=b.lazyLoadXT;c.srcAttrS=c.srcAttr,c.srcAttr=d}})}(window.jQuery||window.Zepto||window.$,window,document); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){function b(b){var c=b.lazyLoadXT.srcAttr,e=a.isFunction(c),f=b.children("img"),g=e?c(f):f.attr(c);return d&&b.children("br").each(function(b,f){var h=a(f),i=e?c(h):h.attr(c),j=h.attr("media");!i||j&&!d(j).matches||(g=i)}),f.attr("src",g),g}var c=a.lazyLoadXT,d=window.matchMedia;c.selector+=",picture",a(document).on("lazyinit","img",function(a,b){b.parent("picture").length&&(b.lazyLoadXT.srcAttr="")}).on("lazyinit","picture",function(b,c){if(c[0].firstChild){var d=c.children("img");d.length||(d=a("").appendTo(c)),d.attr("width",c.attr("width")),d.attr("height",c.attr("height"))}}).on("lazyshow","picture",function(a,c){if(c[0].firstChild){var d=c.lazyLoadXT;d.srcAttrS=d.srcAttr,d.srcAttr=b}})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.print.js b/dist/jquery.lazyloadxt.print.js index 4a3ce09..a91183d 100644 --- a/dist/jquery.lazyloadxt.print.js +++ b/dist/jquery.lazyloadxt.print.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($, window) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { $.lazyLoadXT.forceEvent += ' beforeprint'; if (window.matchMedia) { @@ -16,4 +23,4 @@ }); } -})(window.jQuery || window.Zepto || window.$, window); +})); diff --git a/dist/jquery.lazyloadxt.print.min.js b/dist/jquery.lazyloadxt.print.min.js index b5b8455..62617c9 100644 --- a/dist/jquery.lazyloadxt.print.min.js +++ b/dist/jquery.lazyloadxt.print.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b){a.lazyLoadXT.forceEvent+=" beforeprint",b.matchMedia&&b.matchMedia("print").addListener(function(c){c.matches&&a(b).trigger("beforeprint")})}(window.jQuery||window.Zepto||window.$,window); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){a.lazyLoadXT.forceEvent+=" beforeprint",window.matchMedia&&window.matchMedia("print").addListener(function(b){b.matches&&a(window).trigger("beforeprint")})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.script.js b/dist/jquery.lazyloadxt.script.js index a0b92ed..1b67b5f 100644 --- a/dist/jquery.lazyloadxt.script.js +++ b/dist/jquery.lazyloadxt.script.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($, window, document) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery); + } +}(window, function($) { var options = $.lazyLoadXT, dataLazyTag = options.dataLazyTag || 'data-lazy-tag'; @@ -56,4 +63,4 @@ $(window).lazyLoadXT(); }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/dist/jquery.lazyloadxt.script.min.js b/dist/jquery.lazyloadxt.script.min.js index 5347c6a..a719bf1 100644 --- a/dist/jquery.lazyloadxt.script.min.js +++ b/dist/jquery.lazyloadxt.script.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a,b,c){var d=a.lazyLoadXT,e=d.dataLazyTag||"data-lazy-tag";b.L=function(a){c.write("
")},a(c).ready(function(){var f=d.srcAttr;a.isFunction(f)&&(f="data-src"),a("br["+e+"],span["+e+"]").each(function(b,d){var g,h=d.attributes,i=c.createElement(a(d).attr(e));for(g=0;g")},a(document).ready(function(){var d=b.srcAttr;a.isFunction(d)&&(d="data-src"),a("br["+c+"],span["+c+"]").each(function(b,e){var f,g=e.attributes,h=document.createElement(a(e).attr(c));for(f=0;f=t[i]||a[i]===j}function g(a){return a[i]===j}function h(d){var h=d.attr(k.srcsetAttr);if(!h)return!1;var l=a.map(h.replace(/(\s[\d.]+[whx]),/g,"$1 @,@ ").split(" @,@ "),function(a){return{url:m.exec(a)[1],w:parseFloat((n.exec(a)||q)[1]),h:parseFloat((o.exec(a)||q)[1]),x:parseFloat((p.exec(a)||r)[1])}});if(!l.length)return!1;var s,u,v=c.documentElement;t={w:b.innerWidth||v.clientWidth,h:b.innerHeight||v.clientHeight,x:b.devicePixelRatio||1};for(s in t)i=s,j=e(l,"max"),l=a.grep(l,f);for(s in t)i=s,j=e(l,"min"),l=a.grep(l,g);return u=l[0].url,k.srcsetExtended&&(u=(d.attr(k.srcsetBaseAttr)||"")+u+(d.attr(k.srcsetExtAttr)||"")),u}var i,j,k=a.lazyLoadXT,l=function(){return"srcset"in new Image}(),m=/^\s*(\S*)/,n=/\S\s+(\d+)w/,o=/\S\s+(\d+)h/,p=/\S\s+([\d\.]+)x/,q=[0,1/0],r=[0,1],s={srcsetAttr:"data-srcset",srcsetExtended:!0,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},t={w:0,h:0,x:0};for(i in s)k[i]===d&&(k[i]=s[i]);k.selector+=",img["+k.srcsetAttr+"]",a(c).on("lazyshow","img",function(a,b){var c=b.attr(k.srcsetAttr);c&&(!k.srcsetExtended&&l?b.attr("srcset",c):b.lazyLoadXT.srcAttr=h)})}(window.jQuery||window.Zepto||window.$,window,document); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){function b(b,c){return Math[c].apply(null,a.map(b,function(a){return a[g]}))}function c(a){return a[g]>=r[g]||a[g]===h}function d(a){return a[g]===h}function e(a){return a.replace(/^\s+|\s+$/g,"").replace(/(\s+[\d\.]+[wx]),\s*|\s*,\s+/g,"$1 @,@ ").split(" @,@ ")}function f(f){var k=f.attr(i.srcsetAttr);if(!k)return!1;var q=a.map(e(k),function(a){return{url:l.exec(a)[1],w:parseFloat((m.exec(a)||o)[1]),x:parseFloat((n.exec(a)||p)[1])}});if(!q.length)return!1;r={w:window.innerWidth||j.clientWidth,x:window.devicePixelRatio||1};var s,t;for(s in r)g=s,h=b(q,"max"),q=a.grep(q,c);for(s in r)g=s,h=b(q,"min"),q=a.grep(q,d);return t=q[0].url,i.srcsetExtended&&(t=(f.attr(i.srcsetBaseAttr)||"")+t+(f.attr(i.srcsetExtAttr)||"")),t}var g,h,i=a.lazyLoadXT,j=document.documentElement,k=function(){return"srcset"in new Image}(),l=/^\s*(\S+)/,m=/\S\s+(\d+)w/,n=/\S\s+([\d\.]+)x/,o=[0,1/0],p=[0,1],q={srcsetAttr:"data-srcset",srcsetExtended:!0,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},r={w:0,x:0};for(g in q)void 0===i[g]&&(i[g]=q[g]);i.selector+=",img["+i.srcsetAttr+"]",a(document).on("lazyshow","img",function(b,c){var d=c.attr(i.srcsetAttr);d&&(k?(i.srcsetExtended&&(d=a.map(e(d),function(a){var b=a.indexOf(" ");return 0>b&&(b=a.length),(c.attr(i.srcsetBaseAttr)||"")+a.substr(0,b)+(c.attr(i.srcsetExtAttr)||"")+a.substr(b)}).join(", ")),c.attr("srcset",d)):c.lazyLoadXT.srcAttr=f)})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.video.js b/dist/jquery.lazyloadxt.video.js index 2924d3a..ff667f3 100644 --- a/dist/jquery.lazyloadxt.video.js +++ b/dist/jquery.lazyloadxt.video.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT; options.selector += ',video,iframe[data-src]'; @@ -31,4 +38,4 @@ } }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.video.min.js b/dist/jquery.lazyloadxt.video.min.js index de02bb6..cb1518a 100644 --- a/dist/jquery.lazyloadxt.video.min.js +++ b/dist/jquery.lazyloadxt.video.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){var b=a.lazyLoadXT;b.selector+=",video,iframe[data-src]",b.videoPoster="data-poster",a(document).on("lazyshow","video",function(c,d){var e=d.lazyLoadXT.srcAttr,f=a.isFunction(e),g=!1;d.attr("poster",d.attr(b.videoPoster)),d.children("source,track").each(function(b,c){var d=a(c),h=f?e(d):d.attr(e);h&&(d.attr("src",h),g=!0)}),g&&this.load()})}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){var b=a.lazyLoadXT;b.selector+=",video,iframe[data-src]",b.videoPoster="data-poster",a(document).on("lazyshow","video",function(c,d){var e=d.lazyLoadXT.srcAttr,f=a.isFunction(e),g=!1;d.attr("poster",d.attr(b.videoPoster)),d.children("source,track").each(function(b,c){var d=a(c),h=f?e(d):d.attr(e);h&&(d.attr("src",h),g=!0)}),g&&this.load()})}); \ No newline at end of file diff --git a/dist/jquery.lazyloadxt.widget.js b/dist/jquery.lazyloadxt.widget.js index 858e775..2e018c6 100644 --- a/dist/jquery.lazyloadxt.widget.js +++ b/dist/jquery.lazyloadxt.widget.js @@ -1,9 +1,16 @@ -/*! Lazy Load XT v1.1.0 2016-01-12 +/*! Lazy Load XT v1.1.0 2016-03-21 * http://ressio.github.io/lazy-load-xt * (C) 2016 RESS.io * Licensed under MIT */ +/*global define*/ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { var options = $.lazyLoadXT, widgetAttr = options.widgetAttr || 'data-lazy-widget', reComment = //; @@ -30,4 +37,4 @@ $this.triggerHandler('load'); }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/dist/jquery.lazyloadxt.widget.min.js b/dist/jquery.lazyloadxt.widget.min.js index f117a07..6dc933a 100644 --- a/dist/jquery.lazyloadxt.widget.min.js +++ b/dist/jquery.lazyloadxt.widget.min.js @@ -1,2 +1,2 @@ /* Lazy Load XT 1.1.0 | MIT License */ -!function(a){var b=a.lazyLoadXT,c=b.widgetAttr||"data-lazy-widget",d=//;b.selector+=",["+c+"]",a(document).on("lazyshow","["+c+"]",function(){var b,e=a(this),f=e,g=e.attr(c);g&&(f=a("#"+g)),f.length&&(b=d.exec(f.html()),b&&f.replaceWith(a.trim(b[1]))),e.triggerHandler("load")})}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery||a.$)}(window,function(a){var b=a.lazyLoadXT,c=b.widgetAttr||"data-lazy-widget",d=//;b.selector+=",["+c+"]",a(document).on("lazyshow","["+c+"]",function(){var b,e=a(this),f=e,g=e.attr(c);g&&(f=a("#"+g)),f.length&&(b=d.exec(f.html()),b&&f.replaceWith(a.trim(b[1]))),e.triggerHandler("load")})}); \ No newline at end of file diff --git a/src/jqlight.lazyloadxt.js b/src/jqlight.lazyloadxt.js index 310e8e1..f8a4c36 100644 --- a/src/jqlight.lazyloadxt.js +++ b/src/jqlight.lazyloadxt.js @@ -1,9 +1,16 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true, eqnull:true */ /*jshint -W040:false */ /* to don't alert on "this" in triggerLoadOrError */ /*jshint -W089:false */ -(function (window, document, Element, undefined) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else { + factory(root, document, Element.prototype); + } +}(typeof window !== "undefined" ? window : this, function(window, document, Element) { 'use strict'; function Wrapper(collection) { @@ -240,4 +247,4 @@ node = node.parentElement; } } -})(window, document, Element.prototype); +})); diff --git a/src/jquery.lazyloadxt.autoload.js b/src/jquery.lazyloadxt.autoload.js index cf25449..6675a9f 100644 --- a/src/jquery.lazyloadxt.autoload.js +++ b/src/jquery.lazyloadxt.autoload.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT; @@ -15,4 +22,4 @@ }, options.autoLoadTime); }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.bg.js b/src/jquery.lazyloadxt.bg.js index 683984c..1a03049 100644 --- a/src/jquery.lazyloadxt.bg.js +++ b/src/jquery.lazyloadxt.bg.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -20,4 +27,4 @@ } }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.bootstrap.js b/src/jquery.lazyloadxt.bootstrap.js index cd1cafa..30283f8 100644 --- a/src/jquery.lazyloadxt.bootstrap.js +++ b/src/jquery.lazyloadxt.bootstrap.js @@ -1,8 +1,15 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; $.lazyLoadXT.updateEvent += ' shown.bs.modal shown.bs.dropdown shown.bs.tab shown.bs.tooltip shown.bs.popover shown.bs.collapse slid.bs.carousel'; -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.html.js b/src/jquery.lazyloadxt.html.js index 4a2c0da..3575ebc 100644 --- a/src/jquery.lazyloadxt.html.js +++ b/src/jquery.lazyloadxt.html.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -16,4 +23,4 @@ }); }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.jquerymobile.js b/src/jquery.lazyloadxt.jquerymobile.js index dd39dde..73d04aa 100644 --- a/src/jquery.lazyloadxt.jquerymobile.js +++ b/src/jquery.lazyloadxt.jquerymobile.js @@ -1,8 +1,15 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; $.lazyLoadXT.updateEvent += ' collapsibleexpand filterablefilter pagechange panelopen popupafteropen tabsactivate'; -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.js b/src/jquery.lazyloadxt.js index 566d37c..ee062a6 100644 --- a/src/jquery.lazyloadxt.js +++ b/src/jquery.lazyloadxt.js @@ -1,8 +1,16 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ /*jshint -W040:false */ /* to don't alert on "this" in triggerLoadOrError */ -(function ($, window, document, undefined) { +// UMD dance - https://github.com/umdjs/umd +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; // options @@ -310,4 +318,4 @@ } }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/src/jquery.lazyloadxt.picture.js b/src/jquery.lazyloadxt.picture.js index 896332a..a603950 100644 --- a/src/jquery.lazyloadxt.picture.js +++ b/src/jquery.lazyloadxt.picture.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true, regexp:false */ /*jshint browser:true, jquery:true */ -(function ($, window, document) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -65,4 +72,4 @@ elOptions.srcAttr = parsePicture; }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/src/jquery.lazyloadxt.print.js b/src/jquery.lazyloadxt.print.js index ae65e3f..4eab31e 100644 --- a/src/jquery.lazyloadxt.print.js +++ b/src/jquery.lazyloadxt.print.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true */ /*jshint browser:true, jquery:true */ -(function ($, window) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; $.lazyLoadXT.forceEvent += ' beforeprint'; @@ -16,4 +23,4 @@ }); } -})(window.jQuery || window.Zepto || window.$, window); +})); diff --git a/src/jquery.lazyloadxt.script.js b/src/jquery.lazyloadxt.script.js index 460bd45..0d4dc2f 100644 --- a/src/jquery.lazyloadxt.script.js +++ b/src/jquery.lazyloadxt.script.js @@ -1,8 +1,15 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ /*jshint -W060:false */ /* we use document.write */ -(function ($, window, document) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -57,4 +64,4 @@ $(window).lazyLoadXT(); }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/src/jquery.lazyloadxt.simple.js b/src/jquery.lazyloadxt.simple.js index 97cb264..8680db5 100644 --- a/src/jquery.lazyloadxt.simple.js +++ b/src/jquery.lazyloadxt.simple.js @@ -1,9 +1,16 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true */ /*jshint browser:true, jquery:true */ /* SIMPLE VERSION IS NO LONGER SUPPORTED. USE jquery.lazyloadxt.js INSTEAD. */ -(function ($, window, document) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; // options @@ -184,4 +191,4 @@ initLazyElements(); // standard initialization }); -})(window.jQuery || window.Zepto, window, document); +})); diff --git a/src/jquery.lazyloadxt.srcset.js b/src/jquery.lazyloadxt.srcset.js index c132b43..78b7fc4 100644 --- a/src/jquery.lazyloadxt.srcset.js +++ b/src/jquery.lazyloadxt.srcset.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true, plusplus:true, vars:true, regexp:false */ /*jshint browser:true, jquery:true */ -(function ($, window, document, undefined) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -121,4 +128,4 @@ } }); -})(window.jQuery || window.Zepto || window.$, window, document); +})); diff --git a/src/jquery.lazyloadxt.video.js b/src/jquery.lazyloadxt.video.js index 1705f68..9157e39 100644 --- a/src/jquery.lazyloadxt.video.js +++ b/src/jquery.lazyloadxt.video.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT; @@ -31,4 +38,4 @@ } }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/src/jquery.lazyloadxt.widget.js b/src/jquery.lazyloadxt.widget.js index 2a38697..d1e0b8e 100644 --- a/src/jquery.lazyloadxt.widget.js +++ b/src/jquery.lazyloadxt.widget.js @@ -1,7 +1,14 @@ +/*global define*/ /*jslint browser:true */ /*jshint browser:true, jquery:true */ -(function ($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(root.jQuery || root.$); + } +}(window, function($) { 'use strict'; var options = $.lazyLoadXT, @@ -30,4 +37,4 @@ $this.triggerHandler('load'); }); -})(window.jQuery || window.Zepto || window.$); +})); diff --git a/test/lazyloadxt-domtastic.html b/test/lazyloadxt-domtastic.html index 585fbe9..4dd09c8 100644 --- a/test/lazyloadxt-domtastic.html +++ b/test/lazyloadxt-domtastic.html @@ -4,6 +4,7 @@ Lazy Load XT Test Suite +