10 defined(
'JPATH_PLATFORM') or die;
29 protected $type =
'Color';
37 protected $control =
'hue';
45 protected $position =
'right';
72 public function __get($name)
83 return parent::__get($name);
96 public function __set($name, $value)
101 $value = (int) $value;
105 $this->$name = (string) $value;
109 parent::__set($name, $value);
127 public function setup(SimpleXMLElement $element, $value, $group = null)
129 $return = parent::setup($element, $value, $group);
133 $this->control = isset($this->element[
'control']) ? (string) $this->element[
'control'] :
'hue';
134 $this->position = isset($this->element[
'position']) ? (string) $this->element[
'position'] :
'right';
135 $this->colors = (string) $this->element[
'colors'];
136 $this->split = isset($this->element[
'split']) ? (int) $this->element[
'split'] : 3;
149 protected function getInput()
152 $hint = $this->translateHint ?
JText::_($this->hint) : $this->hint;
155 $control = $this->control;
158 $position =
' data-position="' . $this->position .
'"';
160 $onchange = !empty($this->onchange) ?
' onchange="' . $this->onchange .
'"' :
'';
161 $class = $this->class;
162 $required = $this->required ?
' required aria-required="true"' :
'';
163 $disabled = $this->disabled ?
' disabled' :
'';
164 $autofocus = $this->autofocus ?
' autofocus' :
'';
166 $color = strtolower($this->value);
168 if (!$color || in_array($color, array(
'none',
'transparent')))
172 elseif ($color[
'0'] !=
'#')
174 $color =
'#' . $color;
177 if ($control ==
'simple')
179 $class =
' class="' . trim(
'simplecolors chzn-done ' . $class) .
'"';
180 JHtml::_(
'behavior.simplecolorpicker');
182 $colors = strtolower($this->colors);
203 $colors = explode(
',', $colors);
206 $split = $this->split;
210 $count = count($colors);
225 $split = $split ? $split : 3;
228 $html[] =
'<select name="' . $this->name .
'" id="' . $this->
id .
'"' . $disabled . $required
229 . $class . $position . $onchange . $autofocus .
' style="visibility:hidden;width:22px;height:1px">';
231 foreach ($colors as $i => $c)
233 $html[] =
'<option' . ($c == $color ?
' selected="selected"' :
'') .
'>' . $c .
'</option>';
235 if (($i + 1) % $split == 0)
237 $html[] =
'<option>-</option>';
241 $html[] =
'</select>';
243 return implode(
'', $html);
247 $class =
' class="' . trim(
'minicolors ' . $class) .
'"';
248 $control = $control ?
' data-control="' . $control .
'"' :
'';
249 $readonly = $this->readonly ?
' readonly' :
'';
250 $hint = $hint ?
' placeholder="' . $hint .
'"' :
' placeholder="#rrggbb"';
251 $autocomplete = !$this->autocomplete ?
' autocomplete="off"' :
'';
254 JHtml::_(
'jquery.framework');
255 JHtml::_(
'script',
'system/html5fallback.js',
false,
true);
257 JHtml::_(
'behavior.colorpicker');
259 return '<input type="text" name="' . $this->name .
'" id="' . $this->
id .
'"' .
' value="'
260 . htmlspecialchars($color, ENT_COMPAT,
'UTF-8') .
'"' . $hint . $class . $position . $control
261 . $readonly . $disabled . $required . $onchange . $autocomplete . $autofocus .
'/>';