forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls.rias.min.js
3 lines (3 loc) · 3.49 KB
/
ls.rias.min.js
1
2
3
/*! lazysizes - v0.9.0 - 2015-02-06
Licensed MIT */
!function(a,b){"use strict";function c(a,b){var c,d,e,f;d=a.parentNode,f={isPicture:!(!d||!l.test(d.nodeName||""))},e=function(b,c){var d=a.getAttribute("data-"+b);if(null!=d){if("true"==d)d=!0;else if("false"==d)d=!1;else if(k.test(d))d=parseFloat(d);else if("function"==typeof i[b])d=i[b](a,d);else if(o.test(d))try{d=JSON.parse(d)}catch(e){}f[b]=d}else b in i&&"function"!=typeof i[b]?f[b]=i[b]:c&&"function"==typeof i[b]&&(f[b]=i[b](a,d))};for(c in i)e(c);return b.replace(n,function(a,b){b in f||e(b,!0)}),f}function d(a,b){var c=[],d=function(a,c){return j[typeof b[c]]?b[c]:a};return c.srcset=[],b.absUrl&&(q.setAttribute("href",a),a=q.href),a=((b.prefix||"")+a+(b.postfix||"")).replace(n,d),b.widths.forEach(function(d){var e={u:a.replace(m,b.widthmap[d]||d),w:d};c.push(e),c.srcset.push(e.c=e.u+" "+d+"w")}),c}function e(a,b,c){a&&(a=d(a,b),a.isPicture=b.isPicture,c.setAttribute(h.srcsetAttr,a.srcset.join(", ")),Object.defineProperty(c,"_lazyrias",{value:a,writable:!0}))}function f(a,b){var d=c(a,b);return i.modifyOptions.call(a,{target:a,details:d}),lazySizes.fire(a,"lazyriasmodifyoptions",d),d}function g(a){return a.getAttribute(a.getAttribute("data-srcattr")||i.srcAttr)||a.getAttribute(h.srcsetAttr)||a.getAttribute(h.srcAttr)||""}if(b.addEventListener){var h,i,j={string:1,number:1},k=/^\-*\+*\d+\.*\d*$/,l=/^picture$/i,m=/\s*\{\s*width\s*\}\s*/i,n=/\s*\{\s*([a-z0-9]+)\s*\}\s*/gi,o=/^\[.*\]|\{.*\}$/,p=/^(?:auto|\d+(px)?)$/,q=b.createElement("a");!function(){var b,c=function(){},d={prefix:"",postfix:"",srcAttr:"data-src",absUrl:!1,modifyOptions:c,widthmap:{}};h=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,h||(h={},a.lazySizesConfig=h),h.rias||(h.rias={}),i=h.rias,"widths"in i||(i.widths=[],function(a){var b,c=0;for(a.push(96);!b||2800>b;)c+=10,c>60&&(c+=10),b=16*c,a.push(b)}(i.widths));for(b in d)b in i||(i[b]=d[b])}(),addEventListener("lazybeforeunveil",function(a){var b,c,d,j,k,l,n,o,q;if(b=a.target,!a.defaultPrevented&&(c=g(b))&&!i.disabled&&(q=b.getAttribute(h.sizesAttr)||b.getAttribute("sizes"))&&p.test(q)){if(d=f(b,c),m.test(c)||m.test(d.prefix)||m.test(d.postfix)){if(d.isPicture&&(j=b.parentNode))for(k=j.getElementsByTagName("source"),l=0,n=k.length;n>l;l++)o=g(k[l]),e(o,d,k[l]);e(c,d,b)}"auto"!=q&&r({target:b,details:{width:parseInt(q,10)}})}});var r=function(){var c=function(a,b,c,d){return Math.abs(b.w-d.w)<Math.abs(a.w-d.w)?b:a},d=function(a,b){var c;return!a._lazyrias&&lazySizes.pWS&&(c=lazySizes.pWS(a.getAttribute(h.srcsetAttr||""))).length&&(Object.defineProperty(a,"_lazyrias",{value:c,writable:!0}),b&&a.parentNode&&(c.isPicture="PICTURE"==a.parentNode.nodeName.toUpperCase())),a._lazyrias},e=function(b){var c=a.devicePixelRatio||1,d=lazySizes.getX&&lazySizes.getX(b),e=Math.min(d||c,2.2,c);return 1.2>e?e*=1.05:e>1.6&&!d&&(e*=.95),e},f=function(b,f){var g,h,i,j,k;if(f=Math.round(f*e(b)),k=b._lazyrias,k.isPicture&&a.matchMedia)for(h=0,g=b.parentNode.getElementsByTagName("source"),i=g.length;i>h;h++)if(d(g[h])&&!g[h].getAttribute("type")&&(!(j=g[h].getAttribute("media"))||(matchMedia(j)||{}).matches)){k=g[h]._lazyrias;break}return(!k.w||k.w<f)&&(k.w=f),k.reduce(c)},g=function(c){var e,i=c.target;return a.HTMLPictureElement||a.respimage||a.picturefill?void b.removeEventListener("lazybeforesizes",g):void((i._lazyrias||c.details.dataAttr&&d(i,!0))&&(e=f(i,c.details.width),e&&e.u&&i._lazyrias.cur!=e.u&&(i._lazyrias.cur=e.u,i.setAttribute(h.srcAttr,e.u),i.setAttribute("src",e.u))))};return b.addEventListener("lazybeforesizes",g),g}()}}(window,document);