1
0
mirror of https://github.com/github/choosealicense.com synced 2024-11-10 13:38:53 +01:00
choosealicense.com/javascripts/selectivizr-min.js

5 lines
5.3 KiB
JavaScript
Raw Normal View History

2012-09-12 21:20:53 +02:00
/*!
2013-10-30 18:29:54 +01:00
* selectivizr v1.0.3b - (c) Keith Clark, freely distributable under the terms of the MIT license.
2012-09-12 21:20:53 +02:00
* selectivizr.com
*/
2013-10-30 18:29:54 +01:00
!function(e){function t(e){return e.replace(H,V).replace(I,function(e,t,a){for(var s=a.split(","),c=0,l=s.length;l>c;c++){var i=u(s[c])+K,o=[];s[c]=i.replace(L,function(e,t,a,s,c){if(t)return o.length>0&&(O.push({selector:i.substring(0,c),patches:o}),o=[]),t;var l=a?n(a):r(s);return l?(o.push(l),"."+l.className):e})}return t+s.join(",")})}function r(e){return!G||G.test(e)?{className:c(e),applyClass:!0}:null}function n(t){var r,n,a=!0,s=c(t.slice(1)),l=":not("==t.substring(0,5);l&&(t=t.slice(5,-1));var i=t.indexOf("(");if(i>-1&&(t=t.substring(0,i)),":"==t.charAt(0))switch(t.slice(1)){case"root":a=function(e){return l?e!=E:e==E};break;case"target":if(8==A){a=function(t){var r=function(){var e=location.hash,r=e.slice(1);return l?e==J||t.id!=r:e!=J&&t.id==r};return p(e,"hashchange",function(){f(t,s,r())}),r()};break}return!1;case"checked":a=function(e){return U.test(e.type)&&p(e,"propertychange",function(){"checked"==event.propertyName&&f(e,s,e.checked!==l)}),e.checked!==l};break;case"disabled":l=!l;case"enabled":a=function(e){return D.test(e.tagName)?(p(e,"propertychange",function(){"$disabled"==event.propertyName&&f(e,s,e.$disabled===l)}),C.push(e),e.$disabled=e.disabled,e.disabled===l):":enabled"==t?l:!l};break;case"focus":r="focus",n="blur";case"hover":r||(r="mouseenter",n="mouseleave"),a=function(e){return p(e,l?n:r,function(){f(e,s,!0)}),p(e,l?r:n,function(){f(e,s,!1)}),l};break;default:if(!z.test(t))return!1}return{className:s,applyClass:a}}function a(){for(var e,t,r,n,a=0;a<O.length;a++){t=O[a].selector,r=O[a].patches,n=t.replace(B,J),(n==J||n.charAt(n.length-1)==K)&&(n+="*");try{e=k(n)}catch(c){l("Selector '"+t+"' threw exception '"+c+"'")}if(e)for(var i=0,o=e.length;o>i;i++){for(var u=e[i],f=u.className,p=0,h=r.length;h>p;p++){var g=r[p];s(u,g)||!g.applyClass||g.applyClass!==!0&&g.applyClass(u)!==!0||(f=d(f,g.className,!0))}u.className=f}}}function s(e,t){return new RegExp("(^|\\s)"+t.className+"(\\s|$)").test(e.className)}function c(e){return j+"-"+(6==A&&w?M++:e.replace(P,function(e){return e.charCodeAt(0)}))}function l(t){e.console&&e.console.log(t)}function i(e){return e.replace(F,V)}function o(e){return i(e).replace(Y,K)}function u(e){return o(e.replace(Q,V).replace(W,V))}function f(e,t,r){var n=e.className,a=d(n,t,r);a!=n&&(e.className=a,e.parentNode.className+=J)}function d(e,t,r){var n=RegExp("(^|\\s)"+t+"(\\s|$)"),a=n.test(e);return r?a?e:e+K+t:a?i(e.replace(n,V)):e}function p(e,t,r){e.attachEvent("on"+t,r)}function h(){if(e.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){return null}}function g(e){return T.open("GET",e,!1),T.send(),200==T.status?T.responseText:J}function v(e,t,r){function n(e){return e.substring(0,e.indexOf("//"))}function a(e){return e.substring(0,e.indexOf("/",8))}if(t||(t=_),"//"==e.substring(0,2)&&(e=n(t)+e),/^https?:\/\//i.test(e))return r||a(t)==a(e)?e:null;if("/"==e.charAt(0))return a(t)+e;var s=t.split(/[?#]/)[0];return"?"!=e.charAt(0)&&"/"!=s.charAt(s.length-1)&&(s=s.substring(0,s.lastIndexOf("/")+1)),s+e}function b(e){return e?g(e).replace(R,J).replace(X,function(t,r,n,a,s,c){var l=b(v(n||s,e));return c?"@media "+c+" {"+l+"}":l}).replace(q,function(t,r,n,a){return n=n||J,r?t:" url("+n+v(a,e,!0)+n+") "}):J}function m(){for(var e,r,n=0;n<S.styleSheets.length;n++)r=S.styleSheets[n],r.href!=J&&(e=v(r.href),e&&(r.cssText=r.rawCssText=t(b(e))))}function y(){a(),C.length>0&&setInterval(function(){for(var e=0,t=C.length;t>e;e++){var r=C[e];r.disabled!==r.$disabled&&(r.disabled?(r.disabled=!1,r.$disabled=!0,r.disabled=!0):r.$disabled=r.disabled)}},250)}function N(e,t){var r=!1,n=!0,a=function(n){("readystatechange"!=n.type||"complete"==S.readyState)&&(("load"==n.type?e:S).detachEvent("on"+n.type,a,!1),!r&&(r=!0)&&t.call(e,n.type||n))},s=function(){try{E.doScroll("left")}catch(e){return setTimeout(s,50),void 0}a("poll")};if("complete"==S.readyState)t.call(e,J);else{if(S.createEventObject&&E.doScroll){try{n=!e.frameElement}catch(c){}n&&s()}p(S,"readystatechange",a),p(e,"load",a)}}var $=navigator.userAgent.match(/MSIE (\d+)/);if(!$)return