-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.min.js
1 lines (1 loc) · 11.7 KB
/
index.min.js
1
(function(e,t){"use strict";function r(e,r){var a,i=XMLHttpRequest,o=!1;try{o=XMLHttpRequest&&"withCredentials"in(a=new i)}catch(s){}return o?(a.open("GET",e),a.onload=function(){if(a.onload=a.onerror=null,a.status<200||a.status>=300)console.error("style failed to load: "+e);else{var i=t.createElement("style");i.appendChild(t.createTextNode(a.responseText)),i.setAttribute("data-url",e),t.head.appendChild(i),r(i),i.remove()}},a.onerror=function(){a.onload=a.onerror=null,console.error("XHR CORS CSS fail:"+e)},void a.send()):void console.error("CORS not supported")}function a(e){try{return e.cssRules||e.rules}catch(t){return}}function i(e,t){if(e.ownerNode&&e.ownerNode.hasAttribute("data-style-skip"))return void t([],e.href);var i=a(e);!i&&L[e.href]?(i=L[e.href].rules,t(i,e.href)):i?t(i,e.href):function(e){r(e.href,function(r){L[e.href]={},L[e.href].styleSheet=r.sheet,L[e.href].rules=a(r.sheet),t(L[e.href].rules,e.href)})}(e)}function o(e,t,r){for(var a,i=0,o=e.length;i<o;i++)a=e[i],a.selectorText&&t.call(r,a,i)}function s(e){var r,a=t.getElementsByTagName("html")[0],i=0,o=0,s=function(t){e.scrollHeight<=e.clientHeight||((r>Math.abs(t.deltaY)||!r)&&(r=Math.abs(t.deltaY)),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.deltaY<0&&0===e.scrollTop||t.deltaY>0&&e.scrollHeight===e.scrollTop+e.clientHeight?t.preventDefault?t.preventDefault():t.returnValue=!1:(o||(i=a.scrollTop),o++,setTimeout(function(){o--,o||a.scrollTop===i||(a.scrollTop=i)},0)))},n=function(e){e.deltaY=-e.wheelDelta,s(e)};e.removeWheelListener||e.addEventListener&&(e.addEventListener("wheel",s,!1),e.addEventListener("mousewheel",n,!1),e.removeWheelListener=function(){e.removeEventListener("wheel",s,!1),e.removeEventListener("mousewheel",n,!1),e.removeWheelListener=void 0})}function n(e,t,r){return"#"+((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}function l(e){return e=e.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()}),0===e.indexOf("Webkit")&&(e=e[0].toLowerCase()+e.slice(1)),e}function d(e,t){var r=e[t]||e[l(t)]||e[T[t]]||"";return r}function u(e,r,a){var s,l,u,c,p,f,g,h,y,b,v,x;Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]),a=a||[];for(var k=0;u=R.elms[k];k++)u.problems=[];for(R={elms:[]},c=t.body.querySelectorAll("[data-style-audit]"),k=0;u=c[k];k++)u.removeAttribute("data-style-audit");for(c=t.body.querySelectorAll("[data-style-using]"),k=0;u=c[k];k++)u.removeAttribute("data-style-using");for(var A,w=0;A=e[w];w++)s=t.querySelector('link[href*="'+A+'"]'),s&&(l=s.sheet,i(l,function(e,a){o(e,function(e){f=e.selectorText.split(",");for(var i=0;g=f[i];i++){h=_.calculate(g)[0].specificity.split(",").map(Number);try{c=t.body.querySelectorAll(g)}catch(o){return}for(var s=0,l=c.length;s<l;s++){p=c[s],m(h,[0,0,0,999999])===h&&p.setAttribute("data-style-using","true");for(var u=0,A=e.style.length;u<A;u++)if(y=e.style[u],b=d(e.style,y),v=p.computedStyles[y],v[0].styleSheet!==a){var w=!1;for(k=0;x=r[k];k++)if(v[0].styleSheet&&v[0].styleSheet.indexOf(x)!==-1){w=!0;break}if(!w){p.problems=p.problems||[];var S,C;S=b.indexOf("rgb(")!==-1?n.apply(this,b.match(H).map(Number)):b,C=v[0].value.indexOf("rgb(")!==-1?n.apply(this,v[0].value.match(H).map(Number)):v[0].value,p.problems.push({type:"property-override",selector:v[0].selector,description:"<code>"+y+": "+S+"</code> overridden by <code>"+C+"</code> in the selector <code>"+v[0].selector+"</code> from styleSheet <code>"+v[0].styleSheet+"."}),R.elms.indexOf(p)===-1&&R.elms.push(p)}}}}});for(var i,s=0;i=R.elms[s];s++)i.setAttribute("data-style-audit","property-override")}));for(w=0;w<a.length;w++){c=t.body.querySelectorAll(a[w].selector);for(var S=0;S<c.length;S++)c[S].problems=c[S].problems||[],c[S].problems.push({type:a[w].type,selector:a[w].selector,description:a[w].description}),c[S].setAttribute("data-style-audit",a[w].type)}for(c=t.body.querySelectorAll(".audit-results *"),k=0;u=c[k];k++)u.removeAttribute("data-style-using"),u.removeAttribute("data-style-audit")}function c(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")}function p(e){t.body.classList.add("open-audit"),A.innerHTML="",b.scrollTop=0;var r=t.createElement("div");r.appendChild(e.cloneNode(!1)),r.firstChild.removeAttribute("data-style-audit"),r.firstChild.removeAttribute("data-style-computed"),r.firstChild.removeAttribute("data-style-using"),v.innerHTML=c(r.innerHTML),Prism.highlightElement(v);for(var a,i,o=t.createDocumentFragment(),s=t.createElement("ul"),n=0;i=e.problems[n];n++)a=t.createElement("li"),a.innerHTML='<div><input id="audit-result-'+n+'" type="checkbox"/></div><div>'+i.description+"</div>",o.appendChild(a);s.appendChild(o),A.appendChild(s)}function f(e,t){return t.specificity[0]-e.specificity[0]||t.specificity[1]-e.specificity[1]||t.specificity[2]-e.specificity[2]||t.specificity[3]-e.specificity[3]||t.index-e.index}function m(e,t){for(var r=0;r<4;r++){if(e[r]>t[r])return e;if(t[r]>e[r])return t}return e}function g(){y.setAttribute("data-loading","true"),setTimeout(function(){var e,r,a,s=t.body.querySelectorAll("[data-style-computed]");for(e=0,r=s.length;e<r;e++)s[e].computedStyles={};var n,l,u,c,p,g,h,b,v,x=t.styleSheets,k=0;for(e=0,a=x.length;e<a;e++)n=x[e],function(e){i(n,function(r,i){if(o(r,function(r){l=r.selectorText.split(",");for(var a=0;u=l[a];a++){c=_.calculate(u)[0].specificity.split(",").map(Number);try{p=t.body.querySelectorAll(u)}catch(o){continue}for(var s=0,n=p.length;s<n;s++){g=p[s],g.computedStyles=g.computedStyles||{};for(var y=0,x=r.style.length;y<x;y++){h=r.style[y],b=d(r.style,h),g.computedStyles[h]=g.computedStyles[h]||[],v=g.computedStyles[h];for(var k=!1,A=0,w=v.length;A<w;A++)if(v[A].selector===r.selectorText&&v[A].styleSheet===i){v[A].specificity=m(v[A].specificity,c),k=!0;break}k||(v.push({value:b,styleSheet:i,specificity:c,selector:r.selectorText,index:e}),g.setAttribute("data-style-computed","true")),v.sort(f)}}}}),++k===a){y.removeAttribute("data-loading");var s=new CustomEvent("styleSheetsParsed",{count:k});t.dispatchEvent(s)}})}(e)},250)}var h=300,y=t.createElement("div");y.classList.add("audit-push-results"),y.innerHTML="<div></div>",t.body.appendChild(y);var b=t.createElement("div");b.setAttribute("class","audit-results"),t.body.appendChild(b),s(b);var v=t.createElement("code");v.setAttribute("class","language-markup");var x=t.createElement("pre");x.appendChild(v);var k=t.createElement("div");k.setAttribute("class","audit-results__title"),k.appendChild(x),b.appendChild(k);var A=t.createElement("div");A.setAttribute("class","audit-results__body"),b.appendChild(A);var w=t.createElement("style");w.setAttribute("data-style-skip","true");var S=".audit-results {position: fixed;bottom: -"+h+"px;left: 0;right: 0;height: "+h+"px;background: white;border-top: 0 solid black;transition: bottom 300ms, border 300ms;overflow-y: auto;z-index: 1000000}body.open-audit .audit-results {bottom: 0;border-top-width: 1px;}.audit-push-results {height: 0;transition: height 300ms;}.audit-push-results[data-loading] {position: fixed;left: 0;right: 0;top: 0;bottom: 0;background: rgba(166,166,166,.6);height: auto;z-index: 10000000;height: auto !important}.audit-push-results[data-loading] div {background-color: #fff;border-radius: 100%;margin: 2px;-webkit-animation-fill-mode: both;animation-fill-mode: both;border: 3px solid #fff;border-bottom-color: transparent;height: 100px;width: 100px;background: transparent !important;-webkit-animation: styleRotate 0.75s 0s linear infinite;animation: styleRotate 0.75s 0s linear infinite;position: absolute;top: 50%;left: 50%;margin-left: -50px;margin-top: -50px;}body.open-audit .audit-push-results {height: "+h+'px;}.audit-results__body {padding: 1em;}.audit-results__body li {margin-bottom: 10px;}.audit-results__body div:first-child {display: none;}.audit-results__body input[type="checkbox"] {float: none;margin: 0;padding: 0;}.audit-results__body label {font-size: 16px;padding-left: 0;}.audit-results__body code {margin-bottom: 4px;display: inline-block;}.audit-results pre[class*=language-] {border-radius: 0;margin: 0;}.audit-results pre[class*=language-]>code[data-language]::before {display: none;}[data-style-audit] {background: salmon !important;cursor: pointer !important;}[data-style-using] {outline: 1px dashed midnightblue !important}@keyframes styleRotate {0%, {-webkit-transform: rotate(0deg);transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@-moz-keyframes styleRotate {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@-webkit-keyframes styleRotate {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@-o-keyframes styleRotate {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@-ms-keyframes styleRotate {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}';if(w.appendChild(t.createTextNode(S)),t.head.appendChild(w),!e.Prism){var C=t.createElement("script");C.setAttribute("async",!0),C.src="https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.js",t.body.appendChild(C);var E=t.createElement("link");E.setAttribute("rel","stylesheet"),E.href="https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.min.css",E.setAttribute("data-style-skip","true"),t.head.appendChild(E)}var L={},T={"float":"cssFloat","margin-left-value":"marginLeft","margin-left-ltr-source":"","margin-left-rtl-source":"","margin-right-value":"marginRight","margin-right-ltr-source":"","margin-right-rtl-source":"","padding-right-value":"paddingRight","padding-right-ltr-source":"","padding-right-rtl-source":"","padding-left-value":"paddingLeft","padding-left-ltr-source":"","padding-left-rtl-source":""},_=function(){var e,t;return e=function(e){var r,a,i,o,s=[];for(r=e.split(","),i=0,o=r.length;i<o;i+=1)a=r[i],a.length>0&&s.push(t(a));return s},t=function(e){var t,r=e,a={a:0,b:0,c:0},i=[],o=/(\[[^\]]+\])/g,s=/(#[^\s\+>~\.\[:]+)/g,n=/(\.[^\s\+>~\.\[:]+)/g,l=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,d=/(:[\w-]+\([^\)]*\))/gi,u=/(:[^\s\+>~\.\[:]+)/g,c=/([^\s\+>~\.\[:]+)/g;return t=function(t,o){var s,n,l,d,u,c;if(t.test(r))for(s=r.match(t),n=0,l=s.length;n<l;n+=1)a[o]+=1,d=s[n],u=r.indexOf(d),c=d.length,i.push({selector:e.substr(u,c),type:o,index:u,length:c}),r=r.replace(d,Array(c+1).join(" "))},function(){var e=function(e){var t,a,i,o;if(e.test(r))for(t=r.match(e),a=0,i=t.length;a<i;a+=1)o=t[a],r=r.replace(o,Array(o.length+1).join("A"))},t=/\\[0-9A-Fa-f]{6}\s?/g,a=/\\[0-9A-Fa-f]{1,5}\s/g,i=/\\./g;e(t),e(a),e(i)}(),function(){var e=/:not\(([^\)]*)\)/g;e.test(r)&&(r=r.replace(e," $1 "))}(),function(){var e,t,a,i,o=/{[^]*/gm;if(o.test(r))for(e=r.match(o),t=0,a=e.length;t<a;t+=1)i=e[t],r=r.replace(i,Array(i.length+1).join(" "))}(),t(o,"b"),t(s,"a"),t(n,"b"),t(l,"c"),t(d,"b"),t(u,"b"),r=r.replace(/[\*\s\+>~]/g," "),r=r.replace(/[#\.]/g," "),t(c,"c"),i.sort(function(e,t){return e.index-t.index}),{selector:e,specificity:"0,"+a.a.toString()+","+a.b.toString()+","+a.c.toString(),parts:i}},{calculate:e}}();"undefined"!=typeof exports&&(exports.calculate=_.calculate);var R={elms:[]},H=/([0-9]){1,3}/g;e.auditStyleGuide=u,t.body.addEventListener("click",function(e){var r=e.target;if(r){do{if(null!==r.getAttribute("data-style-audit"))return e.preventDefault(),void p(r);if(r.classList.contains("audit-results"))return}while(r=r.parentElement);try{t.body.classList.remove("open-audit")}catch(a){}}},!0),e.parseStyleSheets=g})(window,document);