• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/element/ColorPicker.php

00001 <?PHP
00017 include_once("InputElement.php");
00018 class ColorPicker extends InputText {
00019        public $m_Config;
00020        public $m_Mode;
00027     protected function readMetaData(&$xmlArr)
00028     {
00029         parent::readMetaData($xmlArr);
00030         $this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : "input_text_s";
00031               $this->m_cssErrorClass = isset($xmlArr["ATTRIBUTES"]["CSSERRORCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSERRORCLASS"] : $this->m_cssClass."_error";
00032               $this->m_cssFocusClass = isset($xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"] : $this->m_cssClass."_focus";
00033         $this->m_Mode = isset($xmlArr["ATTRIBUTES"]["MODE"]) ? $xmlArr["ATTRIBUTES"]["MODE"] : null;
00034         $this->m_Config = isset($xmlArr["ATTRIBUTES"]["CONFIG"]) ? $xmlArr["ATTRIBUTES"]["CONFIG"] : null;
00035     }
00036     
00037        public function render(){
00038               BizSystem::clientProxy()->includeColorPickerScripts();
00039               if($this->m_Value!=null){
00040               $value = $this->m_Value;
00041        }else{
00042               $value = $this->getText();
00043        } 
00044        
00045         $disabledStr = ($this->getEnabled() == "N") ? "READONLY=\"true\"" : "";
00046         $style = $this->getStyle();
00047         $func = $this->getFunction();
00048         $func_org = $func;
00049         $formobj = $this->GetFormObj();
00050        if($formobj->m_Errors[$this->m_Name]){
00051                      $func .= "onchange=\"this.className='$this->m_cssClass'\"";
00052               }else{
00053                      $func .= "onfocus=\"this.className='$this->m_cssFocusClass'\" onblur=\"this.className='$this->m_cssClass'\"";
00054               }        
00055         $elementName = $this->m_Name;   
00056         $elementTrigger=array();
00057         
00058               if($value){
00059                      $default_color = "color: '#$value',";
00060               }else{
00061                      $default_color = "";
00062                      $value=$this->getDefaultValue() ? $this->getDefaultValue() : "";
00063               }        
00064               switch(strtolower($this->m_Mode)){
00065                      case "viewonly":                          
00066                             $sHTML .= "<span id=\"colorpreview_$elementName\" $func_org class=\"colorpicker_preview\" style=\"background-color:#$value;width:98px;\" ></span>";
00067                             $elementTrigger = array();
00068                             break;               
00069                      case "widget":
00070                             $config = " 
00071                                                  onShow: function (colpkr) {
00072                                                         if(\$j(colpkr).css('display')=='none'){
00073                                                                \$j(colpkr).fadeIn(300);
00074                                                         }
00075                                                         return false;
00076                                                  },
00077                                                  onHide: function (colpkr) {
00078                                                         \$j(colpkr).fadeOut(300);
00079                                                         return false;
00080                                                  },                                                                                         
00081                                                  onSubmit: function(hsb, hex, rgb, el) {
00082                                                         $('$this->m_Name').value=hex;
00083                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);
00084                                                  },
00085                                                  onChange: function (hsb, hex, rgb) {
00086                                                         $('$this->m_Name').value=hex;
00087                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);
00088                                                  }
00089                                                  ";
00090                             $sHTML .= "<span id=\"colorpreview_$elementName\" class=\"colorpicker_preview\" style=\"background-color:#$value;\" $func ></span>";
00091                             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name ."\" VALUE=\"" . $value . "\" type=\"hidden\" />";
00092                             $elementTrigger = array("colorpreview_$elementName");
00093                             break;
00094                             
00095                      case "flat":
00096                             $config = "flat: true,
00097                                                  onSubmit: function(hsb, hex, rgb, el) {
00098                                                         $('$this->m_Name').value=hex;
00099                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);                                                  
00100                                                  },
00101                                                  onChange: function (hsb, hex, rgb) {
00102                                                         $('$this->m_Name').value=hex;
00103                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);
00104                                                         
00105                                                  }
00106                             ";
00107                             $sHTML .= "<span id=\"colorpreview_$elementName\" class=\"colorpicker_preview\" style=\"background-color:#$value;\" ></span>";                                          
00108                             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name ."\" VALUE=\"" . $value . "\" $disabledStr $this->m_HTMLAttr $style $func />";
00109                             $sHTML .= "<div id=\"colorpicker_$elementName\" style=\"float:left\"></div>";
00110                             $elementTrigger = array("colorpicker_".$elementName);
00111                             break;
00112                             
00113                      default:
00114                             $config = " 
00115                                                  onShow: function (colpkr) {
00116                                                         if(\$j(colpkr).css('display')=='none'){
00117                                                                \$j(colpkr).fadeIn(300);
00118                                                         }
00119                                                         return false;
00120                                                  },
00121                                                  onHide: function (colpkr) {
00122                                                         \$j(colpkr).fadeOut(300);
00123                                                         return false;
00124                                                  },                                                                                         
00125                                                  onSubmit: function(hsb, hex, rgb, el) {
00126                                                         $('$this->m_Name').value=hex;
00127                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);
00128                                                  },
00129                                                  onChange: function (hsb, hex, rgb) {
00130                                                         $('$this->m_Name').value=hex;
00131                                                         \$j('#colorpreview_$this->m_Name').css('backgroundColor', '#' + hex);
00132                                                  }
00133                                                  ";
00134                             $sHTML .= "<span id=\"colorpreview_$elementName\" class=\"colorpicker_preview\" style=\"background-color:#$value;\" ></span>";
00135                             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name ."\" VALUE=\"" . $value . "\" $disabledStr $this->m_HTMLAttr $style $func />";                                                     
00136                             $elementTrigger = array($elementName,"colorpreview_$elementName");
00137                             break;
00138               }
00139               
00140               if($this->m_Config){
00141                      $config .= ",".$this->m_Config;    
00142               }
00143               $config = "{".$default_color.$config."}";
00144               foreach($elementTrigger as $trigger){
00145                      $sHTML .= "<script>\$j('#$trigger').ColorPicker($config);</script>\n";
00146               }
00147         
00148         return $sHTML;
00149        }
00150        
00151        public function getFunctionByEvent($event_name){
00152         $name = $this->m_Name;
00153         // loop through the event handlers
00154         $func = "";
00155 
00156         if ($this->m_EventHandlers == null)
00157             return null;
00158         $formobj = $this->getFormObj();
00159         
00160         foreach($this->m_EventHandlers as $eventHandler){
00161               if($eventHandler->m_Event==$event_name){
00162                      break;
00163               }
00164         }
00165                 
00166         $ehName = $eventHandler->m_Name;
00167         $event = $eventHandler->m_Event;
00168         $type = $eventHandler->m_FunctionType;
00169         if (!$event) return;
00170         if($events[$event]!=""){
00171            $events[$event]=array_merge(array($events[$event]),array($eventHandler->getFormedFunction()));
00172         }else{
00173            $events[$event]=$eventHandler->getFormedFunction();
00174         }
00175 
00176               foreach ($events as $event=>$function){
00177                      if(is_array($function)){
00178                             foreach($function as $f){
00179                                    $function_str.=$f.";";
00180                             }
00181                             $func .= $function_str;
00182                      }else{
00183                             $func .= $function;
00184                      }
00185               }
00186         return $func;              
00187        }    
00188 }
00189 ?>

Generated on Thu Apr 19 2012 17:01:15 for openbiz by  doxygen 1.7.2