wp_back/wp-content/plugins/wp-smushit/app/assets/js/smush-lazy-load-native.min.js
2024-05-20 15:37:46 +03:00

2 lines
9.3 KiB
JavaScript

!function(){var e={7090:function(e){!function(t,n){var i=function(e,t,n){"use strict";var i,a;if(function(){var t,n={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",fastLoadedClass:"ls-is-cached",iframeLoadMode:0,srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(t in a=e.lazySizesConfig||e.lazysizesConfig||{},n)t in a||(a[t]=n[t])}(),!t||!t.getElementsByClassName)return{init:function(){},cfg:a,noSupport:!0};var o=t.documentElement,r=e.HTMLPictureElement,s="addEventListener",l="getAttribute",d=e[s].bind(e),c=e.setTimeout,u=e.requestAnimationFrame||c,f=e.requestIdleCallback,v=/^picture$/i,g=["load","error","lazyincluded","_lazyloaded"],m={},y=Array.prototype.forEach,p=function(e,t){return m[t]||(m[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),m[t].test(e[l]("class")||"")&&m[t]},z=function(e,t){p(e,t)||e.setAttribute("class",(e[l]("class")||"").trim()+" "+t)},h=function(e,t){var n;(n=p(e,t))&&e.setAttribute("class",(e[l]("class")||"").replace(n," "))},b=function(e,t,n){var i=n?s:"removeEventListener";n&&b(e,t),g.forEach((function(n){e[i](n,t)}))},L=function(e,n,a,o,r){var s=t.createEvent("Event");return a||(a={}),a.instance=i,s.initEvent(n,!o,!r),s.detail=a,e.dispatchEvent(s),s},C=function(t,n){var i;!r&&(i=e.picturefill||a.pf)?(n&&n.src&&!t[l]("srcset")&&t.setAttribute("srcset",n.src),i({reevaluate:!0,elements:[t]})):n&&n.src&&(t.src=n.src)},E=function(e,t){return(getComputedStyle(e,null)||{})[t]},A=function(e,t,n){for(n=n||e.offsetWidth;n<a.minSize&&t&&!e._lazysizesWidth;)n=t.offsetWidth,t=t.parentNode;return n},_=(ze=[],he=[],be=ze,Le=function(){var e=be;for(be=ze.length?he:ze,ye=!0,pe=!1;e.length;)e.shift()();ye=!1},Ce=function(e,n){ye&&!n?e.apply(this,arguments):(be.push(e),pe||(pe=!0,(t.hidden?c:u)(Le)))},Ce._lsFlush=Le,Ce),M=function(e,t){return t?function(){_(e)}:function(){var t=this,n=arguments;_((function(){e.apply(t,n)}))}},w=function(e){var t,i=0,o=a.throttleDelay,r=a.ricTimeout,s=function(){t=!1,i=n.now(),e()},l=f&&r>49?function(){f(s,{timeout:r}),r!==a.ricTimeout&&(r=a.ricTimeout)}:M((function(){c(s)}),!0);return function(e){var a;(e=!0===e)&&(r=33),t||(t=!0,(a=o-(n.now()-i))<0&&(a=0),e||a<9?l():c(l,a))}},x=function(e){var t,i,a=99,o=function(){t=null,e()},r=function(){var e=n.now()-i;e<a?c(r,a-e):(f||o)(o)};return function(){i=n.now(),t||(t=c(r,a))}},N=(K=/^img$/i,Q=/^iframe$/i,V="onscroll"in e&&!/(gle|ing)bot/.test(navigator.userAgent),X=0,Y=0,Z=0,ee=-1,te=function(e){Z--,(!e||Z<0||!e.target)&&(Z=0)},ne=function(e){return null==J&&(J="hidden"==E(t.body,"visibility")),J||!("hidden"==E(e.parentNode,"visibility")&&"hidden"==E(e,"visibility"))},ie=function(e,n){var i,a=e,r=ne(e);for(j-=n,G+=n,U-=n,q+=n;r&&(a=a.offsetParent)&&a!=t.body&&a!=o;)(r=(E(a,"opacity")||1)>0)&&"visible"!=E(a,"overflow")&&(i=a.getBoundingClientRect(),r=q>i.left&&U<i.right&&G>i.top-1&&j<i.bottom+1);return r},ae=function(){var e,n,r,s,d,c,u,f,v,g,m,y,p=i.elements;if((P=a.loadMode)&&Z<8&&(e=p.length)){for(n=0,ee++;n<e;n++)if(p[n]&&!p[n]._lazyRace)if(!V||i.prematureUnveil&&i.prematureUnveil(p[n]))fe(p[n]);else if((f=p[n][l]("data-expand"))&&(c=1*f)||(c=Y),g||(g=!a.expand||a.expand<1?o.clientHeight>500&&o.clientWidth>500?500:370:a.expand,i._defEx=g,m=g*a.expFactor,y=a.hFac,J=null,Y<m&&Z<1&&ee>2&&P>2&&!t.hidden?(Y=m,ee=0):Y=P>1&&ee>1&&Z<6?g:X),v!==c&&(I=innerWidth+c*y,$=innerHeight+c,u=-1*c,v=c),r=p[n].getBoundingClientRect(),(G=r.bottom)>=u&&(j=r.top)<=$&&(q=r.right)>=u*y&&(U=r.left)<=I&&(G||q||U||j)&&(a.loadHidden||ne(p[n]))&&(R&&Z<3&&!f&&(P<3||ee<4)||ie(p[n],c))){if(fe(p[n]),d=!0,Z>9)break}else!d&&R&&!s&&Z<4&&ee<4&&P>2&&(k[0]||a.preloadAfterLoad)&&(k[0]||!f&&(G||q||U||j||"auto"!=p[n][l](a.sizesAttr)))&&(s=k[0]||p[n]);s&&!d&&fe(s)}},oe=w(ae),re=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(te(e),z(t,a.loadedClass),h(t,a.loadingClass),b(t,le),L(t,"lazyloaded"))},se=M(re),le=function(e){se({target:e.target})},de=function(e,t){var n=e.getAttribute("data-load-mode")||a.iframeLoadMode;0==n?e.contentWindow.location.replace(t):1==n&&(e.src=t)},ce=function(e){var t,n=e[l](a.srcsetAttr);(t=a.customMedia[e[l]("data-media")||e[l]("media")])&&e.setAttribute("media",t),n&&e.setAttribute("srcset",n)},ue=M((function(e,t,n,i,o){var r,s,d,u,f,g;(f=L(e,"lazybeforeunveil",t)).defaultPrevented||(i&&(n?z(e,a.autosizesClass):e.setAttribute("sizes",i)),s=e[l](a.srcsetAttr),r=e[l](a.srcAttr),o&&(u=(d=e.parentNode)&&v.test(d.nodeName||"")),g=t.firesLoad||"src"in e&&(s||r||u),f={target:e},z(e,a.loadingClass),g&&(clearTimeout(H),H=c(te,2500),b(e,le,!0)),u&&y.call(d.getElementsByTagName("source"),ce),s?e.setAttribute("srcset",s):r&&!u&&(Q.test(e.nodeName)?de(e,r):e.src=r),o&&(s||u)&&C(e,{src:r})),e._lazyRace&&delete e._lazyRace,h(e,a.lazyClass),_((function(){var t=e.complete&&e.naturalWidth>1;g&&!t||(t&&z(e,a.fastLoadedClass),re(f),e._lazyCache=!0,c((function(){"_lazyCache"in e&&delete e._lazyCache}),9)),"lazy"==e.loading&&Z--}),!0)})),fe=function(e){if(!e._lazyRace){var t,n=K.test(e.nodeName),i=n&&(e[l](a.sizesAttr)||e[l]("sizes")),o="auto"==i;(!o&&R||!n||!e[l]("src")&&!e.srcset||e.complete||p(e,a.errorClass)||!p(e,a.lazyClass))&&(t=L(e,"lazyunveilread").detail,o&&T.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,Z++,ue(e,t,o,i,n))}},ve=x((function(){a.loadMode=3,oe()})),ge=function(){3==a.loadMode&&(a.loadMode=2),ve()},me=function(){R||(n.now()-D<999?c(me,999):(R=!0,a.loadMode=3,oe(),d("scroll",ge,!0)))},{_:function(){D=n.now(),i.elements=t.getElementsByClassName(a.lazyClass),k=t.getElementsByClassName(a.lazyClass+" "+a.preloadClass),d("scroll",oe,!0),d("resize",oe,!0),d("pageshow",(function(e){if(e.persisted){var n=t.querySelectorAll("."+a.loadingClass);n.length&&n.forEach&&u((function(){n.forEach((function(e){e.complete&&fe(e)}))}))}})),e.MutationObserver?new MutationObserver(oe).observe(o,{childList:!0,subtree:!0,attributes:!0}):(o[s]("DOMNodeInserted",oe,!0),o[s]("DOMAttrModified",oe,!0),setInterval(oe,999)),d("hashchange",oe,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach((function(e){t[s](e,oe,!0)})),/d$|^c/.test(t.readyState)?me():(d("load",me),t[s]("DOMContentLoaded",oe),c(me,2e4)),i.elements.length?(ae(),_._lsFlush()):oe()},checkElems:oe,unveil:fe,_aLSL:ge}),T=(O=M((function(e,t,n,i){var a,o,r;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),v.test(t.nodeName||""))for(o=0,r=(a=t.getElementsByTagName("source")).length;o<r;o++)a[o].setAttribute("sizes",i);n.detail.dataAttr||C(e,n.detail)})),B=function(e,t,n){var i,a=e.parentNode;a&&(n=A(e,a,n),(i=L(e,"lazybeforesizes",{width:n,dataAttr:!!t})).defaultPrevented||(n=i.detail.width)&&n!==e._lazysizesWidth&&O(e,a,i,n))},F=x((function(){var e,t=S.length;if(t)for(e=0;e<t;e++)B(S[e])})),{_:function(){S=t.getElementsByClassName(a.autosizesClass),d("resize",F)},checkElems:F,updateElem:B}),W=function(){!W.i&&t.getElementsByClassName&&(W.i=!0,T._(),N._())};var S,O,B,F;var k,R,H,P,D,I,$,j,U,q,G,J,K,Q,V,X,Y,Z,ee,te,ne,ie,ae,oe,re,se,le,de,ce,ue,fe,ve,ge,me;var ye,pe,ze,he,be,Le,Ce;return c((function(){a.init&&W()})),i={cfg:a,autoSizer:T,loader:N,init:W,uP:C,aC:z,rC:h,hC:p,fire:L,gW:A,rAF:_}}(t,t.document,Date);t.lazySizes=i,e.exports&&(e.exports=i)}("undefined"!=typeof window?window:{})},627:function(e,t,n){var i,a,o;!function(r,s){s=s.bind(null,r,r.document),e.exports?s(n(7090)):(a=[n(7090)],void 0===(o="function"==typeof(i=s)?i.apply(t,a):i)||(e.exports=o))}(window,(function(e,t,n){"use strict";var i="loading"in HTMLImageElement.prototype,a="loading"in HTMLIFrameElement.prototype,o=!1,r=n.prematureUnveil,s=n.cfg,l={focus:1,mouseover:1,click:1,load:1,transitionend:1,animationend:1,scroll:1,resize:1};function d(){var r,d,c,u;o||(o=!0,i&&a&&s.nativeLoading.disableListeners&&(!0===s.nativeLoading.disableListeners&&(s.nativeLoading.setLoadingAttribute=!0),r=n.loader,d=r.checkElems,c=function(){setTimeout((function(){e.removeEventListener("scroll",r._aLSL,!0)}),1e3)},(u="object"==typeof s.nativeLoading.disableListeners?s.nativeLoading.disableListeners:l).scroll&&(e.addEventListener("load",c),c(),e.removeEventListener("scroll",d,!0)),u.resize&&e.removeEventListener("resize",d,!0),Object.keys(u).forEach((function(e){u[e]&&t.removeEventListener(e,d,!0)}))),s.nativeLoading.setLoadingAttribute&&e.addEventListener("lazybeforeunveil",(function(e){var t=e.target;"loading"in t&&!t.getAttribute("loading")&&t.setAttribute("loading","lazy")}),!0))}s.nativeLoading||(s.nativeLoading={}),e.addEventListener&&e.MutationObserver&&(i||a)&&(n.prematureUnveil=function(e){return o||d(),!(!("loading"in e)||!s.nativeLoading.setLoadingAttribute&&!e.getAttribute("loading")||"auto"==e.getAttribute("data-sizes")&&!e.offsetWidth)||(r?r(e):void 0)})}))}},t={};function n(i){var a=t[i];if(void 0!==a)return a.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=n(7090),t=n.n(e);n(627);t().cfg.nativeLoading={setLoadingAttribute:!0,disableListeners:{scroll:!0}},t().init()}()}();
//# sourceMappingURL=smush-lazy-load-native.min.js.map