-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathriloadr.jquery.min.js
2 lines (2 loc) · 5.1 KB
/
riloadr.jquery.min.js
1
2
/*! Riloadr.js 1.5.3 (c) 2014 Tubal Martin - MIT license */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):window.Riloadr=a(jQuery)}(function(a){"use strict";function hb(b){function qb(){bb=nb(),_=ib(k,bb,M),db=D in _&&kb(k,_[D]),eb=eb||G&&jb(k),hb=H&&lb(_,eb)}function rb(){var b,a=0;if((V||G)&&zb(T,u,X),V&&(zb(T,s,W),ab&&(gb=T[L],zb(T,P,Y)),B))for(;b=B[a];)zb(U[N](b),s,W),a++}function sb(){var b,a=0;if(!G&&(Ab(T,u,X),V)){if(Ab(T,s,W),B)for(;b=B[a];)Ab(U[N](b),s,W),a++;ab&&Ab(T,P,Y)}}function tb(a,b){a[y]=0,a[D]=h,a[v]=wb,a[w]=a[x]=Db,a[d]=ob(a,g,_),Z.splice(b,1)}function wb(){var c,e,a=this;"naturalWidth"in a?e=a.naturalWidth+a.naturalHeight:(c=new Image,c[d]=a[d],e=c[o]+c[q],c=j),+e>0&&(a[v]=a[w]=a[x]=j,a[C]&&(a[E]=a[E].replace(n,"$1$2")),V&&(a.style.visibility="visible"),v in b&&b[v][l](a),Eb())}function Db(){var f,a=this,c=function(b){var c=new Image;c[v]=function(){a[d]=c[d],wb[l](a)},c[w]=c[x]=function(){Db[l](a)},c[d]=b};a[v]=a[w]=a[x]=j,w in b&&b[w][l](a),a[y]<O?(a[y]++,f=ob(a,g,a[D]?db:_,e),c(f)):D in _&&!a[D]&&db?(a[y]=0,a[D]=e,f=ob(a,g,db),c(f)):Eb()}function Eb(){$--,0===$&&(sb(),I in b&&b[I]())}var _,cb,db,eb,hb,c=this,g=b.base||p,k=b.breakpoints||yb('"breakpoints" not defined.'),m=b.name||"responsive",n=new RegExp("(^|\\s)"+m+"(\\s|$)"),t=b.defer&&("string"==typeof b.defer?{mode:b.defer,threshold:b.foldDistance,overflownElemsIds:[]}:b.defer),z=t&&t.mode.toLowerCase(),A=t&&t.threshold||100,B=t&&t.overflownElemsIds,F=b.watchViewportWidth,G=!!F,H="wider"==F,J="*"==F,M=b.ignoreLowBandwidth||h,O=b[y]||0,Q=b.root||j,V=("invisible"==z||"belowfold"==z)&&!fb,W=ub(function(){c[K]()},i),X=vb(function(){G&&qb(),c[K](G)},i),Y=vb(function(){T[L]!==gb&&(gb=T[L],c[K]())},i),Z=[],$=0;c[K]=function(b){xb(function(c,d){if(Z[r]&&b!==e||(b&&rb(),a("img."+m,Q).each(function(a,c){c&&!c[C]&&((!G||G&&(b===e||!cb||H&&mb(_,cb)||J&&!lb(_,cb)))&&(Z.push(c),$++),(!G||hb)&&(c[C]=e))}),G&&(hb&&(G=h),cb=_)),Z[r])for(d=0;c=Z[d];)c&&(!V||V&&pb(c,A))&&(tb(c,d),d--),d++;c=j})},Bb(function(){R=a(T),S=U[f],Q=Q&&a("#"+Q)||S,qb(),rb(),!z||V?c[K]():Cb(c[K])})}function ib(a,b,c){for(var g,h,i,j,d=b,e=0,f={};g=a[e];)h=g[z],i=g[A],j=g[Q],b>0?(h&&i&&b>=h&&i>=b||h&&!i&&b>=h||i&&!h&&i>=b)&&(!j||j&&db>=j&&(c||!c&&!eb))&&(f=g):(0>=d||d>h||d>i)&&(d=h||i||d,f=g),e++;return f}function jb(a){for(var d,b=0,c={};d=a[b];)mb(d,c)&&(c=d),b++;return c}function kb(a,b){for(var d,c=0;d=a[c];){if(d.name==b)return d;c++}}function lb(a,b){return a.name===b.name&&a[z]===b[z]&&a[A]===b[A]&&a[Q]===b[Q]&&a[F]===b[F]}function mb(a,b){var c=+a[Q]||1,d=+b[Q]||1;return a=Math.max(+a[z]||0,+a[A]||0)*(db>=c?c:1),b=Math.max(+b[z]||0,+b[A]||0)*(db>=d?d:1),a>b}function nb(){for(var d,a=Math,b=[T.innerWidth,V.clientWidth,V.offsetWidth,S.clientWidth],c=0;c<b[r];c++)isNaN(b[c])&&(b.splice(c,1),c--);return b[r]&&(d=a.max[m](a,b),isNaN(cb)||(d=a.min(cb,d))),d||cb||0}function ob(a,b,c,d){var e=(a.getAttribute("data-base")||b)+(a.getAttribute("data-src")||a.getAttribute("data-src-"+c.name)||p);return c[F]&&(e=e.split("."),e.pop(),e=e.join(".")+"."+c[F]),d&&(e+=($.test(e)?"&":"?")+"riloadrts="+(new Date).getTime()),e.replace(_,c.name)}function eb(){var a=T.navigator,b=a.connection||a.mozConnection||a.webkitConnection||a.oConnection||a.msConnection||{},c=b.type||"unknown",d=+b.bandwidth||1/0;return d>0&&.1>d||/^[23]g|3|4$/.test(c+p)}function pb(b,c){var d=a(b);return!(qb(d,c)||rb(d,c)||sb(d,c)||tb(d,c))}function qb(a,b){return R[q]()+R[H]()<=a[t]()[c]-b}function rb(a,b){return R[H]()>=a[t]()[c]+b+a[q]()}function sb(a,b){return R[o]()+R[J]()<=a[t]()[g]-b}function tb(a,b){return R[J]()>=a[t]()[g]+b+a[o]()}function ub(a,b){function h(){g=new Date,f=j,a[m](e,c)}var c,d,e,f,g=0;return function(){var i=new Date,j=b-(i-g);return c=arguments,e=this,0>=j?(g=i,d=a[m](e,c)):f||(f=wb(h,j)),d}}function vb(a,b,c){function h(){g=j,c||a[m](f,d)}var d,e,f,g;return function(){var i=c&&!g;return d=arguments,f=this,clearTimeout(g),g=wb(h,b),i&&(e=a[m](f,d)),e}}function wb(a,b){var c=Array[G].slice[l](arguments,2);return T.setTimeout(function(){return a[m](j,c)},b)}function xb(a){return wb[m](j,[a,1].concat(Array[G].slice[l](arguments,1)))}function yb(a){throw new Error("Riloadr: "+a)}function zb(a,b,c){a[Y](X+b,c,h)}function Ab(a,b,c){a[Z](X+b,c,h)}function Bb(b){a(b)}function Cb(a){if(U.readyState===B)a();else{var b=function(){Ab(T,k,b),a()};zb(T,k,b)}}var R,S,bb,gb,b="on",c="top",d="src",e=!0,f="body",g="left",h=!1,i=250,j=null,k="load",l="call",m="apply",n="error",o="width",p="",q="height",r="length",s="scroll",t="offset",u="resize",v=b+k,w=b+n,x=b+"abort",y="retries",z="minWidth",A="maxWidth",B="complete",C="riloaded",D="fallback",E="className",F="imgFormat",G="prototype",H=s+"Top",I=b+B,J=s+"Left",K=k+"Images",L="orientation",M="EventListener",N="getElementById",O="add"+M,P=L+"change",Q="minDevicePixelRatio",T=window,U=T.document,V=U.documentElement,W=O in U,X=W?p:b,Y=W?O:"attachEvent",Z=W?"remove"+M:"detachEvent",$=/\?/,_=/{breakpoint-name}/gi,ab=L in T&&b+P in T,cb=T.screen[o],db=T.devicePixelRatio||1,eb=eb(),fb="[object OperaMini]"===Object[G].toString[l](T.operamini);return V[E]=V[E].replace(/(^|\s)no-js(\s|$)/,"$1$2"),hb.version="1.5.3",hb[G].riload=function(){this[K](e)},hb});