mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-16 16:27:12 +10:00
Merge pull request #2460 from dryabov/master
Add jQuery Lazy Load XT plugin 0.8.11 [author]
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($) {
|
||||
var options = $.lazyLoadXT;
|
||||
|
||||
options.forceEvent += ' lazyloadall';
|
||||
options.autoLoad = options.autoLoad || 50;
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(function () {
|
||||
$(window).trigger('lazyloadall');
|
||||
}, options.autoLoad);
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a){var b=a.lazyLoadXT;b.forceEvent+=" lazyloadall",b.autoLoad=b.autoLoad||50,a(document).ready(function(){setTimeout(function(){a(window).trigger("lazyloadall")},b.autoLoad)})}(window.jQuery||window.Zepto);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($) {
|
||||
var options = $.lazyLoadXT,
|
||||
bgAttr = options.bgAttr || 'data-bg';
|
||||
|
||||
options.selector += ',[' + bgAttr + ']';
|
||||
|
||||
$(document).on('lazyshow', function (e) {
|
||||
var $this = $(e.target);
|
||||
$this
|
||||
.css('background-image', "url('" + $this.attr(bgAttr) + "')")
|
||||
.removeAttr(bgAttr);
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | 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);d.css("background-image","url('"+d.attr(c)+"')").removeAttr(c)})}(window.jQuery||window.Zepto);
|
||||
@@ -0,0 +1,298 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document, undefined) {
|
||||
// options
|
||||
var options = {
|
||||
autoInit: true,
|
||||
selector: 'img',
|
||||
classNojs: 'lazy',
|
||||
blankImage: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
|
||||
throttle: 99,
|
||||
loadEvent: 'pageshow', // check AJAX-loaded content in jQueryMobile
|
||||
updateEvent: 'load orientationchange resize scroll touchmove', // page-modified events
|
||||
forceEvent: '', // force loading of all elements
|
||||
oninit: null, // init handler
|
||||
onshow: null, // start loading handler
|
||||
onload: null, // load success handler
|
||||
onerror: null // error handler
|
||||
},
|
||||
elementOptions = {
|
||||
srcAttr: 'data-src',
|
||||
edgeX: 0,
|
||||
edgeY: 0,
|
||||
visibleOnly: true
|
||||
},
|
||||
// autoload all images in Opera Mini and some mobile browsers without scroll event
|
||||
autoLoad = (window.onscroll === undefined || !!window.operamini),
|
||||
$window = $(window),
|
||||
dataLazied = 'lazied',
|
||||
elements = [],
|
||||
viewportTop,
|
||||
viewportBottom,
|
||||
viewportLeft,
|
||||
viewportRight,
|
||||
$data = $.data || function (el, name) {
|
||||
return $(el).data(name);
|
||||
},
|
||||
topLazy = 0,
|
||||
/*
|
||||
waitingMode=0 : no setTimeout
|
||||
waitingMode=1 : setTimeout, no deferred events
|
||||
waitingMode=2 : setTimeout, deferred events
|
||||
*/
|
||||
waitingMode = 0;
|
||||
|
||||
$.lazyLoadXT = $.extend(options, elementOptions, $.lazyLoadXT);
|
||||
|
||||
/**
|
||||
* Add new elements to lazy-load list:
|
||||
* $(elements).lazyLoadXT() or $(window).lazyLoadXT()
|
||||
*
|
||||
* @param {object} [overrides] loading of all elements
|
||||
*/
|
||||
$.fn.lazyLoadXT = function (overrides) {
|
||||
overrides = overrides || {};
|
||||
|
||||
var elementOptionsOverrides = {},
|
||||
blankImage = overrides.blankImage || options.blankImage,
|
||||
classNojs = overrides.classNojs || options.classNojs,
|
||||
checkDuplicates = overrides.checkDuplicates || true,
|
||||
prop;
|
||||
|
||||
for (prop in elementOptions) {
|
||||
elementOptionsOverrides[prop] = (overrides[prop] === undefined) ? options[prop] : overrides[prop];
|
||||
}
|
||||
|
||||
return this.each(function () {
|
||||
if (this === window) {
|
||||
$(options.selector).lazyLoadXT(overrides);
|
||||
} else {
|
||||
// prevent duplicates
|
||||
if (checkDuplicates && $data(this, dataLazied)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $el = $(this);
|
||||
|
||||
$el
|
||||
.data(dataLazied, 1)
|
||||
.removeClass(classNojs);
|
||||
|
||||
if (blankImage && $el[0].tagName === 'IMG' && !$el.attr('src')) {
|
||||
$el.attr('src', blankImage);
|
||||
}
|
||||
|
||||
// clone elementOptionsOverrides object
|
||||
$el.lazyLoadXT = $.extend({}, elementOptionsOverrides);
|
||||
|
||||
triggerEvent('init', $el);
|
||||
|
||||
elements.unshift($el); // push it in the first position as we iterate elements in reverse order
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Save visible viewport boundary to viewportXXX variables
|
||||
*/
|
||||
function calcViewport() {
|
||||
viewportTop = $window.scrollTop();
|
||||
viewportBottom = viewportTop + (window.innerHeight || $window.height());
|
||||
|
||||
viewportLeft = window.pageXOffset || 0;
|
||||
viewportRight = viewportLeft + (window.innerWidth || $window.width());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process function/object event handler
|
||||
* @param {string} event suffix
|
||||
* @param {jQuery} $el
|
||||
*/
|
||||
function triggerEvent(event, $el) {
|
||||
$el.trigger('lazy' + event, [$el]);
|
||||
|
||||
var handler = options['on' + event];
|
||||
if (handler) {
|
||||
if ($.isFunction(handler)) {
|
||||
handler.call($el[0]);
|
||||
} else {
|
||||
$el
|
||||
.addClass(handler.addClass)
|
||||
.removeClass(handler.removeClass);
|
||||
}
|
||||
}
|
||||
|
||||
// queue next check as images may be resized after loading of actual file
|
||||
queueCheckLazyElements();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trigger onload/onerror handler
|
||||
* @param {Event} e
|
||||
*/
|
||||
function triggerLoadOrError(e) {
|
||||
triggerEvent(e.type, $(this).off('load error', triggerLoadOrError));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load visible elements
|
||||
* @param {bool} [force] loading of all elements
|
||||
*/
|
||||
function checkLazyElements(force) {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
force = force || autoLoad;
|
||||
|
||||
topLazy = Infinity;
|
||||
calcViewport();
|
||||
|
||||
for (var i = elements.length - 1; i >= 0; i--) {
|
||||
var $el = elements[i],
|
||||
el = $el[0],
|
||||
objData = $el.lazyLoadXT;
|
||||
|
||||
// remove items that are not in DOM
|
||||
if (!$.contains(document.documentElement, el)) {
|
||||
elements.splice(i, 1);
|
||||
} else if (force || !objData.visibleOnly || el.offsetWidth > 0 || el.offsetHeight > 0) {
|
||||
var offset = $el.offset(),
|
||||
elTop = offset.top,
|
||||
elLeft = offset.left,
|
||||
edgeX = objData.edgeX,
|
||||
edgeY = objData.edgeY,
|
||||
topEdge = elTop - edgeY;
|
||||
|
||||
if (force ||
|
||||
((topEdge <= viewportBottom) && (elTop + $el.height() > viewportTop - edgeY) &&
|
||||
(elLeft <= viewportRight + edgeX) && (elLeft + $el.width() > viewportLeft - edgeX))) {
|
||||
|
||||
triggerEvent('show', $el);
|
||||
|
||||
var srcAttr = objData.srcAttr,
|
||||
src = $.isFunction(srcAttr) ? srcAttr($el) : $el.attr(srcAttr);
|
||||
if (src) {
|
||||
$el
|
||||
.on('load error', triggerLoadOrError)
|
||||
.attr('src', src);
|
||||
}
|
||||
|
||||
elements.splice(i, 1);
|
||||
} else {
|
||||
if (topEdge < topLazy) {
|
||||
topLazy = topEdge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!elements.length) {
|
||||
$(document).trigger('lazyloadall');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run check of lazy elements after timeout
|
||||
*/
|
||||
function timeoutLazyElements() {
|
||||
if (waitingMode > 1) {
|
||||
waitingMode = 1;
|
||||
checkLazyElements();
|
||||
setTimeout(timeoutLazyElements, options.throttle);
|
||||
} else {
|
||||
waitingMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Queue check of lazy elements because of event e
|
||||
* @param {Event} [e]
|
||||
*/
|
||||
function queueCheckLazyElements(e) {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fast check for scroll event without new visible elements
|
||||
if (e && e.type === 'scroll') {
|
||||
calcViewport();
|
||||
if (topLazy >= viewportBottom) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!waitingMode) {
|
||||
setTimeout(timeoutLazyElements, 0);
|
||||
}
|
||||
|
||||
waitingMode = 2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize list of hidden elements
|
||||
*/
|
||||
function initLazyElements() {
|
||||
$window.lazyLoadXT();
|
||||
queueCheckLazyElements();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loading of all elements
|
||||
*/
|
||||
function forceLoadAll() {
|
||||
checkLazyElements(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$window
|
||||
.on(options.loadEvent, initLazyElements)
|
||||
.on(options.updateEvent, queueCheckLazyElements)
|
||||
.on(options.forceEvent, forceLoadAll);
|
||||
|
||||
if (options.autoInit) {
|
||||
initLazyElements(); // standard initialization
|
||||
}
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
|
||||
|
||||
(function ($) {
|
||||
var options = $.lazyLoadXT;
|
||||
|
||||
options.selector += ',video,iframe[data-src]';
|
||||
options.videoPoster = 'data-poster';
|
||||
|
||||
$(document).on('lazyshow', 'video', function (e, $el) {
|
||||
var srcAttr = $el.lazyLoadXT.srcAttr,
|
||||
isFuncSrcAttr = $.isFunction(srcAttr);
|
||||
|
||||
$el
|
||||
.attr('poster', $el.attr(options.videoPoster))
|
||||
.children('source,track')
|
||||
.each(function () {
|
||||
var $child = $(this);
|
||||
$child.attr('src', isFuncSrcAttr ? srcAttr($child) : $child.attr(srcAttr));
|
||||
});
|
||||
|
||||
// reload video
|
||||
this.load();
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c,d){function e(){m=t.scrollTop(),n=m+(b.innerHeight||t.height()),o=b.pageXOffset||0,p=o+(b.innerWidth||t.width())}function f(b,c){c.trigger("lazy"+b,[c]);var d=q["on"+b];d&&(a.isFunction(d)?d.call(c[0]):c.addClass(d.addClass).removeClass(d.removeClass)),j()}function g(b){f(b.type,a(this).off("load error",g))}function h(b){if(v.length){b=b||s,x=1/0,e();for(var d=v.length-1;d>=0;d--){var h=v[d],i=h[0],j=h.lazyLoadXT;if(a.contains(c.documentElement,i)){if(b||!j.visibleOnly||i.offsetWidth>0||i.offsetHeight>0){var k=h.offset(),l=k.top,q=k.left,r=j.edgeX,t=j.edgeY,u=l-t;if(b||n>=u&&l+h.height()>m-t&&p+r>=q&&q+h.width()>o-r){f("show",h);var w=j.srcAttr,y=a.isFunction(w)?w(h):h.attr(w);y&&h.on("load error",g).attr("src",y),v.splice(d,1)}else x>u&&(x=u)}}else v.splice(d,1)}v.length||a(c).trigger("lazyloadall")}}function i(){y>1?(y=1,h(),setTimeout(i,q.throttle)):y=0}function j(a){v.length&&(a&&"scroll"===a.type&&(e(),x>=n)||(y||setTimeout(i,0),y=2))}function k(){t.lazyLoadXT(),j()}function l(){h(!0)}var m,n,o,p,q={autoInit:!0,selector:"img",classNojs:"lazy",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove",forceEvent:"",oninit:null,onshow:null,onload:null,onerror:null},r={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},s=b.onscroll===d||!!b.operamini,t=a(b),u="lazied",v=[],w=a.data||function(b,c){return a(b).data(c)},x=0,y=0;a.lazyLoadXT=a.extend(q,r,a.lazyLoadXT),a.fn.lazyLoadXT=function(c){c=c||{};var e,g={},h=c.blankImage||q.blankImage,i=c.classNojs||q.classNojs,j=c.checkDuplicates||!0;for(e in r)g[e]=c[e]===d?q[e]:c[e];return this.each(function(){if(this===b)a(q.selector).lazyLoadXT(c);else{if(j&&w(this,u))return;var d=a(this);d.data(u,1).removeClass(i),h&&"IMG"===d[0].tagName&&!d.attr("src")&&d.attr("src",h),d.lazyLoadXT=a.extend({},g),f("init",d),v.unshift(d)}})},a(c).ready(function(){t.on(q.loadEvent,k).on(q.updateEvent,j).on(q.forceEvent,l),q.autoInit&&k()})}(window.jQuery||window.Zepto,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);d.attr("poster",d.attr(b.videoPoster)).children("source,track").each(function(){var b=a(this);b.attr("src",f?e(b):b.attr(e))}),this.load()})}(window.jQuery||window.Zepto);
|
||||
@@ -0,0 +1,273 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document, undefined) {
|
||||
// options
|
||||
var options = {
|
||||
autoInit: true,
|
||||
selector: 'img',
|
||||
classNojs: 'lazy',
|
||||
blankImage: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
|
||||
throttle: 99,
|
||||
loadEvent: 'pageshow', // check AJAX-loaded content in jQueryMobile
|
||||
updateEvent: 'load orientationchange resize scroll touchmove', // page-modified events
|
||||
forceEvent: '', // force loading of all elements
|
||||
oninit: null, // init handler
|
||||
onshow: null, // start loading handler
|
||||
onload: null, // load success handler
|
||||
onerror: null // error handler
|
||||
},
|
||||
elementOptions = {
|
||||
srcAttr: 'data-src',
|
||||
edgeX: 0,
|
||||
edgeY: 0,
|
||||
visibleOnly: true
|
||||
},
|
||||
// autoload all images in Opera Mini and some mobile browsers without scroll event
|
||||
autoLoad = (window.onscroll === undefined || !!window.operamini),
|
||||
$window = $(window),
|
||||
dataLazied = 'lazied',
|
||||
elements = [],
|
||||
viewportTop,
|
||||
viewportBottom,
|
||||
viewportLeft,
|
||||
viewportRight,
|
||||
$data = $.data || function (el, name) {
|
||||
return $(el).data(name);
|
||||
},
|
||||
topLazy = 0,
|
||||
/*
|
||||
waitingMode=0 : no setTimeout
|
||||
waitingMode=1 : setTimeout, no deferred events
|
||||
waitingMode=2 : setTimeout, deferred events
|
||||
*/
|
||||
waitingMode = 0;
|
||||
|
||||
$.lazyLoadXT = $.extend(options, elementOptions, $.lazyLoadXT);
|
||||
|
||||
/**
|
||||
* Add new elements to lazy-load list:
|
||||
* $(elements).lazyLoadXT() or $(window).lazyLoadXT()
|
||||
*
|
||||
* @param {object} [overrides] loading of all elements
|
||||
*/
|
||||
$.fn.lazyLoadXT = function (overrides) {
|
||||
overrides = overrides || {};
|
||||
|
||||
var elementOptionsOverrides = {},
|
||||
blankImage = overrides.blankImage || options.blankImage,
|
||||
classNojs = overrides.classNojs || options.classNojs,
|
||||
checkDuplicates = overrides.checkDuplicates || true,
|
||||
prop;
|
||||
|
||||
for (prop in elementOptions) {
|
||||
elementOptionsOverrides[prop] = (overrides[prop] === undefined) ? options[prop] : overrides[prop];
|
||||
}
|
||||
|
||||
return this.each(function () {
|
||||
if (this === window) {
|
||||
$(options.selector).lazyLoadXT(overrides);
|
||||
} else {
|
||||
// prevent duplicates
|
||||
if (checkDuplicates && $data(this, dataLazied)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $el = $(this);
|
||||
|
||||
$el
|
||||
.data(dataLazied, 1)
|
||||
.removeClass(classNojs);
|
||||
|
||||
if (blankImage && $el[0].tagName === 'IMG' && !$el.attr('src')) {
|
||||
$el.attr('src', blankImage);
|
||||
}
|
||||
|
||||
// clone elementOptionsOverrides object
|
||||
$el.lazyLoadXT = $.extend({}, elementOptionsOverrides);
|
||||
|
||||
triggerEvent('init', $el);
|
||||
|
||||
elements.unshift($el); // push it in the first position as we iterate elements in reverse order
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Save visible viewport boundary to viewportXXX variables
|
||||
*/
|
||||
function calcViewport() {
|
||||
viewportTop = $window.scrollTop();
|
||||
viewportBottom = viewportTop + (window.innerHeight || $window.height());
|
||||
|
||||
viewportLeft = window.pageXOffset || 0;
|
||||
viewportRight = viewportLeft + (window.innerWidth || $window.width());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process function/object event handler
|
||||
* @param {string} event suffix
|
||||
* @param {jQuery} $el
|
||||
*/
|
||||
function triggerEvent(event, $el) {
|
||||
$el.trigger('lazy' + event, [$el]);
|
||||
|
||||
var handler = options['on' + event];
|
||||
if (handler) {
|
||||
if ($.isFunction(handler)) {
|
||||
handler.call($el[0]);
|
||||
} else {
|
||||
$el
|
||||
.addClass(handler.addClass)
|
||||
.removeClass(handler.removeClass);
|
||||
}
|
||||
}
|
||||
|
||||
// queue next check as images may be resized after loading of actual file
|
||||
queueCheckLazyElements();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trigger onload/onerror handler
|
||||
* @param {Event} e
|
||||
*/
|
||||
function triggerLoadOrError(e) {
|
||||
triggerEvent(e.type, $(this).off('load error', triggerLoadOrError));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load visible elements
|
||||
* @param {bool} [force] loading of all elements
|
||||
*/
|
||||
function checkLazyElements(force) {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
force = force || autoLoad;
|
||||
|
||||
topLazy = Infinity;
|
||||
calcViewport();
|
||||
|
||||
for (var i = elements.length - 1; i >= 0; i--) {
|
||||
var $el = elements[i],
|
||||
el = $el[0],
|
||||
objData = $el.lazyLoadXT;
|
||||
|
||||
// remove items that are not in DOM
|
||||
if (!$.contains(document.documentElement, el)) {
|
||||
elements.splice(i, 1);
|
||||
} else if (force || !objData.visibleOnly || el.offsetWidth > 0 || el.offsetHeight > 0) {
|
||||
var offset = $el.offset(),
|
||||
elTop = offset.top,
|
||||
elLeft = offset.left,
|
||||
edgeX = objData.edgeX,
|
||||
edgeY = objData.edgeY,
|
||||
topEdge = elTop - edgeY;
|
||||
|
||||
if (force ||
|
||||
((topEdge <= viewportBottom) && (elTop + $el.height() > viewportTop - edgeY) &&
|
||||
(elLeft <= viewportRight + edgeX) && (elLeft + $el.width() > viewportLeft - edgeX))) {
|
||||
|
||||
triggerEvent('show', $el);
|
||||
|
||||
var srcAttr = objData.srcAttr,
|
||||
src = $.isFunction(srcAttr) ? srcAttr($el) : $el.attr(srcAttr);
|
||||
if (src) {
|
||||
$el
|
||||
.on('load error', triggerLoadOrError)
|
||||
.attr('src', src);
|
||||
}
|
||||
|
||||
elements.splice(i, 1);
|
||||
} else {
|
||||
if (topEdge < topLazy) {
|
||||
topLazy = topEdge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!elements.length) {
|
||||
$(document).trigger('lazyloadall');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run check of lazy elements after timeout
|
||||
*/
|
||||
function timeoutLazyElements() {
|
||||
if (waitingMode > 1) {
|
||||
waitingMode = 1;
|
||||
checkLazyElements();
|
||||
setTimeout(timeoutLazyElements, options.throttle);
|
||||
} else {
|
||||
waitingMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Queue check of lazy elements because of event e
|
||||
* @param {Event} [e]
|
||||
*/
|
||||
function queueCheckLazyElements(e) {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fast check for scroll event without new visible elements
|
||||
if (e && e.type === 'scroll') {
|
||||
calcViewport();
|
||||
if (topLazy >= viewportBottom) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!waitingMode) {
|
||||
setTimeout(timeoutLazyElements, 0);
|
||||
}
|
||||
|
||||
waitingMode = 2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize list of hidden elements
|
||||
*/
|
||||
function initLazyElements() {
|
||||
$window.lazyLoadXT();
|
||||
queueCheckLazyElements();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loading of all elements
|
||||
*/
|
||||
function forceLoadAll() {
|
||||
checkLazyElements(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$window
|
||||
.on(options.loadEvent, initLazyElements)
|
||||
.on(options.updateEvent, queueCheckLazyElements)
|
||||
.on(options.forceEvent, forceLoadAll);
|
||||
|
||||
if (options.autoInit) {
|
||||
initLazyElements(); // standard initialization
|
||||
}
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c,d){function e(){m=t.scrollTop(),n=m+(b.innerHeight||t.height()),o=b.pageXOffset||0,p=o+(b.innerWidth||t.width())}function f(b,c){c.trigger("lazy"+b,[c]);var d=q["on"+b];d&&(a.isFunction(d)?d.call(c[0]):c.addClass(d.addClass).removeClass(d.removeClass)),j()}function g(b){f(b.type,a(this).off("load error",g))}function h(b){if(v.length){b=b||s,x=1/0,e();for(var d=v.length-1;d>=0;d--){var h=v[d],i=h[0],j=h.lazyLoadXT;if(a.contains(c.documentElement,i)){if(b||!j.visibleOnly||i.offsetWidth>0||i.offsetHeight>0){var k=h.offset(),l=k.top,q=k.left,r=j.edgeX,t=j.edgeY,u=l-t;if(b||n>=u&&l+h.height()>m-t&&p+r>=q&&q+h.width()>o-r){f("show",h);var w=j.srcAttr,y=a.isFunction(w)?w(h):h.attr(w);y&&h.on("load error",g).attr("src",y),v.splice(d,1)}else x>u&&(x=u)}}else v.splice(d,1)}v.length||a(c).trigger("lazyloadall")}}function i(){y>1?(y=1,h(),setTimeout(i,q.throttle)):y=0}function j(a){v.length&&(a&&"scroll"===a.type&&(e(),x>=n)||(y||setTimeout(i,0),y=2))}function k(){t.lazyLoadXT(),j()}function l(){h(!0)}var m,n,o,p,q={autoInit:!0,selector:"img",classNojs:"lazy",blankImage:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",throttle:99,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll touchmove",forceEvent:"",oninit:null,onshow:null,onload:null,onerror:null},r={srcAttr:"data-src",edgeX:0,edgeY:0,visibleOnly:!0},s=b.onscroll===d||!!b.operamini,t=a(b),u="lazied",v=[],w=a.data||function(b,c){return a(b).data(c)},x=0,y=0;a.lazyLoadXT=a.extend(q,r,a.lazyLoadXT),a.fn.lazyLoadXT=function(c){c=c||{};var e,g={},h=c.blankImage||q.blankImage,i=c.classNojs||q.classNojs,j=c.checkDuplicates||!0;for(e in r)g[e]=c[e]===d?q[e]:c[e];return this.each(function(){if(this===b)a(q.selector).lazyLoadXT(c);else{if(j&&w(this,u))return;var d=a(this);d.data(u,1).removeClass(i),h&&"IMG"===d[0].tagName&&!d.attr("src")&&d.attr("src",h),d.lazyLoadXT=a.extend({},g),f("init",d),v.unshift(d)}})},a(c).ready(function(){t.on(q.loadEvent,k).on(q.updateEvent,j).on(q.forceEvent,l),q.autoInit&&k()})}(window.jQuery||window.Zepto,window,document);
|
||||
@@ -0,0 +1,64 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document) {
|
||||
var options = $.lazyLoadXT,
|
||||
matchMedia = window.matchMedia;
|
||||
|
||||
options.selector += ',picture';
|
||||
|
||||
$(document)
|
||||
// remove default behaviour for inner <img> tag
|
||||
.on('lazyinit', 'img', function (e, $el) {
|
||||
if ($el.parent('picture').length) {
|
||||
$el.lazyLoadXT.srcAttr = '';
|
||||
}
|
||||
})
|
||||
// prepare <picture> polyfill
|
||||
.on('lazyinit', 'picture', function (e, $el) {
|
||||
if (!$el[0].firstChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $img = $el.children('img');
|
||||
if (!$img.length) {
|
||||
$img = $('<img>').appendTo($el);
|
||||
}
|
||||
|
||||
$img
|
||||
.attr('width', $el.attr('width'))
|
||||
.attr('height', $el.attr('height'));
|
||||
})
|
||||
// show picture
|
||||
.on('lazyshow', 'picture', function (e, $el) {
|
||||
if (!$el[0].firstChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
var srcAttr = $el.lazyLoadXT.srcAttr,
|
||||
isFuncSrcAttr = $.isFunction(srcAttr),
|
||||
$img = $el.children('img'),
|
||||
src = isFuncSrcAttr ? srcAttr($img) : $img.attr(srcAttr);
|
||||
|
||||
if (src) {
|
||||
$img.attr('src', src);
|
||||
}
|
||||
|
||||
if (matchMedia) {
|
||||
$el
|
||||
.children('br')
|
||||
.each(function () {
|
||||
var $child = $(this),
|
||||
src = isFuncSrcAttr ? srcAttr($child) : $child.attr(srcAttr),
|
||||
media = $child.attr('media');
|
||||
|
||||
if (src && (!media || matchMedia(media).matches)) {
|
||||
$img.attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c){var d=a.lazyLoadXT,e=b.matchMedia;d.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("<img>").appendTo(c)),d.attr("width",c.attr("width")).attr("height",c.attr("height"))}}).on("lazyshow","picture",function(b,c){if(c[0].firstChild){var d=c.lazyLoadXT.srcAttr,f=a.isFunction(d),g=c.children("img"),h=f?d(g):g.attr(d);h&&g.attr("src",h),e&&c.children("br").each(function(){var b=a(this),c=f?d(b):b.attr(d),h=b.attr("media");!c||h&&!e(h).matches||g.attr("src",c)})}})}(window.jQuery||window.Zepto,window,document);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window) {
|
||||
$.lazyLoadXT.forceEvent += ' beforeprint';
|
||||
|
||||
if (window.matchMedia) {
|
||||
window
|
||||
.matchMedia('print')
|
||||
.addListener(function (mql) {
|
||||
if (mql.matches) {
|
||||
$(window).trigger('beforeprint');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})(window.jQuery || window.Zepto, window);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | 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);
|
||||
@@ -0,0 +1,59 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document) {
|
||||
var options = $.lazyLoadXT,
|
||||
dataLazyTag = options.dataLazyTag || 'data-lazy-tag';
|
||||
|
||||
window.L = function (tag) {
|
||||
document.write('<br ' + dataLazyTag + '="' + (tag || 'img') + '" ');
|
||||
};
|
||||
|
||||
window.Lb = function (tag) {
|
||||
document.write('<span ' + dataLazyTag + '="' + (tag || 'video') + '" ');
|
||||
};
|
||||
|
||||
window.Le = function () {
|
||||
document.write('</span>');
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
var srcAttr = options.srcAttr;
|
||||
if ($.isFunction(srcAttr)) {
|
||||
srcAttr = 'data-src';
|
||||
}
|
||||
|
||||
$('br[' + dataLazyTag + '],span[' + dataLazyTag + ']').each(function () {
|
||||
var attrs = this.attributes,
|
||||
el = document.createElement($(this).attr(dataLazyTag)),
|
||||
i;
|
||||
|
||||
for (i = 0; i < attrs.length; i++) {
|
||||
var attr = attrs[i];
|
||||
if (attr.specified) {
|
||||
var attrName = attr.nodeName,
|
||||
attrValue = attr.nodeValue;
|
||||
if (attrName.charAt(0) !== '<') {
|
||||
if (attrName === 'src') {
|
||||
el.setAttribute(srcAttr, attrValue);
|
||||
} else {
|
||||
el.setAttribute(attrName, attrValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (this.hasChildNodes()) {
|
||||
var child = this.removeChild(this.firstChild);
|
||||
el.appendChild(child);
|
||||
}
|
||||
|
||||
this.parentNode.replaceChild(el, this);
|
||||
});
|
||||
|
||||
$(window).lazyLoadXT();
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c){var d=a.lazyLoadXT,e=d.dataLazyTag||"data-lazy-tag";b.L=function(a){c.write("<br "+e+'="'+(a||"img")+'" ')},b.Lb=function(a){c.write("<span "+e+'="'+(a||"video")+'" ')},b.Le=function(){c.write("</span>")},a(c).ready(function(){var f=d.srcAttr;a.isFunction(f)&&(f="data-src"),a("br["+e+"],span["+e+"]").each(function(){var b,d=this.attributes,g=c.createElement(a(this).attr(e));for(b=0;b<d.length;b++){var h=d[b];if(h.specified){var i=h.nodeName,j=h.nodeValue;"<"!==i.charAt(0)&&("src"===i?g.setAttribute(f,j):g.setAttribute(i,j))}}for(;this.hasChildNodes();){var k=this.removeChild(this.firstChild);g.appendChild(k)}this.parentNode.replaceChild(g,this)}),a(b).lazyLoadXT()})}(window.jQuery||window.Zepto,window,document);
|
||||
@@ -0,0 +1,185 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document) {
|
||||
// options
|
||||
var options = {
|
||||
selector: 'img',
|
||||
srcAttr: 'data-src',
|
||||
classNojs: 'lazy',
|
||||
edgeX: 0,
|
||||
edgeY: 0,
|
||||
throttle: 99,
|
||||
visibleOnly: true,
|
||||
loadEvent: 'pageshow', // check AJAX-loaded content in jQueryMobile
|
||||
updateEvent: 'load orientationchange resize scroll' // page-modified events
|
||||
},
|
||||
$window = $(window),
|
||||
elements = [],
|
||||
viewportTop,
|
||||
viewportBottom,
|
||||
viewportLeft,
|
||||
viewportRight,
|
||||
topLazy = 0,
|
||||
/*
|
||||
waitingMode=0 : no setTimeout
|
||||
waitingMode=1 : setTimeout, no deferred events
|
||||
waitingMode=2 : setTimeout, deferred events
|
||||
*/
|
||||
waitingMode = 0;
|
||||
|
||||
$.lazyLoadXT = $.extend(options, $.lazyLoadXT);
|
||||
|
||||
/**
|
||||
* Add new elements to lazy-load list:
|
||||
* $(elements).lazyLoadXT() or $(window).lazyLoadXT()
|
||||
*/
|
||||
$.fn.lazyLoadXT = function () {
|
||||
this.each(function () {
|
||||
if (this === window) {
|
||||
$(options.selector).lazyLoadXT();
|
||||
return;
|
||||
}
|
||||
|
||||
var $el = $(this);
|
||||
|
||||
// prevent duplicates
|
||||
if ($el.data('lazied')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$el
|
||||
.data('lazied', 1)
|
||||
.removeClass(options.classNojs);
|
||||
|
||||
elements.unshift($el); // push it in the first position as we iterate elements in reverse order
|
||||
});
|
||||
|
||||
// queue next check as images may be resized after loading of actual file
|
||||
queueCheckLazyElements();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Save visible viewport boundary to viewportXXX variables
|
||||
*/
|
||||
function calcViewport() {
|
||||
var scrollTop = $window.scrollTop(),
|
||||
scrollLeft = window.pageXOffset || 0,
|
||||
edgeX = options.edgeX,
|
||||
edgeY = options.edgeY;
|
||||
|
||||
viewportTop = scrollTop - edgeY;
|
||||
viewportBottom = scrollTop + (window.innerHeight || $window.height()) + edgeY;
|
||||
viewportLeft = scrollLeft - edgeX;
|
||||
viewportRight = scrollLeft + (window.innerWidth || $window.width()) + edgeX;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load visible elements
|
||||
*/
|
||||
function checkLazyElements() {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
topLazy = Infinity;
|
||||
calcViewport();
|
||||
|
||||
var i = elements.length - 1,
|
||||
srcAttr = options.srcAttr;
|
||||
for (; i >= 0; i--) {
|
||||
var $el = elements[i],
|
||||
el = $el[0];
|
||||
|
||||
// remove items that are not in DOM
|
||||
if (!$.contains(document.documentElement, el)) {
|
||||
elements.splice(i, 1);
|
||||
} else if (!options.visibleOnly || el.offsetWidth > 0 || el.offsetHeight > 0) {
|
||||
var offset = $el.offset(),
|
||||
elTop = offset.top,
|
||||
elLeft = offset.left;
|
||||
|
||||
if ((elTop < viewportBottom) && (elTop + $el.height() > viewportTop) &&
|
||||
(elLeft < viewportRight) && (elLeft + $el.width() > viewportLeft)) {
|
||||
|
||||
var src = $el.attr(srcAttr);
|
||||
if (src) {
|
||||
$el.attr('src', src);
|
||||
}
|
||||
|
||||
elements.splice(i, 1);
|
||||
} else {
|
||||
if (elTop < topLazy) {
|
||||
topLazy = elTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run check of lazy elements after timeout
|
||||
*/
|
||||
function timeoutLazyElements() {
|
||||
if (waitingMode > 1) {
|
||||
waitingMode = 1;
|
||||
checkLazyElements();
|
||||
setTimeout(timeoutLazyElements, options.throttle);
|
||||
} else {
|
||||
waitingMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Queue check of lazy elements because of event e
|
||||
* @param {Event} [e]
|
||||
*/
|
||||
function queueCheckLazyElements(e) {
|
||||
if (!elements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fast check for scroll event without new visible elements
|
||||
if (e && e.type === 'scroll') {
|
||||
calcViewport();
|
||||
if (topLazy >= viewportBottom) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!waitingMode) {
|
||||
setTimeout(timeoutLazyElements, 0);
|
||||
}
|
||||
|
||||
waitingMode = 2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize list of hidden elements
|
||||
*/
|
||||
function initLazyElements() {
|
||||
$(window).lazyLoadXT();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$window
|
||||
.on(options.loadEvent, initLazyElements)
|
||||
.on(options.updateEvent, queueCheckLazyElements);
|
||||
|
||||
initLazyElements(); // standard initialization
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c){function d(){var a=n.scrollTop(),c=b.pageXOffset||0,d=m.edgeX,e=m.edgeY;i=a-e,j=a+(b.innerHeight||n.height())+e,k=c-d,l=c+(b.innerWidth||n.width())+d}function e(){if(o.length){p=1/0,d();for(var b=o.length-1,e=m.srcAttr;b>=0;b--){var f=o[b],g=f[0];if(a.contains(c.documentElement,g)){if(!m.visibleOnly||g.offsetWidth>0||g.offsetHeight>0){var h=f.offset(),n=h.top,q=h.left;if(j>n&&n+f.height()>i&&l>q&&q+f.width()>k){var r=f.attr(e);r&&f.attr("src",r),o.splice(b,1)}else p>n&&(p=n)}}else o.splice(b,1)}}}function f(){q>1?(q=1,e(),setTimeout(f,m.throttle)):q=0}function g(a){o.length&&(a&&"scroll"===a.type&&(d(),p>=j)||(q||setTimeout(f,0),q=2))}function h(){a(b).lazyLoadXT()}var i,j,k,l,m={selector:"img",srcAttr:"data-src",classNojs:"lazy",edgeX:0,edgeY:0,throttle:99,visibleOnly:!0,loadEvent:"pageshow",updateEvent:"load orientationchange resize scroll"},n=a(b),o=[],p=0,q=0;a.lazyLoadXT=a.extend(m,a.lazyLoadXT),a.fn.lazyLoadXT=function(){return this.each(function(){if(this===b)return a(m.selector).lazyLoadXT(),void 0;var c=a(this);c.data("lazied")||(c.data("lazied",1).removeClass(m.classNojs),o.unshift(c))}),g(),this},a(c).ready(function(){n.on(m.loadEvent,h).on(m.updateEvent,g),h()})}(window.jQuery||window.Zepto,window,document);
|
||||
@@ -0,0 +1,102 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($, window, document, undefined) {
|
||||
var options = $.lazyLoadXT,
|
||||
srcsetSupport = (function () {
|
||||
return 'srcset' in (new Image());
|
||||
})(),
|
||||
reUrl = /^\s*(\S*)/,
|
||||
reWidth = /\S\s+(\d+)w/,
|
||||
reHeight = /\S\s+(\d+)h/,
|
||||
reDpr = /\S\s+([\d\.]+)x/,
|
||||
infty = [0, Infinity],
|
||||
one = [0, 1],
|
||||
srcsetOptions = {
|
||||
srcsetAttr: 'data-srcset',
|
||||
srcsetExtended: true,
|
||||
srcsetBaseAttr: 'data-srcset-base',
|
||||
srcsetExtAttr: 'data-srcset-ext'
|
||||
},
|
||||
viewport = {
|
||||
w: 0,
|
||||
h: 0,
|
||||
x: 0
|
||||
},
|
||||
property,
|
||||
limit;
|
||||
|
||||
for (property in srcsetOptions) {
|
||||
if (options[property] === undefined) {
|
||||
options[property] = srcsetOptions[property];
|
||||
}
|
||||
}
|
||||
|
||||
function mathFilter(array, action) {
|
||||
return Math[action].apply(null, $.map(array, function (item) {
|
||||
return item[property];
|
||||
}));
|
||||
}
|
||||
|
||||
function compareMax(item) {
|
||||
return item[property] >= viewport[property] || item[property] === limit;
|
||||
}
|
||||
|
||||
function compareMin(item) {
|
||||
return item[property] === limit;
|
||||
}
|
||||
|
||||
$(document).on('lazyshow', 'img', function (e, $el) {
|
||||
var srcset = $el.attr(options.srcsetAttr);
|
||||
|
||||
if (srcset) {
|
||||
if (!options.srcsetExtended && srcsetSupport) {
|
||||
$el.attr('srcset', srcset);
|
||||
} else {
|
||||
var list = srcset.split(',').map(function (item) {
|
||||
return {
|
||||
url: reUrl.exec(item)[1],
|
||||
w: parseFloat((reWidth.exec(item) || infty)[1]),
|
||||
h: parseFloat((reHeight.exec(item) || infty)[1]),
|
||||
x: parseFloat((reDpr.exec(item) || one)[1])
|
||||
};
|
||||
});
|
||||
|
||||
if (list.length) {
|
||||
var documentElement = document.documentElement,
|
||||
whx,
|
||||
src;
|
||||
|
||||
viewport = {
|
||||
w: window.innerWidth || documentElement.clientWidth,
|
||||
h: window.innerHeight || documentElement.clientHeight,
|
||||
x: window.devicePixelRatio || 1
|
||||
};
|
||||
|
||||
for (whx in viewport) {
|
||||
property = whx;
|
||||
limit = mathFilter(list, 'max');
|
||||
list = $.grep(list, compareMax);
|
||||
}
|
||||
|
||||
for (whx in viewport) {
|
||||
property = whx;
|
||||
limit = mathFilter(list, 'min');
|
||||
list = $.grep(list, compareMin);
|
||||
}
|
||||
|
||||
src = list[0].url;
|
||||
|
||||
if (options.srcsetExtended) {
|
||||
src = ($el.attr(options.srcsetBaseAttr) || '') + src + ($el.attr(options.srcsetExtAttr) || '');
|
||||
}
|
||||
|
||||
$el.attr('src', src);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a,b,c,d){function e(b,c){return Math[c].apply(null,a.map(b,function(a){return a[h]}))}function f(a){return a[h]>=s[h]||a[h]===i}function g(a){return a[h]===i}var h,i,j=a.lazyLoadXT,k=function(){return"srcset"in new Image}(),l=/^\s*(\S*)/,m=/\S\s+(\d+)w/,n=/\S\s+(\d+)h/,o=/\S\s+([\d\.]+)x/,p=[0,1/0],q=[0,1],r={srcsetAttr:"data-srcset",srcsetExtended:!0,srcsetBaseAttr:"data-srcset-base",srcsetExtAttr:"data-srcset-ext"},s={w:0,h:0,x:0};for(h in r)j[h]===d&&(j[h]=r[h]);a(c).on("lazyshow","img",function(d,r){var t=r.attr(j.srcsetAttr);if(t)if(!j.srcsetExtended&&k)r.attr("srcset",t);else{var u=t.split(",").map(function(a){return{url:l.exec(a)[1],w:parseFloat((m.exec(a)||p)[1]),h:parseFloat((n.exec(a)||p)[1]),x:parseFloat((o.exec(a)||q)[1])}});if(u.length){var v,w,x=c.documentElement;s={w:b.innerWidth||x.clientWidth,h:b.innerHeight||x.clientHeight,x:b.devicePixelRatio||1};for(v in s)h=v,i=e(u,"max"),u=a.grep(u,f);for(v in s)h=v,i=e(u,"min"),u=a.grep(u,g);w=u[0].url,j.srcsetExtended&&(w=(r.attr(j.srcsetBaseAttr)||"")+w+(r.attr(j.srcsetExtAttr)||"")),r.attr("src",w)}}})}(window.jQuery||window.Zepto,window,document);
|
||||
@@ -0,0 +1,28 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($) {
|
||||
var options = $.lazyLoadXT;
|
||||
|
||||
options.selector += ',video,iframe[data-src]';
|
||||
options.videoPoster = 'data-poster';
|
||||
|
||||
$(document).on('lazyshow', 'video', function (e, $el) {
|
||||
var srcAttr = $el.lazyLoadXT.srcAttr,
|
||||
isFuncSrcAttr = $.isFunction(srcAttr);
|
||||
|
||||
$el
|
||||
.attr('poster', $el.attr(options.videoPoster))
|
||||
.children('source,track')
|
||||
.each(function () {
|
||||
var $child = $(this);
|
||||
$child.attr('src', isFuncSrcAttr ? srcAttr($child) : $child.attr(srcAttr));
|
||||
});
|
||||
|
||||
// reload video
|
||||
this.load();
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | 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);d.attr("poster",d.attr(b.videoPoster)).children("source,track").each(function(){var b=a(this);b.attr("src",f?e(b):b.attr(e))}),this.load()})}(window.jQuery||window.Zepto);
|
||||
@@ -0,0 +1,30 @@
|
||||
/*! Lazy Load XT v0.8.11 2014-01-10
|
||||
* http://ressio.github.io/lazy-load-xt
|
||||
* (C) 2014 RESS.io
|
||||
* Licensed under MIT */
|
||||
|
||||
(function ($) {
|
||||
var options = $.lazyLoadXT,
|
||||
widgetAttr = options.widgetAttr || 'data-lazy-widget',
|
||||
reComment = /<!--([\s\S]*)-->/;
|
||||
|
||||
options.selector += ',[' + widgetAttr + ']';
|
||||
|
||||
$(document).on('lazyshow', '[' + widgetAttr + ']', function () {
|
||||
var $this = $(this),
|
||||
id = $this.attr(widgetAttr),
|
||||
match;
|
||||
|
||||
if (id) {
|
||||
$this = $('#' + id);
|
||||
}
|
||||
|
||||
if ($this.length) {
|
||||
match = reComment.exec($this.html());
|
||||
if (match) {
|
||||
$this.replaceWith($.trim(match[1]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(window.jQuery || window.Zepto);
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Lazy Load XT 0.8.11 | MIT License */
|
||||
!function(a){var b=a.lazyLoadXT,c=b.widgetAttr||"data-lazy-widget",d=/<!--([\s\S]*)-->/;b.selector+=",["+c+"]",a(document).on("lazyshow","["+c+"]",function(){var b,e=a(this),f=e.attr(c);f&&(e=a("#"+f)),e.length&&(b=d.exec(e.html()),b&&e.replaceWith(a.trim(b[1])))})}(window.jQuery||window.Zepto);
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jquery.lazyloadxt",
|
||||
"filename": "jquery.lazyloadxt.min.js",
|
||||
"version": "0.8.10",
|
||||
"version": "0.8.11",
|
||||
"description": "Lazy Load XT is mobile-oriented, fast and extensible jQuery plugin for lazy loading of images, videos and other media with built-in support of jQueryMobile framework. It improves performance of website by loading visible media elements only, and elements below the fold are loaded after page scroll. The plugin has many options, supports callbacks and special lazy events, that allows to have different loading effects (e.g. fade in and spinner effects). Examples of plugin and its addons include ajax, background images, infinite scroll, horizontal scroll, iframe-based widgets (YouTube, Vimeo, Google Maps Engine Lite, Facebook recommend button, Google+ profile), html5 video, responsive images with retina support (srcset and picture polyfills), social widgets (embedded tweet, Twitter share button, Google Plus badge and share button, Facebook like and recommend buttons, Facebook post comments), load all images before print, etc. Tested in IE 6-11, Chrome 1-31, Firefox 1.5-27.0, Safari 3-7, Opera 10.6-18.0, iOS 5-7, Android 2.3-4.4, and WP8. Requires jQuery 1.7+ or Zepto 1.0+.",
|
||||
"license": "MIT",
|
||||
"homepage": "http://ressio.github.io/lazy-load-xt",
|
||||
|
||||
Reference in New Issue
Block a user