コード例 #1
0
ファイル: CBTree.php プロジェクト: oaki/demoshop
 /**
  * Render 1 node (+ subnodes)
  * @param TreeViewNode node
  * @param control
  * @param label
  * @return Nette\Web\Html
  */
 private function renderNode(TreeViewNode $node, $control, $label)
 {
     $pcontrol = clone $control;
     $li = NHtml::el('li');
     $nid = $node->getDataRow()->id;
     $control->id = $label->for = $control->id . '-' . $nid;
     $ck = $this->checkColumn;
     /*
      * Pridal som ze ak neezistuje stlpec, aby nedavalo notice
      */
     if (isset($node->getDataRow()->{$ck}) and $node->getDataRow()->{$ck}) {
         $control->checked = 'checked';
     } else {
         $control->checked = null;
     }
     $control->value = $nid;
     $nc = $this->nameColumn;
     $label->setText($node->getDataRow()->{$nc});
     $li->add((string) $control . (string) $label);
     $nodes = $node->getNodes();
     if (count($nodes)) {
         $ul = NHtml::el('ul');
         $li->add($ul);
         foreach ($nodes as $n) {
             $ul->add($this->renderNode($n, $pcontrol, $label));
         }
     }
     return $li;
 }
コード例 #2
0
 public function renderLink(TreeViewNode $node, $name, $wrapper = 'link node')
 {
     $el = $this->getWrapper($wrapper);
     if (NULL === $el) {
         return NULL;
     }
     $link = $node[$name];
     if ($link->useAjax) {
         $class = $el->class;
         $ajaxClass = $this->getValue('link .ajax');
         if (!empty($class) && !empty($ajaxClass)) {
             $ajaxClass = $class . ' ' . $ajaxClass;
         }
         $el->class = $ajaxClass;
     }
     $el->setText($link->getLabel());
     $el->href($link->getUrl());
     if ($name != 'nodeLink') {
         $span = Html::el('span');
         $span->class = 'collapsable';
         $span->add($el);
         return $span;
     } else {
         $sub = $this->getWrapper('node subcontainer');
         $sub->class = $this->getValue('node .subcontainer');
         $sub->add($el);
         $move = $this->getWrapper('move container');
         $move->addClass($this->getValue('move .class'));
         //TODO: nefunguje v nove verzi jquery?
         //$move->addClass('handler');
         $delete = $this->getWrapper('delete container');
         $delete->href = $this->tree->getPresenter()->link($this->onDelete . '!', $node->getDataRow()->id);
         $delete->class = $this->getValue('delete .ajax');
         $delete->addClass($this->getValue('delete .class'));
         $deleteSpan = $this->getWrapper('delete subcontainer');
         $deleteSpan->add('delete');
         $delete->add($deleteSpan);
         $edit = Html::el('a');
         $edit->href = $this->tree->getPresenter()->link($this->onEdit, $node->getDataRow()->id);
         $edit->addClass('edit');
         $editSpan = Html::el('span');
         $editSpan->add('edit');
         $edit->add($editSpan);
         $sub->add($move);
         $sub->add($delete);
         $sub->add($edit);
         return $sub;
     }
     return $el;
 }
コード例 #3
0
ファイル: EditableTree.php プロジェクト: oaki/demoshop
 /**
  * @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;
 }