hexo-theme-sb
Version:
Clean and simple theme for Hexo blog framework
1 lines • 6.96 kB
JavaScript
;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},FontFaceObserver=void 0;!function(){var t,e=[];function n(){for(;e.length;)e[0](),e.shift()}function o(t){this.a=i,this.b=void 0,this.f=[];var e=this;try{t(function(t){!function t(e,n){if(e.a==i){if(n==e)throw new TypeError;var o=!1;try{var a=n&&n.then;if(null!=n&&"object"==(void 0===n?"undefined":_typeof(n))&&"function"==typeof a)return void a.call(n,function(n){o||t(e,n),o=!0},function(t){o||r(e,t),o=!0})}catch(t){return void(o||r(e,t))}e.a=0,e.b=n,s(e)}}(e,t)},function(t){r(e,t)})}catch(t){r(e,t)}}t=function(){setTimeout(n)};var i=2;function a(t){return new o(function(e){e(t)})}function r(t,e){if(t.a==i){if(e==t)throw new TypeError;t.a=1,t.b=e,s(t)}}function s(n){var o;o=function(){if(n.a!=i)for(;n.f.length;){var t=(a=n.f.shift())[0],e=a[1],o=a[2],a=a[3];try{0==n.a?o("function"==typeof t?t.call(void 0,n.b):n.b):1==n.a&&("function"==typeof e?o(e.call(void 0,n.b)):a(n.b))}catch(t){a(t)}}},e.push(o),1==e.length&&t()}o.prototype.g=function(t){return this.c(void 0,t)},o.prototype.c=function(t,e){var n=this;return new o(function(o,i){n.f.push([t,e,o,i]),s(n)})},window.Promise||(window.Promise=o,window.Promise.resolve=a,window.Promise.reject=function(t){return new o(function(e,n){n(t)})},window.Promise.race=function(t){return new o(function(e,n){for(var o=0;o<t.length;o+=1)a(t[o]).c(e,n)})},window.Promise.all=function(t){return new o(function(e,n){function o(n){return function(o){r[n]=o,(i+=1)==t.length&&e(r)}}var i=0,r=[];0==t.length&&e(r);for(var s=0;s<t.length;s+=1)a(t[s]).c(o(s),n)})},window.Promise.prototype.then=o.prototype.c,window.Promise.prototype.catch=o.prototype.g)}(),function(){function t(t,e){document.addEventListener?t.addEventListener("scroll",e,!1):t.attachEvent("scroll",e)}function e(t){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(t)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function n(t,e){t.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+e+";"}function o(t){var e=t.a.offsetWidth,n=e+100;return t.f.style.width=n+"px",t.c.scrollLeft=n,t.b.scrollLeft=t.b.scrollWidth+100,t.g!==e&&(t.g=e,!0)}function i(e,n){function i(){var t=a;o(t)&&t.a.parentNode&&n(t.g)}var a=e;t(e.b,i),t(e.c,i),o(e)}function a(t,e){var n=e||{};this.family=t,this.style=n.style||"normal",this.weight=n.weight||"normal",this.stretch=n.stretch||"normal"}var r=null,s=null,c=null,l=null;function d(){return null===l&&(l=!!document.fonts),l}function f(t,e){return[t.style,t.weight,function(){if(null===c){var t=document.createElement("div");try{t.style.font="condensed 100px sans-serif"}catch(t){}c=""!==t.style.font}return c}()?t.stretch:"","100px",e].join(" ")}a.prototype.load=function(t,o){var a=this,c=t||"BESbswy",l=0,u=o||3e3,h=(new Date).getTime();return new Promise(function(t,o){if(d()&&!function(){if(null===s)if(d()&&/Apple/.test(window.navigator.vendor)){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent);s=!!t&&603>parseInt(t[1],10)}else s=!1;return s}()){var p=new Promise(function(t,e){!function n(){(new Date).getTime()-h>=u?e():document.fonts.load(f(a,'"'+a.family+'"'),c).then(function(e){1<=e.length?t():setTimeout(n,25)},function(){e()})}()}),m=new Promise(function(t,e){l=setTimeout(e,u)});Promise.race([m,p]).then(function(){clearTimeout(l),t(a)},function(){o(a)})}else w=function(){function s(){var e;(e=-1!=w&&-1!=y||-1!=w&&-1!=v||-1!=y&&-1!=v)&&((e=w!=y&&w!=v&&y!=v)||(null===r&&(e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),r=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))),e=r&&(w==b&&y==b&&v==b||w==g&&y==g&&v==g||w==x&&y==x&&v==x)),e=!e),e&&(E.parentNode&&E.parentNode.removeChild(E),clearTimeout(l),t(a))}var d=new e(c),p=new e(c),m=new e(c),w=-1,y=-1,v=-1,b=-1,g=-1,x=-1,E=document.createElement("div");E.dir="ltr",n(d,f(a,"sans-serif")),n(p,f(a,"serif")),n(m,f(a,"monospace")),E.appendChild(d.a),E.appendChild(p.a),E.appendChild(m.a),document.body.appendChild(E),b=d.a.offsetWidth,g=p.a.offsetWidth,x=m.a.offsetWidth,function t(){if((new Date).getTime()-h>=u)E.parentNode&&E.parentNode.removeChild(E),o(a);else{var e=document.hidden;!0!==e&&void 0!==e||(w=d.a.offsetWidth,y=p.a.offsetWidth,v=m.a.offsetWidth,s()),l=setTimeout(t,50)}}(),i(d,function(t){w=t,s()}),n(d,f(a,'"'+a.family+'",sans-serif')),i(p,function(t){y=t,s()}),n(p,f(a,'"'+a.family+'",serif')),i(m,function(t){v=t,s()}),n(m,f(a,'"'+a.family+'",monospace'))},document.body?w():document.addEventListener?document.addEventListener("DOMContentLoaded",function t(){document.removeEventListener("DOMContentLoaded",t),w()}):document.attachEvent("onreadystatechange",function t(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",t),w())});var w})},"object"===("undefined"==typeof module?"undefined":_typeof(module))?module.exports=a:(window.FontFaceObserver=a,window.FontFaceObserver.prototype.load=a.prototype.load)}(),function(){if(window.sessionStorage.criticalFoftDataUriFontsLoaded1)document.documentElement.className+=" fonts-stage-1 fonts-stage-2";else{var t=new FontFaceObserver("Vollkorn Subset",{weight:"normal",style:"normal"}),e=new FontFaceObserver("Playfair Display Bold Subset",{weight:700,style:"normal"});Promise.all([t.load(),e.load()]).then(function(){document.documentElement.className+=" fonts-stage-1";var t=new FontFaceObserver("Vollkorn",{weight:"normal",style:"normal"}),e=new FontFaceObserver("Playfair Display Bold",{weight:700,style:"normal"});console.log("Subset fonts loaded."),Promise.all([t.load(),e.load()]).then(function(){document.documentElement.className+=" fonts-stage-2",window.sessionStorage.criticalFoftDataUriFontsLoaded1=!0,console.log("Main fonts loaded.")},function(){console.log("Main fonts not loaded.")})},function(){console.log("Subset fonts not loaded.")})}}();