Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

shorter alpha opacity filter, more tests, case-insensitive background…

…-position replace
  • Loading branch information...
commit 81e1d7f07f89f781350e73fbc4222ffbb8f0ed62 1 parent 77b9f9d
@stoyan stoyan authored
View
6 ports/js/cssmin.js
@@ -52,6 +52,10 @@ YAHOO.compressor.cssmin = function (css, linebreakpos) {
match = match.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments[i]);
}
}
+
+ // minify alpha opacity in filter strings
+ match = match.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
+
preservedTokens.push(match);
return quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___" + quote;
});
@@ -161,6 +165,8 @@ YAHOO.compressor.cssmin = function (css, linebreakpos) {
}
});
+ // shorter opacity IE filter
+ css = css.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
// Remove empty rules.
css = css.replace(/[^\};\{\/]+\{\}/g, "");
View
8 src/com/yahoo/platform/yui/compressor/CssCompressor.java
@@ -78,6 +78,9 @@ public void compress(Writer out, int linebreakpos)
}
}
+ // minify alpha opacity in filter strings
+ token = token.replaceAll("(?i)progid:DXImageTransform.Microsoft.Alpha\\(Opacity=", "alpha(opacity=");
+
preservedTokens.add(token);
String preserver = quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___" + quote;
m.appendReplacement(sb, preserver);
@@ -163,7 +166,7 @@ public void compress(Writer out, int linebreakpos)
css = css.replaceAll(":0 0 0(;|})", ":0$1");
css = css.replaceAll(":0 0(;|})", ":0$1");
// Replace background-position:0; with background-position:0 0;
- css = css.replaceAll("background-position:0(;|})", "background-position:0 0$1");
+ css = css.replaceAll("(?i)background-position:0(;|})", "background-position:0 0$1");
// Replace 0.6 to .6, but only when preceded by : or a white-space
css = css.replaceAll("(:|\\s)0+\\.(\\d+)", "$1.$2");
@@ -210,6 +213,9 @@ public void compress(Writer out, int linebreakpos)
m.appendTail(sb);
css = sb.toString();
+ // shorter opacity IE filter
+ css = css.replaceAll("(?i)progid:DXImageTransform.Microsoft.Alpha\\(Opacity=", "alpha(opacity=");
+
// Remove empty rules.
css = css.replaceAll("[^\\}\\{/;]+\\{\\}", "");
View
2  tests/background-position.css
@@ -0,0 +1,2 @@
+a {background-position: 0 0 0 0;}
+b {BACKGROUND-POSITION: 0 0;}
View
1  tests/background-position.css.min
@@ -0,0 +1 @@
+a{background-position:0 0}b{background-position:0 0}
View
14 tests/opacity-filter.css
@@ -0,0 +1,14 @@
+/* example from https://developer.mozilla.org/en/CSS/opacity */
+pre { /* make the box translucent (80% opaque) */
+ border: solid red;
+ opacity: 0.8; /* Firefox, Safari(WebKit), Opera */
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
+ filter: PROGID:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE 4-7 */
+ zoom: 1; /* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */
+}
+
+/** and again */
+code {
+ -ms-filter: "PROGID:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE 4-7 */
+}
View
1  tests/opacity-filter.css.min
@@ -0,0 +1 @@
+pre{border:solid red;opacity:.8;-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80);zoom:1}code{-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80)}
Please sign in to comment.
Something went wrong with that request. Please try again.