* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * * {@internal * created * * $Id: class.widgets.switchabledatechooser.php 2 2011-07-20 12:00:48Z oldperl $: * }} * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } class cSwitchableDateChooser extends cDateChooser { var $_oCheckBox; var $_bReadOnly; var $_bDisabled; function __construct($name, $initValue = false) { parent::__construct($name, $initValue); $this->_oCheckBox = new cHTMLCheckbox($this->getID() . "_check", "true"); $this->_oCheckBox->setLabelText(""); $this->_oCheckBox->setEvent("click", 'document.getElementById("' . $this->getId() . '").disabled = !this.checked; var jstyle = document.getElementById("' . $this->getId() . '"); if (this.checked) { jstyle.className = "textbox"; if (x_oldvalue_' . $this->getID() . ') { jstyle.value = x_oldvalue_' . $this->getID() . ';} document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "";} else { jstyle.className = "textbox_readonly"; x_oldvalue_' . $this->getID() . ' = jstyle.value; jstyle.value = ""; document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "hidden";}'); $this->enable(); } function disable() { $this->_bDisabled = true; $this->setDisabled(true); $this->_oCheckBox->setChecked(false); $this->setClass("textbox_readonly"); $this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;"); } function enable() { $this->_bDisabled = false; $this->setDisabled(false); $this->_oCheckBox->setChecked(true); $this->setClass("textbox"); } function render() { $sRender = parent::render(); $oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender); if ($this->_bDisabled) { $addscript = 'document.getElementById("' . $this->getId() . '").value = "";'; } return $oAlignmentTable->render() . ''; } }