Skip to content

issue/support-amd #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
.idea
104 changes: 50 additions & 54 deletions dist/jqlight.lazyloadxt.js
Original file line number Diff line number Diff line change
@@ -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++) {
Expand All @@ -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;
Expand All @@ -45,7 +51,6 @@
}
return target;
};
$.fn.extend = $.extend;

var prev_$ = window.$;
window.$ = $;
Expand All @@ -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);
}
Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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);
}));
2 changes: 1 addition & 1 deletion dist/jqlight.lazyloadxt.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions dist/jquery.lazyloadxt.autoload.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,4 +22,4 @@
}, options.autoLoadTime);
});

})(window.jQuery || window.Zepto || window.$);
}));
2 changes: 1 addition & 1 deletion dist/jquery.lazyloadxt.autoload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions dist/jquery.lazyloadxt.bg.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -20,4 +27,4 @@
}
});

})(window.jQuery || window.Zepto || window.$);
}));
2 changes: 1 addition & 1 deletion dist/jquery.lazyloadxt.bg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions dist/jquery.lazyloadxt.bootstrap.js
Original file line number Diff line number Diff line change
@@ -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.$);
}));
2 changes: 1 addition & 1 deletion dist/jquery.lazyloadxt.bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions dist/jquery.lazyloadxt.extra.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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]';
Expand Down Expand Up @@ -340,4 +355,4 @@
}
});

})(window.jQuery || window.Zepto || window.$);
}));
Loading