});
// replace standard colors with hex values (only if color name is longer then hex value)
- replace(/(color|background):(\w+)/g, function(match, property, colorName) {
- if (CleanCSS.colors[colorName])
- return property + ':' + CleanCSS.colors[colorName];
- else
- return match;
- });
+ var pattern = "(" + Object.keys(CleanCSS.colors).join('|') + ")";
+ var colorSwitcher = function(match, prefix, colorName, suffix) {
+ return prefix + CleanCSS.colors[colorName] + suffix;
+ };
+ replace(new RegExp("(.)" + pattern + "([;\\}!\)])", 'g'), colorSwitcher);
+ replace(new RegExp("(,)" + pattern + "(,)", 'g'), colorSwitcher);
// replace #f00 with red as it's shorter
replace(/([: ,\(])#f00/g, '$1red');
#bar-liberation .god .godenabled a{background:#3c3c3c;color:#fff}
#bar-liberation .god a.godenter{background:url(http://s0.libe.com/libe/img/common/icon_godenter.png?9ffa63824b5c) no-repeat center center #fff}
#bar-liberation .god a.godquit{background:url(http://s0.libe.com/libe/img/common/icon_godquit.png?a59104f30cfb) no-repeat center center #000}
-#bar-liberation .god a.godquit:hover{background:url(http://s0.libe.com/libe/img/common/icon_godenter.png?9ffa63824b5c) no-repeat center center yellow}
+#bar-liberation .god a.godquit:hover{background:url(http://s0.libe.com/libe/img/common/icon_godenter.png?9ffa63824b5c) no-repeat center center #ff0}
#bar-liberation .god a.jumptoadmin{background:url(http://s0.libe.com/back/img/icon_home.png?c1de55b52ccc) no-repeat center center #fff}
#bar-liberation .god a.jumptoedit{background:url(http://s0.libe.com/back/img/icon_changelink.png?4a31d309d5db) no-repeat center center #fff}
#mainContent .god{font-size:10px;padding:6px;border-radius:2px;-moz-border-radius:4px;-webkit-border-radius:4px}
'a{outline:0}'
],
'display:none not changed': 'a{display:none}',
- 'longer background declaration not changed': 'html{background:none repeat scroll 0 0 white}',
+ 'longer background declaration not changed': 'html{background:none repeat scroll 0 0 #fff}',
'mixed zeros not changed': 'div{margin:0 0 1px 2px}',
'mixed zeros not changed #2': 'div{padding:0 1px 0 3px}',
'mixed zeros not changed #3': 'div{padding:10px 0 0 1px}',
'a{color:white;border-color:black;background-color:fuchsia}p{background:yellow}',
'a{color:#fff;border-color:#000;background-color:#f0f}p{background:#ff0}'
],
+ 'color names to hex values with important': [
+ 'a{color:white !important}',
+ 'a{color:#fff!important}'
+ ],
+ 'color names to hex values in gradients': [
+ 'p{background:linear-gradient(-90deg,black,white)}',
+ 'p{background:linear-gradient(-90deg,#000,#fff)}'
+ ],
'hex value to color name if shorter': [
'p{color:#f00}',
'p{color:red}'
'p{background:-webkit-gradient(linear, left top, left bottom, from(#000), to(#f00))}',
'p{background:-webkit-gradient(linear,left top,left bottom,from(#000),to(red))}'
],
- 'border color': [
- 'p{border:1px solid #f94311}',
- 'p{border:1px solid #f94311}'
+ 'border color - keep unchanged': 'p{border:1px solid #f94311}',
+ 'border color - hex to name': [
+ 'p{border:1em dotted #f00}',
+ 'p{border:1em dotted red}'
+ ],
+ 'border color - name to hex': [
+ 'p{border:1em dotted white}',
+ 'p{border:1em dotted #fff}'
+ ],
+ 'border color - rgb': [
+ 'p{border:1em dotted rgb(255,0,0)}',
+ 'p{border:1em dotted red}'
],
'colors and colons': 'a{background-image:linear-gradient(top,red,#e6e6e6)}',
'colors and parentheses': 'a{background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6))}'