* zin: refactor
This commit is contained in:
@@ -62,8 +62,8 @@ class props extends \zin\utils\dataset
|
||||
if($prop === 'class' || $prop === '.') return $this->class->set($value);
|
||||
if($prop === 'style' || $prop === '~') return $this->style->set($value);
|
||||
if(strpos($prop, '~') === 0) return $this->style->set(substr($prop, 1), $value);
|
||||
if($prop === '--') return $this->style->var($value);
|
||||
if(strpos($prop, '--') === 0) return $this->style->var(substr($prop, 2), $value);
|
||||
if($prop === '--') return $this->style->cssVar($value);
|
||||
if(strpos($prop, '--') === 0) return $this->style->cssVar(substr($prop, 2), $value);
|
||||
if($prop === '!') return $this->hx($value);
|
||||
if(strpos($prop, '!') === 0) return $this->hx(substr($prop, 1), $value);
|
||||
if(strpos($prop, ':') === 0) return $this->set('data-' . substr($prop, 1), $value);
|
||||
|
||||
@@ -53,27 +53,27 @@ class style extends dataset
|
||||
*
|
||||
* // Create a style object and set
|
||||
* $style = new style();
|
||||
* $style->var('text-size', '14px');
|
||||
* $style->cssVar('text-size', '14px');
|
||||
*
|
||||
* // Set multiple variables
|
||||
* $style->var(array('text-color' => 'yellow', 'background-image': 'none'));
|
||||
* $style->cssVar(array('text-color' => 'yellow', 'background-image': 'none'));
|
||||
*
|
||||
* // Get variable value
|
||||
* echo $style->var('text-size'); // Output "14px"
|
||||
* echo $style->cssVar('text-size'); // Output "14px"
|
||||
*
|
||||
* // Get all variables value
|
||||
* echo $style->var();
|
||||
* echo $style->cssVar();
|
||||
* // Output array('text-size' => '14px', 'color' => 'yellow', 'background': 'none');
|
||||
*
|
||||
* // Remove variable by setting value with an empty string
|
||||
* $style->var('text-color', '');
|
||||
* $style->cssVar('text-color', '');
|
||||
*
|
||||
* @access public
|
||||
* @param array|string $name - Variable name or variables list
|
||||
* @param mixed $value - Property value
|
||||
* @return mixed
|
||||
*/
|
||||
public function var($name = '', $value = NULL)
|
||||
public function cssVar($name = '', $value = NULL)
|
||||
{
|
||||
/* Support for setting multiple variables by an array */
|
||||
if(is_array($name))
|
||||
|
||||
Reference in New Issue
Block a user