Exemplo n.º 1
0
 /**
  * @param TreeViewNode
  * @param string name
  * @return Nette\Web\Html
  */
 public function renderLink(TreeViewNode $node, $name)
 {
     $pres = $this->tree->getPresenter();
     $id = $node->getDataRow()->id;
     $nname = $this->tree->getName();
     $link = $node[$name];
     $label = $link->getLabel();
     $el = Html::el('div');
     $el->add(Html::el('img', array('src' => $this->img_move, 'height' => '16', 'class' => 'handler', 'alt' => 'move', 'style' => 'cursor: move;')));
     if ($this->useCB) {
         $cbx = Html::el('input', array('type' => 'checkbox', 'name' => $nname . '[]', 'id' => 'cbx-' . $id, 'style' => 'cursor: default;'));
         $ck = $this->checkColumn;
         if ($node->getDataRow()->{$ck}) {
             $cbx->checked = 'checked';
         }
         $url = $pres->link($this->onCB . '!');
         $cbx->onChange = "jQuery.ajax({ url: '{$url}', type: 'POST', data: { tid: {$id}, vis: this.checked}})";
         $el->add($cbx);
     }
     if (!$this->enableEditName) {
         $el->add($label);
     } else {
         if ($this->useUI) {
             //				$el->add($label);
             $el->add(Html::el('span', array('style' => 'cursor: text;', 'onClick' => "\$('#{$nname}-dform').dialog('option', 'dlgvals', { id: {$id}, meno: '{$label}'}); \$('#{$nname}-dform').dialog('option', 'nop', 'update'); \$('#{$nname}-dform').dialog('open');"))->add($label));
         } else {
             $el->add(Html::el('span', array('class' => $nname . '_click', 'id' => $id))->add($label));
         }
     }
     if ($this->enableDel) {
         $el->add(Html::el('input', array('type' => 'button', 'class' => 'etbtn_del', 'onClick' => "jQuery.ajax({ url: '" . $pres->link($this->onDel . '!', array('id' => $id)) . "', type: 'post', complete: function(data){ window.location.reload();}});")));
     }
     if ($this->useUI) {
         if ($this->enableEditName) {
             /* editBTN
             				$el->add(Html::el('input', array(
             											'type' => 'button',
             											'class' => 'etbtn_edit',
             											'onClick' => "$('#$nname-dform').dialog('option', 'dlgvals', { id: $id, meno: '$label'}); $('#$nname-dform').dialog('option', 'nop', 'update'); $('#$nname-dform').dialog('open');"
             											)));
             */
             $el->add(Html::el('input', array('type' => 'button', 'class' => 'etbtn_add', 'onClick' => "\$('#{$nname}-dform').dialog('option', 'dlgvals', { id: {$id}, meno: '{$label}'}); \$('#{$nname}-dform').dialog('option', 'nop', 'add'); \$('#{$nname}-dform').dialog('open');")));
         }
     } elseif ($this->enableAdd) {
         $el->add(Html::el('input', array('type' => 'button', 'class' => 'etbtn_add', 'onClick' => "jQuery.ajax({ url: '" . $pres->link($this->onAdd . '!', array('id' => $id)) . "', type: 'post', complete: function(data){ window.location.reload();}});")));
     }
     return $el;
 }