diff --git a/libraries/cms/html/behavior.php b/libraries/cms/html/behavior.php
index 1c07cf22c1fbc..1ccc6d9a144a5 100644
--- a/libraries/cms/html/behavior.php
+++ b/libraries/cms/html/behavior.php
@@ -577,8 +577,11 @@ public static function colorpicker()
jQuery(document).ready(function (){
jQuery('.minicolors').each(function() {
jQuery(this).minicolors({
+ alpha: jQuery(this).attr('data-alpha') || false,
control: jQuery(this).attr('data-control') || 'hue',
- position: jQuery(this).attr('data-position') || 'right',
+ keywords: jQuery(this).attr('data-keywords') || '',
+ opacity: jQuery(this).attr('data-validate') === 'color' ? false : jQuery(this).attr('data-alpha') || false,
+ position: jQuery(this).attr('data-position') || 'default',
theme: 'bootstrap'
});
});
diff --git a/libraries/joomla/form/fields/color.php b/libraries/joomla/form/fields/color.php
index 98328c982aae3..2b83a8321c91e 100644
--- a/libraries/joomla/form/fields/color.php
+++ b/libraries/joomla/form/fields/color.php
@@ -40,7 +40,23 @@ class JFormFieldColor extends JFormField
* @var mixed
* @since 3.2
*/
- protected $position = 'right';
+ protected $position = 'default';
+
+ /**
+ * The keywords.
+ *
+ * @var string
+ * @since 3.5
+ */
+ protected $keywords = '';
+
+ /**
+ * The alpha.
+ *
+ * @var boolean
+ * @since 3.5
+ */
+ protected $alpha = false;
/**
* The colors.
@@ -72,6 +88,8 @@ public function __get($name)
switch ($name)
{
case 'control':
+ case 'keywords':
+ case 'alpha':
case 'exclude':
case 'colors':
case 'split':
@@ -98,6 +116,10 @@ public function __set($name, $value)
case 'split':
$value = (int) $value;
case 'control':
+ case 'keywords':
+ $this->$name = (string) $value;
+ break;
+ case 'alpha':
case 'exclude':
case 'colors':
$this->$name = (string) $value;
@@ -128,10 +150,12 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
if ($return)
{
- $this->control = isset($this->element['control']) ? (string) $this->element['control'] : 'hue';
- $this->position = isset($this->element['position']) ? (string) $this->element['position'] : 'right';
- $this->colors = (string) $this->element['colors'];
- $this->split = isset($this->element['split']) ? (int) $this->element['split'] : 3;
+ $this->control = isset($this->element['control']) ? (string) $this->element['control'] : 'hue';
+ $this->position = isset($this->element['position']) ? (string) $this->element['position'] : 'default';
+ $this->keywords = isset($this->element['keywords']) ? (string) $this->element['keywords'] : '';
+ $this->alpha = isset($this->element['alpha']) ? $this->element['alpha'] : false;
+ $this->colors = (string) $this->element['colors'];
+ $this->split = isset($this->element['split']) ? (int) $this->element['split'] : 3;
}
return $return;
@@ -152,22 +176,48 @@ protected function getInput()
// Control value can be: hue (default), saturation, brightness, wheel or simple
$control = $this->control;
- // Position of the panel can be: right (default), left, top or bottom
+ // Position of the panel can be: right (default), left, top or bottom (default rtl is left)
$position = ' data-position="' . $this->position . '"';
- $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
+ // Validation of data can be: color (hex color value)
+ $validate = $this->validate ? ' data-validate="' . $this->validate . '"' : '';
+
+ $onchange = ! empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
$class = $this->class;
$required = $this->required ? ' required aria-required="true"' : '';
$disabled = $this->disabled ? ' disabled' : '';
$autofocus = $this->autofocus ? ' autofocus' : '';
$color = strtolower($this->value);
+ $color = ! $color ? '' : $color;
- if (!$color || in_array($color, array('none', 'transparent')))
+ if (in_array($color, array('none', 'transparent')))
{
- $color = 'none';
+ $color = 'transparent';
+ $alpha = '0';
+ }
+ elseif (in_array($color, array('inherit', 'initial')))
+ {
+ $color = $color;
+ $alpha = '1';
+ }
+ elseif (strpos($color, 'rgba') !== false)
+ {
+ $color_rgba = str_replace(array('rgba(', ')'), '', $color);
+ $rgba_array = explode(',', $color_rgba);
+
+ $hex_R = dechex($rgba_array[0]);
+ $hex_G = dechex($rgba_array[1]);
+ $hex_B = dechex($rgba_array[2]);
+ $alpha = $rgba_array[3];
+
+ $R = (strlen($hex_R) < 2) ? '0' . $hex_R : $hex_R;
+ $G = (strlen($hex_G) < 2) ? '0' . $hex_G : $hex_G;
+ $B = (strlen($hex_B) < 2) ? '0' . $hex_B : $hex_B;
+
+ $color = '#' . $R . $G . $B;
}
- elseif ($color['0'] != '#')
+ elseif ($color && $color['0'] != '#')
{
$color = '#' . $color;
}
@@ -179,10 +229,10 @@ protected function getInput()
$colors = strtolower($this->colors);
- if (empty($colors))
+ if (empty($colors) && ! $this->colors)
{
$colors = array(
- 'none',
+ 'transparent',
'#049cdb',
'#46a546',
'#9d261d',
@@ -203,7 +253,7 @@ protected function getInput()
$split = $this->split;
- if (!$split)
+ if ( ! $split)
{
$count = count($colors);
@@ -223,14 +273,14 @@ protected function getInput()
$split = $split ? $split : 3;
$html = array();
- $html[] = '