You are here

public function CSSCompression_Individuals::individuals in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg_css_compress/css-compressor-3.x/src/lib/Individuals.inc \CSSCompression_Individuals::individuals()

Runs special unit/directional compressions

Parameters

(string) prop: CSS Property:

(string) val: Value of CSS Property:

File

advagg_css_compress/css-compressor-3.x/src/lib/Individuals.inc, line 62

Class

CSSCompression_Individuals
CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com

Code

public function individuals($prop, $val) {

  // Properties should always be lowercase
  $prop = strtolower($prop);

  // Split up each definiton for color and numeric compressions
  $parts = preg_split($this->rspace, $val);
  foreach ($parts as &$v) {
    if (!$v || $v == '') {
      continue;
    }

    // Remove uneeded decimals/units
    if ($this->options['format-units']) {
      $v = $this->Numeric
        ->numeric($v);
    }

    // Color compression
    $v = $this->Color
      ->color($v);
  }
  $val = trim(implode(' ', $parts));

  // Special border radius handling
  if (preg_match($this->rborderradius, $prop)) {
    $val = $this
      ->borderRadius($prop, $val);
  }
  else {
    if ($this->options['directional-compress'] && count($parts) > 1 && preg_match($this->rdirectional, $prop)) {
      $val = $this
        ->directionals(strtolower($val));
    }
  }

  // Font-weight converter
  if ($this->options['fontweight2num'] && ($prop == 'font-weight' || $prop == 'font')) {
    $val = $this
      ->fontweight($val);
  }

  // Special font value conversions
  if ($prop == 'font') {
    $val = $this
      ->font($val);
  }

  // Special clip value compressions
  if ($prop == 'clip') {
    $val = $this
      ->clip($val);
  }

  // None to 0 converter
  $val = $this
    ->none($prop, $val);

  // MSIE Filters
  $val = $this
    ->filter($prop, $val);

  // Return for list retrival
  return array(
    $prop,
    $val,
  );
}