forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls.include.min.js
2 lines (2 loc) · 5.43 KB
/
ls.include.min.js
1
2
/*! lazysizes - v3.0.0 */
!function(a,b){"use strict";function c(a){a.match(A)?this.urls[RegExp.$1]=u.map[RegExp.$2]||RegExp.$2:this.urls.include=u.map[a]||a}function d(a){var b,d,e;return a=a.trim(),a=u.map[a]||a,d=a.match(B),d?(e=RegExp.$1,b={condition:t.include.conditions[RegExp.$3]||t.customMedia[RegExp.$3]||RegExp.$2||null,name:RegExp.$3}):(e=a,b={condition:null,name:""}),b.urls={},(u.map[e]||e).split(z).forEach(c,b),!b.urls.include&&b.urls.amd&&(this.saved=!0,b.initial=this),b}function e(a){var b,c,e=a.getAttribute("data-include")||"",f=a.lazyInclude;return(!f||f.str!=e||u.allowReload)&&(c={saved:!1,content:null},f={str:e,candidates:(u.map[e]||e).split(x).map(d,c)},!(b=f.candidates.length)||f.candidates[b-1].condition?(c.saved=!0,f.candidates.push({urls:{},condition:null,name:"initial",content:c})):c.saved&&1==f.candidates.length&&(c.saved=!1),f.initialContent=c,c.saved&&(c.content=a.innerHTML),a.lazyInclude=f,f.candidates.length>1?lazySizes.aC(a,"lazyconditionalinclude"):lazySizes.rC(a,"lazyconditionalinclude")),f}function f(b,c){var d=!c.condition;return c.condition&&(g(),w[c.name]?d=!0:a.matchMedia&&"string"==typeof c.condition?d=(matchMedia(c.condition)||{}).matches:"function"==typeof c.condition&&(d=c.condition(b,c))),d}function g(){var a;w||(v||(v=b.querySelector(u.contentElement)),v?(a=(F(v,":after").getPropertyValue("content")||"none").replace(C,""),w={},a&&(w[a]=1),a=(F(v,":before").getPropertyValue("content")||"none").replace(C,""),a&&(w[a]=1)):w={})}function h(a){var b,c,d=a.lazyInclude;if(d&&d.candidates)for(b=0;b<d.candidates.length&&(c=d.candidates[b],!f(a,c));b++);return c&&c!=d.current||(c=null),c}function i(a,b){var c=new XMLHttpRequest;c.addEventListener("readystatechange",function(){var a=this.DONE||4;this.readyState===a&&(b(c),c=null)},!1),c.open.apply(c,a.openArgs),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.xhrModifier&&a.xhrModifier(c,elem,candidate),c.send(a.sendData)}function j(a,b){a=a.split("|,|");var c=a.length-1;lazySizes.cfg.requireJs?lazySizes.cfg.requireJs(a,b):a.forEach(function(a,d){l(a,d==c?b:null)})}function k(a,b){lazySizes.cfg.systemJs?lazySizes.cfg.systemJs(a,b):l(a,b)}function l(a,c,d){if(!y[a]){var e=b.createElement(c===!0?"script":"link"),f=b.getElementsByTagName("script")[0];c?(e.src=a,e.async=!1):(e.rel="stylesheet",e.href=a),f.parentNode.insertBefore(e,f),y[a]=!0,y[e.href]=!0}}function m(a){a=a.split("|,|"),a.forEach(l)}function n(a){a&&"function"==typeof a.lazytransform&&a.lazytransform(this)}function o(a){a&&"function"==typeof a.lazyunload&&a.lazyunload(this)}function p(a){a&&"function"==typeof a.lazyload&&a.lazyload(this)}function q(b,c){var d,e,f,g=b.lazyInclude.current||null,h={candidate:c,openArgs:["GET",c.urls.include,!0],sendData:null,xhrModifier:null,content:c.content&&c.content.content||c.content,oldCandidate:g},l=lazySizes.fire(b,"lazyincludeload",h);return l.defaultPrevented?void G.d():(d=function(){var d,h=e.status,i=e.content||e.responseText,j=!(null!=i||!g||!g.urls.include),k={candidate:c,content:i,text:e.responseText||e.content,response:e.response,xml:e.responseXML,isSuccess:"status"in e?h>=200&&300>h||304===h:!0,oldCandidate:g,insert:!0,resetHTML:j},l={target:b,details:k,detail:k};c.modules=f,g&&g.modules&&(g.modules.forEach(o,l),g.modules=null,k.resetHTML&&null==k.content&&c.initial&&c.initial.saved&&(k.content=c.initial.content)),f.forEach(n,l),d=lazySizes.fire(b,"lazyincludeloaded",k),k.insert&&k.isSuccess&&!d.defaultPrevented&&null!=k.content&&k.content!=b.innerHTML&&(a.jQuery?jQuery(b).html(k.content):b.innerHTML=k.content),G.d(),f.forEach(p,l),setTimeout(function(){lazySizes.fire(b,"lazyincluded",k)}),e=null,f=null},b.lazyInclude.current=c,b.setAttribute("data-currentinclude",c.name),c.urls.css&&m(c.urls.css),null==h.content&&c.urls.include?i(h,function(a){e=a,f&&d()}):e=h,c.urls.amd||c.urls.module?(loadRequireImportCB=function(){f=Array.prototype.slice.call(arguments),e&&d()},c.urls.amd?j(c.urls.amd,loadRequireImportCB):k(c.urls.module,loadRequireImportCB)):f=[],void(e&&f&&d()))}function r(a){var b,c=e(a);return c.candidates.length&&D.contains(a)?(b=h(a),b&&q(a,b),!0):void 0}function s(a){!a.defaultPrevented&&a.target.getAttribute("data-include")&&(G.q(a.target),a.detail.firesLoad=!0)}if(b.getElementsByClassName){var t,u,v,w,x=/\s*,+\s+/,y={},z=/\s+/,A=/^(amd|css|module)\:(.+)/i,B=/(.+)\s+(\(\s*(.+)\s*\))/,C=/['"]/g,D=b.documentElement,E=b.getElementsByClassName("lazyconditionalinclude"),F=function(b,c){var d=b.ownerDocument.defaultView;return d.opener||(d=a),d.getComputedStyle(b,c||null)||{getPropertyValue:function(){},isNull:!0}},G=function(){var a=2,b=3,c=a,d=0,e=0,f=[],g=function(){var a,b=function(){f.length&&(d=0,f.d())};return function(){clearTimeout(a),a=setTimeout(b,999)}}();return{q:function(a){var h=null==a.getAttribute("data-lazyqueue");h&&(e++,c=b),d>c?f[h?"unshift":"push"](a):r(a)&&(d++,g())},d:function(){if(d&&d--,e>0&&(e--,e||(c=a)),!(d>c)){for(;f.length;)if(r(f.shift())){d++;break}g()}}}}(),H=function(){var a,b=function(){for(var a=0,b=E.length;b>a;a++)!lazySizes.hC(E[a],t.lazyClass)&&h(E[a])&&lazySizes.aC(E[a],t.lazyClass)};return function(c){clearTimeout(a),w=null,a=setTimeout(b,"resize"==c.type?31:0)}}();t=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,t||(t={},a.lazySizesConfig=t),t.include||(t.include={}),u=t.include,u.contentElement||(u.contentElement="html"),u.conditions||(u.conditions={}),u.map||(u.map={}),addEventListener("lazybeforeunveil",s,!1),addEventListener("resize",H,!1),addEventListener("lazyrefreshincludes",H,!1)}}(window,document);