diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-01-23 14:55:32 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-01-23 14:55:32 +0000 |
| commit | e5259a33066415ea2d424afeb54cad5d4c2b1ad9 (patch) | |
| tree | af3cc24fe287671eb29574baf79999d11f4154b4 /frontends/php/include/classes | |
| parent | 0dcb4e9f403253a308b088c145e7404c28de2008 (diff) | |
| download | zabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.tar.gz zabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.tar.xz zabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.zip | |
- improved webmonitoring (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3749 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/classes')
| -rw-r--r-- | frontends/php/include/classes/ccombobox.inc.php | 92 |
1 files changed, 91 insertions, 1 deletions
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php index 387821e6..d05020d7 100644 --- a/frontends/php/include/classes/ccombobox.inc.php +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -19,6 +19,8 @@ **/ ?> <?php + require_once("include/classes/ctag.inc.php"); + class CComboItem extends CTag { /* public */ @@ -98,7 +100,7 @@ class CListBox extends CComboBox { /* public */ - function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL) + function CListBox($name='listbox',$value=NULL,$size=5,$action=NULL) { parent::CComboBox($name,NULL,$action); $this->options['multiple'] = 'multiple'; @@ -111,4 +113,92 @@ } } + function inseret_javascript_for_editable_combobox() + { + if(defined('EDITABLE_COMBOBOX_SCRIPT_INSERTTED')) return; + + define('EDITABLE_COMBOBOX_SCRIPT_INSERTTED', 1); +?> +<script language="JavaScript" type="text/javascript"> +<!-- + function CEditableComboBoxInit(obj) + { + var opt = obj.options; + + if(obj.value) obj.oldValue = obj.value; + + for (var i = 0; i < opt.length; i++) + if (-1 == opt.item(i).value) + return; + + opt = document.createElement("option"); + opt.value = -1; + opt.text = "(other ...)"; + + if(!obj.options.add) + obj.insertBefore(opt, obj.options.item(0)); + else + obj.options.add(opt, 0); + + return; + } + + function CEditableComboBoxOnChange(obj,size) + { + if(-1 != obj.value) + { + obj.oldValue = obj.value; + } + else + { + var new_obj = document.createElement("input"); + new_obj.type = "text"; + new_obj.name = obj.name; + if(size && size > 0) + { + new_obj.size = size; + } + new_obj.className = obj.className; + if(obj.oldValue) new_obj.value = obj.oldValue; + obj.parentNode.replaceChild(new_obj, obj); + new_obj.focus(); + new_obj.select(); + } + } +--> +</script> +<?php + } + + class CEditableComboBox extends CComboBox + { + function CEditableComboBox($name='editablecombobox',$value=NULL,$size=0,$action=NULL) + { + inseret_javascript_for_editable_combobox(); + + parent::CComboBox($name,$value,$action); + parent::AddOption('onfocus','CEditableComboBoxInit(this);'); + parent::AddOption('onchange','CEditableComboBoxOnChange(this,'.$size.');'); + } + + function AddItem($value, $caption='', $selected=NULL, $enabled='yes') + { + if(is_null($selected)) + { + if($value == $this->value || (is_array($this->value) && in_array($value, $this->value))) + $this->value_exist = 1; + } + + parent::AddItem($value,$caption,$selected,$enabled); + } + + function ToString($destroy=true) + { + if(!isset($this->value_exist) && !empty($this->value)) + { + $this->AddItem($this->value, $this->value, 'yes'); + } + return parent::ToString($destroy); + } + } ?> |
