Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #112 from codler/css3finalize

Added css3finalize 2.0
  • Loading branch information...
commit dffb60e17f19baca3cbd2946ae3525be0dcd8fb3 2 parents 140cc3b + 2f4ee0b
@ryankirkman ryankirkman authored
View
15 ajax/libs/css3finalize/2.0/jquery.css3finalize.min.js
@@ -0,0 +1,15 @@
+/**
+ * @author Han Lin Yap < http://zencodez.net/ >
+ * @copyright 2011 zencodez.net
+ * @license http://creativecommons.org/licenses/by-sa/3.0/
+ * @package Css3-Finalize
+ * @version 2.0 - 2011-11-04
+ * @website https://github.com/codler/jQuery-Css3-Finalize
+ *
+ * == Description ==
+ * With this plugin you can write CSS without the vendor prefixes.
+ *
+ * == Example Usage ==
+ * $('style').cssFinalize(); // parse all style-tags
+ */
+(function(a){if(a.cssFinalize){return}a.cssFinalizeSetup={shim:true,node:"style,link",checkMedia:true};a.fn.cssFinalize=function(b){if(!b||typeof b!="object"){b={}}b.node=this;a.cssFinalize(b);return this};a.cssFinalize=function(g){var r=document.createElement("div");g=a.extend({},a.cssFinalizeSetup,g);g.checkMedia=!!(g.checkMedia&&window.matchMedia);var h=[];var w;if(window.getComputedStyle){var m=getComputedStyle(document.documentElement,null);if(m.length){for(var v=0;v<m.length;v++){if(m[v].charAt(0)==="-"){var j=m[v].indexOf("-",1);h.push(m[v].substr(j+1));w=m[v].substr(1,j-1)}}}else{var z=function(i){return i.replace(/[A-Z]/g,function(D){return"-"+D.toLowerCase()})};for(var v in m){var x=z(v);if(x.indexOf("-o-")===0){h.push(x.substr(3))}}w="o"}}else{if(!g.shim){return true}w="ms"}if(w=="ms"){h.push("transform");h.push("transform-origin")}function f(i,D){return function(E){return(w==i)?D:false}}var p={};if(parseInt(a.browser.version.substr(0,1))<2){p={"border-top-left-radius":[f("moz","-moz-border-radius-topleft")],"border-top-right-radius":[f("moz","-moz-border-radius-topright")],"border-bottom-right-radius":[f("moz","-moz-border-radius-bottomright")],"border-bottom-left-radius":[f("moz","-moz-border-radius-bottomleft")]}}function l(i){var D=a.camelCase(i);return(w=="ms")?D[0].toLowerCase()+D.substr(1):D}function y(i){i=i.replace(/\/\*((?:[^\*]|\*[^\/])*)\*\//g,"");i=i.replace(/\n/g,"");i=i.replace(/\r/g,"");i=i.replace(/\@import[^;]*;/g,"");return i}function B(F,E){var i=F.match(RegExp(E,"g"));var D=F.replace(new RegExp(E,"g"),"[|]").split("[|]");var G=[];for(v in D){G.push(D[v]);if(i&&i[v]){G.push(i[v])}}return G}function C(i,E){if(w=="ms"&&a.browser.version<=7){var D=a('<style class="css-finalized" '+((i.attr("media")&&i.attr("media").length>0)?'media="'+i.attr("media")+'"':"")+"/>");a("head:first").append(D);D[0].styleSheet.cssText=d(E)}else{i.after('<style class="css-finalized" '+((i.attr("media")&&i.attr("media").length>0)?'media="'+i.attr("media")+'"':"")+">"+d(E)+"</style>")}}function c(D,E){E=y(E);if(a.trim(E)===""){return}var F=e(E);var i=[];i=G(F);function G(I){var H=[];a.each(I,function(J,L){if(L.attributes){var K=s(L.attributes);if(!a.isEmptyObject(K)){H.push({selector:n(L.selector),attributes:K})}else{if(n(L.selector)!=L.selector){H.push({selector:n(L.selector),attributes:s(L.attributes,true)})}else{if(!g.checkMedia||(g.checkMedia&&L.selector.indexOf("@media")===0&&matchMedia(L.selector.substr(7)).matches)){H.push({selector:L.selector,attributes:G(L.attributes)})}}}}});return H}D.addClass("css-finalize-read");if(i.length>0){C(D,i)}}function e(K){var F;if(w=="ms"&&a.browser.version<=8){F=B(K,"({[^{}]*})")}else{F=K.split(/({[^{}]*})/)}if(F[F.length-1].indexOf("}")==-1){F.pop()}var G=[];var D=false;var L;var I=0;var J;var H=0;while(H<F.length){if(H%2===0){var E=a.trim(F[H]);if(D){if(E.indexOf("}")!=-1){E=E.substr(1);F[H]=E;J=F.splice(I,H-I);J.shift();J.unshift(L[1]);G[G.length-1].attributes=e(J.join(""));D=false;H=I;continue}}else{if(E.indexOf("{")!=-1){L=E.split("{");E=a.trim(L[0]);D=true;I=H}if(E!==""){G.push({selector:E})}}}else{if(!D){G[G.length-1].attributes=A(F[H].substr(1,F[H].length-2))}}H++}return G}function A(E){var D;E=E.replace(/url\(([^)]+)\)/g,function(F){return F.replace(/;/g,"[cssFinalize]")});if(w=="ms"&&a.browser.version<=8){D=B(E,"(:[^;]*;?)")}else{D=E.split(/(:[^;]*;?)/)}D.pop();var i={};a.map(D,function(G,F){if(F%2==1){i[a.trim(D[F-1])]=a.trim(G.substr(1).replace(";","").replace(/url\(([^)]+)\)/g,function(H){return H.replace(/\[cssFinalize\]/g,";")}))}});return i}function d(i){var D="";a.each(i,function(E,F){D+=F.selector+"{";if(a.isArray(F.attributes)){D+=d(F.attributes)}else{a.each(F.attributes,function(H,G){D+=H+":"+G+";"})}D+="}"});return D}function s(D,i){if(a.isArray(D)){if(i){return a.map(D,function(G,F){return{selector:G.selector,attributes:s(G.attributes,i)}})}else{return{}}}var E={};a.each(D,function(I,H){var K=false;var F=t(I);if(F){K=true;E[F]=H}var J=o(I,H,F);if(J){K=true;E[(F)?F:I]=J}var G=u(I,H);if(G){K=true;a.each(G,function(L,M){if(L=="filter"&&E[L]){E[L]+=" "+M}else{E[L]=M}})}if(i&&!K){E[I]=H}});return E}function t(D){if(D in p){for(prefix in p[D]){if(a.isFunction(p[D][prefix])){var i=p[D][prefix](D);if(i){return i}}else{if(w==p[D][prefix]||!w){return"-"+p[D][prefix]+"-"+D}}}}if(a.inArray(D,h)>-1){if(!(l(D) in r.style)||D=="mask"){if(l("-"+w+"-"+D) in r.style){return"-"+w+"-"+D}}}return false}function o(H,G,J){J=J||H;if(H=="background-clip"||H=="background-origin"){r.style.cssText=J+":"+G;if(r.style[l(J)]!==undefined&&""+r.style[l(J)].indexOf(G)==-1){return G.split("-")[0]}}if(H=="transition"||H=="transition-property"){var L=G.split(/\s?,\s?/);var i=[];for(var D in L){var I,M;if(H=="transition"){I=L[D].split(" ")[0]}else{I=L[D]}if((M=t(I))!==false){i.push(M+L[D].substr(I.length))}else{i.push(L[D])}}return i.join(",")}if(w=="moz"){if(G.indexOf("calc")===0){return"-moz-"+G}if(G.indexOf("element")===0){return"-moz-"+G}}var O;if(H=="background"||H=="background-image"){if(G.indexOf("linear-gradient")===0){if(w=="webkit"){O=G.replace(/^linear-gradient\s?\(\s?(.*?)\s?\)$/,"$1").split(/,\s?/);if(O.length==2){return"-webkit-gradient(linear, 0% 0%, 0% 100%, from("+O[0]+"), to("+O[1]+"))"}var N="";if(O.length>=3){var E="0% 0%, 0% 100%";if(O[0]==="left"){E="0% 0%, 100% 0%"}if(O.length>3){var K=O.slice(2,O.length-1);a.each(K,function(Q,R){var P=R.split(/ /);if(P.length===2){N+="color-stop("+P[1]+", "+P[0]+"),"}})}return"-webkit-gradient(linear, "+E+", from("+O[1]+"), "+N+" to("+O[O.length-1]+"))"}}else{if(w=="ms"&&a.browser.version==9){O=G.replace(/^linear-gradient\s?\(\s?(.*?)\s?\)$/,"$1").split(/,\s?/);if(O.length==2){var F='<svg xmlns="http://www.w3.org/2000/svg" version="1.0"><defs><linearGradient id="gradient" x1="0" y1="0" x2="0" y2="100%"><stop offset="0%" style="stop-color: '+O[0]+';"/><stop offset="100%" style="stop-color: '+O[1]+';"/></linearGradient></defs><rect x="0" y="0" fill="url(#gradient)" width="100%" height="100%" /></svg>';return"url(data:image/svg+xml,"+escape(F)+")"}}}return"-"+w+"-"+G}else{if(G.indexOf("radial-gradient")===0){return"-"+w+"-"+G}}}return false}function u(E,D){if(g.shim){if(w=="ms"){if(a.browser.version<=8){if(E.toUpperCase()=="OPACITY"&&!a.support.opacity&&!isNaN(D)){return{filter:"alpha(opacity="+D*100+")",zoom:1}}if(E.toUpperCase()==="BACKGROUND-COLOR"&&D.indexOf("rgba")===0){D=b(D);return{background:"url(#)",filter:"progid:DXImageTransform.Microsoft.gradient(startColorStr='"+D+"',EndColorStr='"+D+"')"}}if((E.toUpperCase()=="BACKGROUND"||E.toUpperCase()==="BACKGROUND-IMAGE")&&D.indexOf("linear-gradient")===0){var i=D.replace(/^linear-gradient\s?\(\s?(.*?)\s?\)$/,"$1").split(/,\s?/);if(i.length==2){return{background:"url(#)",filter:"progid:DXImageTransform.Microsoft.gradient(startColorStr='"+i[0]+"',EndColorStr='"+i[1]+"')"}}}}}}return false}function n(i){if(w=="moz"){i=i.replace("::selection","::-moz-selection");i=i.replace("::placeholder",":-moz-placeholder");i=i.replace("@keyframes","@-moz-keyframes")}else{if(w=="webkit"){i=i.replace("@keyframes","@-webkit-keyframes");i=i.replace("::placeholder","::-webkit-input-placeholder")}}return i}function b(H){var E=H.replace(/^rgba\s?\(\s?(.*?)\s?\)$/,"$1").split(/,\s?/);var D=[];var G;for(var F=0;F<E.length;F++){if(F==3){E[F]*=255}G="0"+parseInt(E[F],10).toString(16);D.push(G.substr(G.length-2,2).toUpperCase())}D.splice(0,0,D.pop());return"#"+D.join("")}if(!(g.node instanceof jQuery)){g.node=a(g.node)}g.node.each(function(i,D){var E=a(this);if(E.hasClass("css-finalize-read")||E.hasClass("css-finalized")){return true}if(this.tagName=="LINK"&&E.attr("rel")=="stylesheet"){if(!g.checkMedia||(E.attr("media")&&E.attr("media").length>0&&matchMedia(E.attr("media")).matches)||!E.attr("media")){k(this.href,E)}}else{c(E,E.html())}});function k(i,D){var I=document.location,H=I.protocol||"http:";var G=/^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/.exec(i.toLowerCase());var E=!!(G&&(G[1]!=H||G[2]!=I.hostname||(G[3]||(G[1]==="http:"?80:443))!=(I.port||(H==="http:"?80:443))));if(E){return}try{a("<div />").load(i,function(J){c(D,J)})}catch(F){}}for(property in p){if((newProperty=t(property))!==false){q(property,newProperty)}}for(property in h){if((newProperty=t(h[property]))!==false){q(h[property],newProperty)}}function q(D,i){i=l(i);a.cssHooks[l(D)]={get:function(G,F,E){return G.style[i]},set:function(E,F){E.style[i]=F}}}};a(function(){if(window.cssFinalize!==false){a.cssFinalize()}})})(jQuery);window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.appendChild(g);return function(h){g.innerHTML='&shy;<style media="'+h+'"> #mq-test-1 { width: 42px; }</style>';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document);
View
2  ajax/libs/css3finalize/package.json
@@ -1,7 +1,7 @@
{
"name": "css3finalize",
"filename": "jquery.css3finalize.min.js",
- "version": "1.45",
+ "version": "2.0",
"description": "Skip vendor prefixes",
"homepage": "https://github.com/codler/jQuery-Css3-Finalize",
"keywords": [
Please sign in to comment.
Something went wrong with that request. Please try again.