summaryrefslogtreecommitdiff
path: root/static/jquery.lazy.min.js
blob: f58aa53f2c3f455d74288e316e5966ab6bb12891 (plain)
1
2
/*! jQuery Lazy 1.6.6 - MIT & GPL-2.0 license - Copyright 2012-2016 Daniel 'Eisbehr' Kern */
!function(e,t,a,r){"use strict";function n(a,r,n,o){function i(){p=t.devicePixelRatio>1,l(n),r("delay")>=0&&setTimeout(function(){u(!0)},r("delay")),(r("delay")<0||r("combined"))&&(o.e=m(r("throttle"),function(e){"resize"===e.type&&(b=v=-1),u(e.all)}),o.a=function(e){l(e),n.push.apply(n,e)},o.g=function(){return n=e(n).filter(function(){return!e(this).data(r("loadedName"))})},u(),e(r("appendScroll")).on("scroll."+a.name+" resize."+a.name,o.e))}function l(t){if(t=e(t).filter(function(){return!e(this).data(r("handledName"))&&(e(this).attr(r("attribute"))||e(this).attr(r("loaderAttribute")))}).data("plugin_"+a.name,a),r("defaultImage")||r("placeholder"))for(var n=0;n<t.length;n++){var o=e(t[n]),i=t[n].tagName.toLowerCase(),l="background-image";"img"==i&&r("defaultImage")&&!o.attr("src")?o.attr("src",r("defaultImage")):"img"==i||!r("placeholder")||o.css(l)&&"none"!=o.css(l)||o.css(l,"url("+r("placeholder")+")")}}function u(t){if(!n.length)return void(r("autoDestroy")&&a.destroy());for(var o=!1,i=r("imageBase")?r("imageBase"):"",l=0;l<n.length;l++)(function(a){if(c(a)||t){var n,l=e(a),u=a.tagName.toLowerCase(),f=l.attr(r("attribute"));l.data(r("handledName"))||r("visibleOnly")&&!l.is(":visible")||!(f&&("img"==u&&i+f!=l.attr("src")||"img"!=u&&i+f!=l.css("background-image"))||(n=l.attr(r("loaderAttribute"))))||(o=!0,l.data(r("handledName"),!0),d(l,u,i,n))}})(n[l]);o&&(n=e(n).filter(function(){return!e(this).data(r("loadedName"))}))}function d(t,a,n,o){++h;var i=function(){g("onError",t),A()};if(g("beforeLoad",t),o)t.off("error").one("error",i),t.one("load",function(){r("removeAttribute")&&t.removeAttr(r("loaderAttribute")),t.data(r("loadedName"),!0),g("afterLoad",t),A()}),g(o,t,function(e){e?t.load():t.error()})||t.error();else{var l=e(new Image);l.one("error",i),l.one("load",function(){t.hide(),"img"==a?t.attr("src",l.attr("src")):t.css("background-image","url('"+l.attr("src")+"')"),t[r("effect")](r("effectTime")),r("removeAttribute")&&t.removeAttr(r("attribute")+" "+r("retinaAttribute")),t.data(r("loadedName"),!0),g("afterLoad",t),l.remove(),A()}),l.attr("src",n+t.attr(r(p&&t.attr(r("retinaAttribute"))?"retinaAttribute":"attribute"))),l.complete&&l.load()}}function c(e){var t=e.getBoundingClientRect(),a=r("scrollDirection"),n=r("threshold"),o=s()+n>t.top&&-n<t.bottom,i=f()+n>t.left&&-n<t.right;return"vertical"==a?o:"horizontal"==a?i:o&&i}function f(){return b>=0?b:b=e(t).width()}function s(){return v>=0?v:v=e(t).height()}function m(e,t){var n,o=0;return function(i,l){function u(){o=+new Date,t.call(a,i)}var d=+new Date-o;n&&clearTimeout(n),d>e||!r("enableThrottle")||l?u():n=setTimeout(u,e-d)}}function A(){--h,n.size()||h||g("onFinishedAll")}function g(e,t,n){return(e=r(e))?(e.apply(a,[].slice.call(arguments,1)),!0):!1}var h=0,b=-1,v=-1,p=!1;!function(){"event"==r("bind")?i():e(t).on("load."+a.name,i)}()}function o(a,o){var i=this,l=e.extend({},i.configuration,o),u={};return i.config=function(e,t){return t===r?l[e]:(l[e]=t,i)},i.addItems=function(t){return u.a&&u.a("string"===e.type(t)?e(t):t),i},i.getItems=function(){return u.g?u.g():{}},i.update=function(e){return u.e&&u.e({},!e),i},i.loadAll=function(){return u.e&&u.e({all:!0},!0),i},i.destroy=function(){return e(i.config("appendScroll")).off("."+i.name,u.e),e(t).off("."+i.name),u={},r},n(i,i.config,a,u),i.config("chainable")?a:i}e.fn.Lazy=e.fn.lazy=function(e){return new o(this,e)},e.extend(o.prototype,{name:"lazy",configuration:{chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:t,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",retinaAttribute:"data-retina",loaderAttribute:"data-loader",removeAttribute:!0,handledName:"handled",loadedName:"loaded",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:null,afterLoad:null,onError:null,onFinishedAll:null}})}(jQuery,window,document);