XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
formcolorpicker.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 
33 {
41  function XoopsFormColorPicker($caption, $name, $value = '#FFFFFF')
42  {
43  $this->XoopsFormText($caption, $name, 9, 7, $value);
44  }
45 
51  function render()
52  {
53  if (isset($GLOBALS['xoTheme'])) {
54  $GLOBALS['xoTheme']->addScript('include/color-picker.js');
55  } else {
56  echo '<script type="text/javascript" src="' . XOOPS_URL . '/include/color-picker.js"></script>';
57  }
58  $this->setExtra(' style="background-color:' . $this->getValue() . ';"');
59  return parent::render() . "<input type='reset' value=' ... ' onclick=\"return TCP.popup('" . XOOPS_URL . "/include/',document.getElementById('" . $this->getName() . "'));\">" ;
60  }
61 
67  function renderValidationJS()
68  {
69  $eltname = $this->getName();
70  $eltcaption = $this->getCaption();
71  $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
72 
73  return "if ( !(new RegExp(\"^#[0-9a-fA-F]{6}\",\"i\").test(myform.{$eltname}.value)) ) { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }";
74  }
75 }
76 
77 ?>