public function renderTitle($item) { $encode = ArrayHelper::getValue($this->titleOptions, 'encode', true); $title = Elements::icon('dropdown') . ($encode ? Html::encode($item['title']) : $item['title']); $options = $this->titleOptions; Html::addCssClass($options, 'title'); if ($item['active']) { Html::addCssClass($options, 'active'); } return Html::tag('div', $title, $options); }
protected function initDefaultButtons() { if (!isset($this->buttons['view'])) { $this->buttons['view'] = function ($url, $model, $key) { return Html::a(Elements::icon('eye'), $url, ['title' => Yii::t('yii', 'View'), 'data-pjax' => '0']); }; } if (!isset($this->buttons['update'])) { $this->buttons['update'] = function ($url, $model, $key) { return Html::a(Elements::icon('pencil'), $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']); }; } if (!isset($this->buttons['delete'])) { $this->buttons['delete'] = function ($url, $model, $key) { return Html::a(Elements::icon('trash'), $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']); }; } }
/** * @param $items * * @return string */ public function renderMenuPart($items) { $items = $this->normalizeItems($items, $hasActiveChild); $lines = ''; foreach ($items as $i => $item) { Html::addCssClass($item['options'], 'item'); if ($item['active']) { Html::addCssClass($item['options'], 'active'); } if (isset($item['items'])) { Html::addCssClass($item['options'], 'ui simple dropdown'); $item['label'] = $item['label'] . Elements::icon('dropdown') . Html::tag('div', $this->renderMenuPart($item['items']), ['class' => 'menu']); $menu = $this->renderItem($item); } else { $menu = $this->renderItem($item); } $lines .= $menu; } return $lines; }
/** * @param array $options * * @return string */ public function renderCloseButton($options = []) { if (!isset($options['id'])) { $options['id'] = $this->getId() . '-close-button'; } $this->getView()->registerJs(' jQuery("#' . $options['id'] . '").on("click", function(event) { jQuery("#' . $this->getId() . '").fadeOut(); }); '); return Elements::icon('close', $options); }