forked from tubalmartin/riloadr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriloadr.jquery.min.js
4 lines (4 loc) · 3.41 KB
/
riloadr.jquery.min.js
1
2
3
4
/*!
* Riloadr.js 1.2.0 (c) 2012 Tubal Martin - MIT license
*/
!function(a){typeof define=="function"&&define.amd?define(["jquery"],a):window.Riloadr=a(jQuery)}(function(a){function T(b){function T(){ab(D,m,J),ab(D,n,K),M&&(S=D[x],ab(D,A,L))}function eb(){bb(D,m,J),bb(D,n,K),M&&bb(D,A,L)}function fb(a,b){a[q]=0,a[o]=gb,a[p]=hb,a.src=W(a,i,Q),O.splice(b,1)}function gb(){var a=this;a[o]=a[p]=f,a[t]=a[t].replace(u,"$1$2"),o in b&&b[o][h](a),ib()}function hb(){var a=this;p in b&&b[p][h](a),a[q]<G?(a[q]++,a.src=W(a,i,Q,c)):ib()}function ib(){P--,P==0&&v in b&&b[v]()}var g=this,i=b.base||k,j=b.breakpoints||_('"breakpoints" not defined.'),r=b.name||"responsive",u=new RegExp("(^|\\s)"+r+"(\\s|$)"),y=b.defer&&b.defer.toLowerCase()||d,z=b.foldDistance||100,F=b.ignoreLowBandwidth||d,G=b[q]||0,H=b.root||f,I=y==="belowfold"&&!R,J=I&&Y(function(){g[w]()},e),K=I&&Z(function(){g[w]()},e),L=I&&Z(function(){D[x]!==S&&(S=D[x],g[w]())},e),O=[],P=0,Q;g[w]=function(b){$(function(d,e){if(!O[l]||b===c)I&&T(),a("img."+r,H).each(function(a,b){b&&!b[s]&&(b[s]=c,O.push(b),P++)});if(O[l]){e=0;while(d=O[e])d&&(!I||I&&!X(d,z))&&(fb(d,e),e--),e++}I&&!O[l]&&eb(),d=f})},cb(function(){B=a(D),C=E.body,H=H&&a("#"+H)||C,N=N||V(),Q=U(j,N,F),!y||I?g[w]():db(g[w])})}function U(a,b,c){var d=k,e=b,f=0,g,h,i,j,l;while(g=a[f]){h=g.name,i=g.minWidth,j=g.maxWidth,l=g.minDevicePixelRatio;if(b>0){if(i&&j&&b>=i&&b<=j||i&&!j&&b>=i||j&&!i&&b<=j)if(!l||l&&P>=l&&(c||!c&&!Q))d=h}else if(e<=0||i<e||j<e)e=i||j||e,d=h;f++}return d+k}function V(){var a=Math,b=[F.clientWidth,F.offsetWidth,C.clientWidth],c=a.ceil(O/P),d=b[l],e=0,f;for(;e<d;e++)isNaN(b[e])&&(b.splice(e,1),e--);return b[l]&&(f=a.max[i](a,b),isNaN(c)||(f=a.min(c,f))),f||c||0}function W(a,b,c,d){var e=(a.getAttribute("data-base")||b)+(a.getAttribute("data-src")||k);return d&&(e+=(K.test(e)?"&":"?")+"riloadrts="+(new Date).getTime()),e.replace(L,c)}function X(b,c){return B.height()+B.scrollTop()<=a(b).offset().top-c}function Q(){var a=D.navigator,b=a.connection||a.mozConnection||a.webkitConnection||a.oConnection||a.msConnection||{},c=b.type||"unknown",d=+b.bandwidth||Infinity;return d>0&&d<.1||/^[23]g|3|4$/.test(c+k)}function Y(a,b){function j(){h=new Date,g=f,a[i](e,c)}var c,d,e,g,h=0;return function(){var f=new Date,k=b-(f-h);return c=arguments,e=this,k<=0?(h=f,d=a[i](e,c)):g||(g=setTimeout(j,k)),d}}function Z(a,b,c){function j(){h=f,c||a[i](g,d)}var d,e,g,h;return function(){var f=c&&!h;return d=arguments,g=this,clearTimeout(h),h=setTimeout(j,b),f&&(e=a[i](g,d)),e}}function $(a){var b=Array[u].slice[h](arguments,1);setTimeout(function(){return a[i](f,b)},1)}function _(a){throw new Error("Riloadr: "+a)}function ab(a,b,c){a[I](H+b,c,d)}function bb(a,b,c){a[J](H+b,c,d)}function cb(b){a(b)}function db(a){if(E.readyState===r)a();else{var b=function(){bb(D,g,b),a()};ab(D,g,b)}}"use strict";var b="on",c=!0,d=!1,e=250,f=null,g="load",h="call",i="apply",j="error",k="",l="length",m="scroll",n="resize",o=b+g,p=b+j,q="retries",r="complete",s="riloaded",t="className",u="prototype",v=b+r,w="loadImages",x="orientation",y="EventListener",z="add"+y,A=x+"change",B,C,D=window,E=D.document,F=E.documentElement,G=z in E,H=G?k:b,I=G?z:"attachEvent",J=G?"remove"+y:"detachEvent",K=/\?/,L=/{breakpoint-name}/gi,M=x in D&&b+A in D,N,O=D.screen.width,P=D.devicePixelRatio||1,Q=Q(),R=Object[u].toString[h](D.operamini)==="[object OperaMini]",S;return F[t]=F[t].replace(/(^|\s)no-js(\s|$)/,"$1$2"),T.version="1.2.0",T[u].riload=function(){this[w](c)},T});