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