/** * Class constructor * Creates the page */ function __construct() { parent::__construct(); // define the tree data $data = array(); $data['Brazil']['RS'][10] = 'Lajeado'; $data['Brazil']['RS'][20] = 'Cruzeiro do Sul'; $data['Brazil']['RS'][30] = 'Porto Alegre'; $data['Brazil']['SP'][40] = 'São Paulo'; $data['Brazil']['SP'][50] = 'Osasco'; $data['Brazil']['MG'][60] = 'Belo Horizonte'; $data['Brazil']['MG'][70] = 'Ipatinga'; // scroll around the treeview $scroll = new TScroll(); $scroll->setSize(300, 200); // creates the treeview $treeview = new TTreeView(); $treeview->setSize(300); $treeview->setItemIcon('ico_file.png'); $treeview->setItemAction(new TAction(array($this, 'onSelect'))); $treeview->fromArray($data); // fill the treeview $scroll->add($treeview); // creates a simple form $this->form = new TQuickForm('form_test'); // creates the notebook around the form $notebook = new TNotebook(350, 100); $notebook->appendPage('Quick form component', $this->form); // creates the form fields $key = new TEntry('key'); $value = new TEntry('value'); $this->form->addQuickField('Key', $key, 50); $this->form->addQuickField('Value', $value, 170); // creates a table to wrap the treeview and the form $table = new TTable(); $row = $table->addRow(); $cell = $row->addCell($scroll)->valign = 'top'; $cell = $row->addCell($notebook)->valign = 'top'; // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($table); parent::add($vbox); }
/** * 注册JS * @see zTree::getRegisterScripts() */ protected function getRegisterScripts() { $js = parent::getRegisterScripts(); $trigger = "#{$this->_textId}" . ($this->showLink ? $this->_linkId : ""); $js[] = "jQuery('{$trigger}').live('click', function(){\n if(\$('#{$this->treeId}:visible').length > 0)\n return;\n// \$('#{$this->treeId}').parents('div.modal-body').each(function(){\n// if(\$(this).css('position') == 'relative') {\n// relativeDom.push(this);\n// \$(this).css('position', 'static');\n// }\n// });\n\n\t\t\t\t\tvar inputObj = \$('#{$this->_textId}');\n\t\t\t\t\tvar inputOffset = inputObj.position();\n\t\t\t\t\t\$('#{$this->treeId}').css({left:inputOffset.left + 'px', top:inputOffset.top + inputObj.outerHeight() + 'px'}).slideDown('fast').fadeIn(\"fast\");\n\t\t})"; if ($this->width === null) { $js[] = "\$('#{$this->treeId}').width(\$('#{$this->_textId}').width());"; } if ($this->height !== null) { $js[] = "\$('#{$this->treeId}').height(" . $this->height . ");"; } $js[] = '$("body").bind("mousedown", function(event){ if (!(event.target.id == "' . $this->_textId . '" || event.target.id == "' . $this->treeId . '" || $(event.target).parents("#' . $this->treeId . '").length>0)) { // if(relativeDom.length > 0) { // $.each(relativeDom ,function(i, obj){ // $(obj).css({"position" :"relative"}); // }); // } $("#' . $this->treeId . '").fadeOut("fast"); } });'; $js[] = "var relativeDom = [];"; return $js; }