diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 5be08f4ef4..c9dac2fb58 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -88,15 +88,21 @@ class html * Please note: it need to be called before the call to egw_header() !!! * * @param string $name the name of the input-field - * @param string $value the actual value for the input-field, default '' - * @param string $title tooltip/title for the picker-activation-icon + * @param string $value='' the actual value for the input-field, default '' + * @param string $title='' tooltip/title for the picker-activation-icon + * @param string $options='' options for input * @return string the html */ - static function inputColor($name,$value='',$title='') + static function inputColor($name,$value='',$title='',$options='') { - $id = str_replace(array('[',']'),array('_',''),$name).'_colorpicker'; - $onclick = "javascript:window.open('".self::$api_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+encodeURIComponent(document.getElementById('$id').value),'colorPicker','width=240,height=187,scrollbars=no,resizable=no,toolbar=no');"; - return ' '. + $options .= ' id="'.htmlspecialchars($id=str_replace(array('[',']'),array('_',''),$name).'_colorpicker').'"'; + $onclick = "javascript:egw_openWindowCentered2('".self::$api_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+encodeURIComponent(document.getElementById('$id').value),'colorPicker',240,187);"; + if (preg_match('/^#[0-9A-F]{6}$/i',$value)) + { + $options .= ' style="background-color: '.$value.'"'; + } + $options .= ' onChange="this.style.backgroundColor=this.value.match(/^(#[0-9A-F]+|[a-z]+)$/i)?this.value:\'#FFFFFF\'+(this.value=\'\')"'; + return self::input($name, $value, 'text', $options.' size="7" maxsize="7"').' '. ''. '"; } @@ -659,9 +665,14 @@ class html */ static function input($name,$value='',$type='',$options='' ) { - if ($type) + switch ((string)$type) { - $type = 'type="'.$type.'"'; + case 'color': + return self::inputColor($name, $value, '', $options); + case ''; + break; + default: + $type = 'type="'.$type.'"'; } return "\n"; } diff --git a/phpgwapi/js/colorpicker/select_color.html b/phpgwapi/js/colorpicker/select_color.html index cc3743d1a9..bb1ee87b06 100644 --- a/phpgwapi/js/colorpicker/select_color.html +++ b/phpgwapi/js/colorpicker/select_color.html @@ -1,22 +1,22 @@