Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
@version 1.2
Paramètres
string $subvalue:
Return value
string
1 call to csstidy_optimise::compress_numbers()
- csstidy_optimise::subvalue dans advagg_css_compress/
csstidy/ class.csstidy_optimise.inc - Optimises a sub-value @access public @version 1.0
Fichier
-
advagg_css_compress/
csstidy/ class.csstidy_optimise.inc, line 366
Classe
- csstidy_optimise
- CSS Optimising Class
Code
function compress_numbers($subvalue) {
$unit_values =& $GLOBALS['csstidy']['unit_values'];
$color_values =& $GLOBALS['csstidy']['color_values'];
// for font:1em/1em sans-serif...;
if ($this->property === 'font') {
$temp = explode('/', $subvalue);
}
else {
$temp = array(
$subvalue,
);
}
for ($l = 0; $l < count($temp); $l++) {
// if we are not dealing with a number at this point, do not optimise anything
$number = $this->AnalyseCssNumber($temp[$l]);
if ($number === false) {
return $subvalue;
}
// Fix bad colors
if (in_array($this->property, $color_values)) {
$temp[$l] = '#' . $temp[$l];
continue;
}
if (abs($number[0]) > 0) {
if ($number[1] == '' && in_array($this->property, $unit_values, true)) {
$number[1] = 'px';
}
}
else {
$number[1] = '';
}
$temp[$l] = $number[0] . $number[1];
}
return count($temp) > 1 ? $temp[0] . '/' . $temp[1] : $temp[0];
}