protected function renderItems() { $html = trim(ob_get_clean()); if (!empty($html)) { $html = "\n" . $html; } $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } elseif (isset($item['content'])) { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $linkOptions['data-toggle'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); $panes[] = Html::tag('div', $item['content'], $options); } elseif (isset($item['contentId'])) { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = $item['contentId']; Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $linkOptions['data-toggle'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); $panes[] = ''; //Html::tag('div', $item['content'], $options); } else { throw new InvalidConfigException("Either the 'content' or 'items' option must be set."); } $headers[] = Html::tag('li', $header, $headerOptions); } return Html::tag('ul', implode("\n", $headers), $this->options) . "\n" . Html::tag('div', implode("\n", $panes) . $html, ['class' => 'tab-content']); }
public function run() { // Only show this widget if we're not on the error page if ($this->_isError) { return ''; } else { return parent::run(); } }
/** * @inheritdoc * @return string */ public function run() { $id = $this->options['id']; $options = $this->getClientOptions(); $options = empty($options) ? '' : Json::htmlEncode($options); $view =& $this->getView(); Yii2BootstrapAsset::register($view); $view->registerJs("jQuery('#{$id}').ajaxDropdown({$options});"); return parent::run(); }
public function testIds() { Dropdown::$counter = 0; $out = Dropdown::widget(['items' => [['label' => 'Page1', 'content' => 'Page1'], ['label' => 'Dropdown1', 'items' => [['label' => 'Page2', 'content' => 'Page2'], ['label' => 'Page3', 'content' => 'Page3']]], ['label' => 'Dropdown2', 'visible' => false, 'items' => [['label' => 'Page4', 'content' => 'Page4'], ['label' => 'Page5', 'content' => 'Page5']]]]]); $expected = <<<EXPECTED <ul id="w0" class="dropdown-menu"><li class="dropdown-header">Page1</li> <li class="dropdown-submenu"><a href="#" tabindex="-1">Dropdown1</a><ul class="dropdown-menu"><li class="dropdown-header">Page2</li> <li class="dropdown-header">Page3</li></ul></li></ul> EXPECTED; $this->assertEqualsWithoutLE($expected, $out); }
public function run() { // Only show this widget if we're not on the error page if ($this->_isError || count(Yii::$app->urlManager->languages) < 2) { return ''; } else { $html = '<li class="dropdown ' . self::$_currentLanguageLabel . '"><a href="#" data-toggle="dropdown" class="dropdown-toggle">' . PHP_EOL . self::label(self::$_currentLanguageLabel) . '<b class="caret"></b></a>' . PHP_EOL; $html .= parent::run(); $html .= '</li>'; return $html; } }
/** * Renders tab items as specified on [[items]]. * @return string the rendering result. * @throws InvalidConfigException. */ protected function renderItems() { $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!array_key_exists('label', $item)) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = $encodeLabel ? Html::encode($item['label']) : $item['label']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { // ha nem dropdown $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $url = ArrayHelper::getValue($linkOptions, 'href', '#'); if ($url == '#' && !isset($linkOptions['data-toggle'])) { $linkOptions['data-toggle'] = 'tab'; $url .= $options['id']; } $header = Html::a($label, $url, $linkOptions); if ($this->renderTabContent) { $panes[] = Html::tag('div', isset($item['content']) ? $item['content'] : '', $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } return Html::tag('ul', implode("\n", $headers), $this->options) . ($this->renderTabContent ? "\n" . Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']) : ''); }
public function run() { $view = $this->getView(); B3wAsset::register($view); if (!is_array($this->items) || count($this->items) == 0) { return ''; } //----------------------------------------- $this->size = strtolower($this->size); $_sizeClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-group-' . $this->size : ''; $_sizeBtnClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-' . $this->size : ''; $this->type = strtolower($this->type); $_typeClass = in_array($this->type, ['default', 'success', 'danger', 'warning', 'info', 'primary']) ? 'btn-' . $this->type : ''; $out = ''; foreach ($this->items as $item) { if (isset($item['items']) && is_array($item['items'])) { $linkOptions = []; $aClasses = ['btn', $_typeClass, 'dropdown-toggle', $_sizeBtnClass]; if (array_key_exists('linkOptions', $item)) { $_ = $item['linkOptions']; if (array_key_exists('class', $_)) { $aClasses = array_merge($aClasses, [$_['class']]); unset($_['class']); } $linkOptions = array_merge($_, ['data-toggle' => 'dropdown']); } $linkOptions['class'] = implode(' ', $aClasses); $groupOptions = array_key_exists('groupOptions', $item) ? $item['groupOptions'] : []; if (array_key_exists('class', $groupOptions)) { $groupOptions['class'] = $groupOptions['class'] . ' btn-group'; } else { $groupOptions['class'] = 'btn-group'; } $groupOptions['role'] = 'group'; $out .= Html::tag('div', Html::a($item['label'] . ' <span class="caret"></span>', '#', $linkOptions) . Dropdown::widget(['items' => $item['items'], 'encodeLabels' => array_key_exists('encodeLabels', $item) ? $item['encodeLabels'] : true]), $groupOptions); } else { $item['linkOptions']['class'] = (isset($item['linkOptions']['class']) ? $item['linkOptions']['class'] : '') . ' btn ' . $_typeClass; $out .= Html::a($item['label'], $item['url'], $item['linkOptions']); } } $this->containerOptions['class'] .= ' btn-group ' . $_sizeClass; $this->containerOptions['role'] = 'group'; return !empty($out) ? Html::tag('div', $out, $this->containerOptions) . ($this->addClearfix ? Html::tag('div', '', ['class' => 'clearfix']) : '') : ''; }
public function init() { $route = Yii::$app->controller->route; $appLanguage = Yii::$app->language; $params = $_GET; $this->_isError = $route === Yii::$app->errorHandler->errorAction; array_unshift($params, '/' . $route); foreach (Yii::$app->urlManager->languages as $language) { $isWildcard = substr($language, -2) === '-*'; if ($language === $appLanguage || $isWildcard && substr($appLanguage, 0, 2) === substr($language, 0, 2)) { continue; // Exclude the current language } if ($isWildcard) { $language = substr($language, 0, 2); } $params['language'] = $language; $this->items[] = ['code' => $language, 'url' => $params]; } parent::init(); }
/** * @inheritdoc */ public function run() { foreach ($this->items as &$item) { // icon ? if (isset($item['icon'])) { $icon = FA::icon($item['icon'] . ' fw'); $item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', '')); $item['encode'] = false; unset($item['icon']); } // active ? if (isset($item['active'])) { $active = $item['active']; if ($active instanceof \Closure) { $active = call_user_func($active, $this->getView()->getContext()); } if ($active) { Html::addCssClass($item['options'], 'active'); } unset($item['active']); } } return parent::run(); }
/** * Renders tab items as specified in [[items]]. * * @return string the rendering result. */ protected function renderItems() { $headers = $panes = $labels = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!ArrayHelper::remove($item, 'visible', true)) { continue; } $label = $this->getLabel($item); $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); $content = ArrayHelper::getValue($item, 'content', ''); if (isset($item['items'])) { foreach ($item['items'] as $subItem) { $subLabel = $this->getLabel($subItem); $labels[] = $this->printHeaderCrumbs ? $label . $this->printCrumbSeparator . $subLabel : $subLabel; } $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $labels[] = $label; $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); $css = 'tab-pane'; $isActive = ArrayHelper::remove($item, 'active'); if ($this->fade) { $css = $isActive ? "{$css} fade in" : "{$css} fade"; } Html::addCssClass($options, $css); if ($isActive) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } if (isset($item['url'])) { $header = Html::a($label, $item['url'], $linkOptions); } else { $linkOptions['data-toggle'] = 'tab'; $linkOptions['role'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); } if ($this->renderTabContent) { $panes[] = Html::tag('div', $content, $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } $outHeader = Html::tag('ul', implode("\n", $headers), $this->options); if ($this->renderTabContent) { $outPane = Html::beginTag('div', ['class' => 'tab-content' . $this->getCss('printable', $this->printable)]); foreach ($panes as $i => $pane) { if ($this->printable) { $outPane .= Html::tag('div', ArrayHelper::getValue($labels, $i), $this->printHeaderOptions) . "\n"; } $outPane .= "{$pane}\n"; } $outPane .= Html::endTag('div'); $tabs = $this->position == self::POS_BELOW ? $outPane . "\n" . $outHeader : $outHeader . "\n" . $outPane; } else { $tabs = $outHeader; } return Html::tag('div', $tabs, $this->containerOptions); }
/** * @return mixed */ private function renderDropdown() { return \yii\bootstrap\Dropdown::widget(['items' => $this->items, 'options' => ['class' => 'pull-right']]); }
/** * Renders a widget's item. * @param string|array $item the item to render. * @return string the rendering result. * @throws InvalidConfigException */ public function renderItem($item) { if (is_string($item)) { return $item; } if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = $encodeLabel ? Html::encode($item['label']) : $item['label']; $options = ArrayHelper::getValue($item, 'options', []); $items = ArrayHelper::getValue($item, 'items'); $url = ArrayHelper::getValue($item, 'url', '#'); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if ($items !== null) { $linkOptions['data-toggle'] = 'dropdown'; Html::addCssClass($options, 'dropdown'); Html::addCssClass($linkOptions, 'dropdown-toggle'); $label .= ' ' . Html::tag('b', '', ['class' => 'caret']); if (is_array($items)) { if ($this->activateItems) { $items = $this->isChildActive($items, $active); } $items = Dropdown::widget(['items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); } } if ($this->activateItems && $active) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); }
/** * Generates the dropdown menu. * @return string the rendering result. */ protected function renderItems() { $this->prepareItems(); $config = []; $config['items'] = $this->items; $config['options'] = ['class' => 'dropdown-menu-right']; $config['clientOptions'] = false; $config['view'] = $this->getView(); return Dropdown::widget($config); }
<?php use yii\helpers\Html; use yii\bootstrap\Dropdown; use yii\widgets\ActiveForm; /** * @var array $options * @var array $formOptions * @var array $dropDownOptions * @var array $buttonOptions */ echo Html::beginTag('div', $options); $form = ActiveForm::begin($formOptions); echo Html::hiddenInput($exportRequestParam); echo Html::button('<i class="glyphicon glyphicon-download-alt"></i>Export<b class="caret"></b>', $buttonOptions); echo Dropdown::widget($dropDownOptions); ActiveForm::end(); echo Html::endTag('div');
public function init() { parent::init(); Html::removeCssClass($this->options, 'dropdown-menu'); Html::addCssClass($this->options, 'treeview-menu'); }
<?php $page->beginContent('bulk-actions'); ?> <?php if (Yii::$app->user->can('support')) { ?> <div class="dropdown" style="display: inline-block"> <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <?php echo Yii::t('hipanel', 'Block'); ?> <span class="caret"></span> </button> <?php echo Dropdown::widget(['encodeLabels' => false, 'options' => ['class' => 'pull-right'], 'items' => [['label' => '<i class="fa fa-toggle-on"></i> ' . Yii::t('hipanel', 'Enable'), 'linkOptions' => ['data-toggle' => 'modal'], 'url' => '#bulk-enable-block-modal'], ['label' => '<i class="fa fa-toggle-off"></i> ' . Yii::t('hipanel', 'Disable'), 'url' => '#bulk-disable-block-modal', 'linkOptions' => ['data-toggle' => 'modal']]]]); ?> <div class="text-left"> <?php echo AjaxModal::widget(['id' => 'bulk-enable-block-modal', 'bulkPage' => true, 'header' => Html::tag('h4', Yii::t('hipanel:client', 'Block clients'), ['class' => 'modal-title']), 'scenario' => 'bulk-enable-block', 'actionUrl' => ['bulk-enable-block-modal'], 'size' => Modal::SIZE_LARGE, 'handleSubmit' => false, 'toggleButton' => false]); ?> <?php echo AjaxModal::widget(['id' => 'bulk-disable-block-modal', 'bulkPage' => true, 'header' => Html::tag('h4', Yii::t('hipanel:client', 'Unblock clients'), ['class' => 'modal-title']), 'scenario' => 'bulk-disable-block', 'actionUrl' => ['bulk-disable-block-modal'], 'size' => Modal::SIZE_LARGE, 'handleSubmit' => false, 'toggleButton' => false]); ?> </div> </div> <?php } ?> <?php if (Yii::$app->user->can('manage')) {
/** * Initializes the widget. * If you override this method, make sure you call the parent implementation first. */ public function init() { parent::init(); Html::addCssClass($this->options, 'sub-menu'); }
public function renderMenu() { if (!$this->menuColumns) { return ''; } $items = []; /** @var $column DataColumn */ foreach ($this->columns as $column) { if (ArrayHelper::getValue($column->options, 'menu', true)) { $items[] = ['label' => Html::checkbox('', $column->visible, []) . ' ' . strip_tags($column->renderHeaderCell()), 'url' => '#', 'encode' => false]; } } $content = Html::beginTag('div', ['class' => 'dropdown-checkbox btn-group']); $content .= Html::tag('button', $this->menuColumnsBtnLabel, ['class' => ' btn btn-default dropdown-toggle', 'data-toggle' => 'dropdown']); $content .= \yii\bootstrap\Dropdown::widget(['items' => $items, 'options' => ['class' => 'dropdown-checkbox-content']]); $content .= Html::endTag('div'); return $content; }
$page->endContent(); ?> <?php $page->beginContent('bulk-actions'); ?> <div class="dropdown" style="display: inline-block"> <button type="button" class="btn btn-default dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <?php echo Yii::t('hipanel:stock', 'Bulk actions'); ?> <span class="caret"></span> </button> <?php echo Dropdown::widget(['encodeLabels' => false, 'items' => [['label' => Yii::t('hipanel:stock', 'Repair'), 'url' => '#', 'linkOptions' => ['data-action' => 'repair']], ['label' => Yii::t('hipanel:stock', 'Copy'), 'url' => '#', 'linkOptions' => ['data-action' => 'copy']], ['label' => Yii::t('hipanel:stock', 'Replace'), 'url' => '#', 'linkOptions' => ['data-action' => 'replace']], ['label' => Yii::t('hipanel:stock', 'Reserve'), 'url' => '#', 'linkOptions' => ['data-action' => 'reserve']], ['label' => Yii::t('hipanel:stock', 'Unreserve'), 'url' => '#', 'linkOptions' => ['data-action' => 'unreserve']], ['label' => Yii::t('hipanel:stock', 'RMA'), 'url' => '#', 'linkOptions' => ['data-action' => 'rma']], '<li role="presentation" class="divider"></li>', ['label' => Yii::t('hipanel:stock', 'Update'), 'url' => '#', 'linkOptions' => ['data-action' => 'update']], ['label' => Yii::t('hipanel:stock', 'Move'), 'url' => '#', 'linkOptions' => ['data-action' => 'move']], ['label' => Yii::t('hipanel:stock', 'Move by one'), 'url' => '#', 'linkOptions' => ['data-action' => 'move-by-one']]]]); ?> </div> <?php echo AjaxModal::widget(['bulkPage' => true, 'id' => 'set-serial-modal', 'scenario' => 'set-serial', 'actionUrl' => ['bulk-set-serial'], 'handleSubmit' => Url::toRoute('set-serial'), 'size' => Modal::SIZE_LARGE, 'header' => Html::tag('h4', Yii::t('hipanel:stock', 'Set serial'), ['class' => 'modal-title']), 'toggleButton' => ['label' => Yii::t('hipanel:stock', 'Set serial'), 'class' => 'btn btn-default btn-sm']]); ?> <?php echo AjaxModal::widget(['bulkPage' => true, 'id' => 'bulk-set-price-modal', 'scenario' => 'bulk-set-price', 'actionUrl' => ['bulk-set-price'], 'size' => Modal::SIZE_LARGE, 'header' => Html::tag('h4', Yii::t('hipanel:stock', 'Set price'), ['class' => 'modal-title']), 'toggleButton' => ['label' => Yii::t('hipanel:stock', 'Set price'), 'class' => 'btn btn-default btn-sm']]); ?> <?php echo $page->renderBulkButton(Yii::t('hipanel:stock', 'Trash'), 'trash', 'danger'); ?> <?php $page->endContent(); ?>
/** * Generates the dropdown menu. * * @return string the rendering result. */ protected function renderDropdown() { $buttons = []; foreach ($this->buttons as $key => $button) { $options = $this->options; unset($options['id']); $url = $this->createUrl($this->key, $key); $label = $this->encodeLabels ? Html::encode($button['label']) : $button['label']; $buttons[] = ['label' => isset($button['icon']) ? Html::icon($button['icon'], ['class' => 'text-' . $button['type']]) . ' ' . $label : $label, 'url' => $url, 'linkOptions' => $options]; } if (count($buttons) <= 1) { return ''; } $splitButton = Button::widget(['label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => ['data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'class' => 'btn-default dropdown-toggle btn-xs']]); return $splitButton . "\n" . Dropdown::widget(['items' => $buttons, 'encodeLabels' => false, 'options' => ['class' => 'pull-right']]); }
use yii\bootstrap\Html; use yii\bootstrap\Dropdown; use kartik\grid\GridView; /** @var $this \yii\web\View */ /** @var $dataProvider \yii\data\ActiveDataProvider */ $this->title = 'Шаблоны писем'; $this->params['breadcrumbs'][] = $this->title; $cols[] = ['attribute' => 'Наименование', 'value' => function ($layout, $index) { return $layout->name; }]; $cols[] = ['attribute' => 'Путь к файлу', 'value' => function ($layout, $index) { return $layout->layout_path; }]; $cols[] = ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'menu-col'], 'options' => ['style' => 'width:50px'], 'value' => function ($layout) { $items[] = ['label' => 'Редактировать', 'url' => ['/broadcast/layout-mng', 'id' => $layout->id]]; return Html::tag('div', '<span class="btn btn-flat menu-button dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-option-vertical"></i></span>' . Dropdown::widget(['items' => $items, 'options' => ['class' => 'control-ul']]), ['class' => 'dropdown']); }]; ?> <div class="box box-default"> <div class="box-header with-border"><?php echo Html::a('<i class="fa fa-plus"></i> Новый шаблон', ['/broadcast/layout-mng'], ['class' => 'btn btn-default btn-flat']); ?> </div> <div class="box-body"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => $cols, 'bordered' => true, 'striped' => false, 'condensed' => true, 'responsive' => false, 'hover' => true]); ?> </div> </div>
/** * Renders the given items as a dropdown. * This method is called to create sub-menus. * @param array $items the given items. Please refer to [[Dropdown::items]] for the array structure. * @param array $parentItem the parent item information. Please refer to [[items]] for the structure of this array. * @return string the rendering result. * @since 2.0.1 */ protected function renderDropdown($items, $parentItem) { return Dropdown::widget(['items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); }
/** * Renders tab items as specified on [[items]]. * * @return string the rendering result. * @throws InvalidConfigException. */ protected function renderItems() { $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!ArrayHelper::remove($item, 'visible', true)) { continue; } if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $label = $encodeLabel ? Html::encode($item['label']) : $item['label']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); $content = ArrayHelper::getValue($item, 'content', ''); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); $css = 'tab-pane'; $isActive = ArrayHelper::remove($item, 'active'); if ($this->fade) { $css = $isActive ? "{$css} fade in" : "{$css} fade"; } Html::addCssClass($options, $css); if ($isActive) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } if (isset($item['url'])) { $header = Html::a($label, $item['url'], $linkOptions); } else { $linkOptions['data-toggle'] = 'tab'; $linkOptions['role'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); } if ($this->renderTabContent) { $panes[] = Html::tag('div', $content, $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } $outHeader = Html::tag('ul', implode("\n", $headers), $this->options); if ($this->renderTabContent) { $outPane = Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']); $tabs = $this->position == self::POS_BELOW ? $outPane . "\n" . $outHeader : $outHeader . "\n" . $outPane; } else { $tabs = $outHeader; } return Html::tag('div', $tabs, $this->containerOptions); }
public function run() { $js = "//Dropdown menu, compatible with mobile ui\n"; $js .= "\$('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) {\n\t\t\tevent.preventDefault(); \n\t\t\tevent.stopPropagation(); \n\t\t\t\$(this).parent().siblings().removeClass('open');\n\t\t\t\$(this).parent().toggleClass('open');\n\t\t});"; $this->getView()->registerJs($js); return parent::run(); }
/** * @inheritdoc */ public function run() { echo Html::endTag($this->_targetTag) . PHP_EOL; echo Html::beginTag($this->_menuTag, $this->menuContainer) . PHP_EOL; echo Dropdown::widget(['items' => $this->items, 'encodeLabels' => $this->encodeLabels, 'options' => $this->menuOptions]) . PHP_EOL; echo Html::endTag($this->_menuTag); }
<div class="box box-default"> <div class="box-header with-border"> <h3 class="box-title"><a href="<?php echo Url::to(['/certificates/requests', 'tasks_id' => $current_task ? $current_task->id : null, 'new' => true]); ?> " class="btn btn-default btn-sm btn-flat"><i class="fa fa-plus"></i> Добавить запрос</a></h3> </div> <div class="box-body"> <?php $columns = [['attribute' => 'created_at', 'format' => ['date', 'php:d.m.Y H:i']], ['attribute' => 'Количество запросов', 'value' => function ($data) { return $data->requestAmount; }], ['attribute' => 'state', 'value' => function ($data) { return $data->state ? 'Активна' : 'Неактивна'; }], ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'menu-col skip-export'], 'value' => function ($data) { $items[] = ['label' => 'Подробнее', 'url' => ['/certificates/requests', 'tasks_id' => $data->id]]; $items[] = ['label' => 'Удалить', 'url' => ['#'], 'linkOptions' => ['data-toggle' => 'modal', 'data-target' => '#myModal', 'onclick' => '$("#del-task").attr("href", "del-task?id=' . $data->id . '");']]; Modal::begin(['header' => '<h2>Действительно удалить задачу из списка?</h2>', 'id' => 'myModal']); echo '<div class="panel">Также будут удалены все запросы, связанные с данной задачей.</div>'; echo '<div class="text-center"><ul class="list-inline">' . '<li>' . Html::a('<span class="fa fa-times"></span> Удалить', '', ['id' => 'del-task', 'class' => 'btn btn-sm btn-flat btn-danger']) . '</li>' . '<li>' . Html::a('Отменить', '', ['class' => 'btn btn-sm btn-flat btn-default ', 'data-dismiss' => "modal", 'aria-hidden' => true]) . '</li>' . '</ul></div>'; Modal::end(); return '<div class="dropdown"><span class="btn btn-flat menu-button dropdown-toggle" data-toggle="dropdown" ><i class="fa fa-ellipsis-v"></i></span>' . Dropdown::widget(['items' => $items, 'options' => ['class' => 'wagon-control-ul']]) . '</div>'; }]]; echo GridView::widget(['dataProvider' => $tasks, 'columns' => $columns, 'layout' => '<div class="pull-left">{summary}</div><div class="pull-right">{export}</div>{items}{pager}', 'toolbar' => ['{export}'], 'export' => ['options' => ['class' => 'btn-default btn-xs btn-flat']], 'bordered' => true, 'striped' => false, 'condensed' => true, 'responsive' => false, 'hover' => true, 'exportConfig' => [GridView::TEXT => ['config' => ['colDelimiter' => " | ", 'rowDelimiter' => "\r\n"]], GridView::PDF => ['config' => ['mode' => 'utf-8']], GridView::EXCEL => []]]); ?> </div> </div> </div> <div class="col-sm-6"> </div> </div>
/** * Generates the dropdown menu. * @return string the rendering result. */ protected function renderDropdown() { $config = $this->dropdown; $config['clientOptions'] = false; $config['view'] = $this->getView(); return Dropdown::widget($config); }
<h3 class="page-header"> <span class="page-header">Year Summary KPI : </span> <span id="tahunCreateTitle" class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown-toggle"><?php echo Html::encode($tahun_create); ?> </a> <?php $start = 2015; $end = date('Y'); $items = []; for ($iTahunCreate = $start; $iTahunCreate <= $end; $iTahunCreate++) { $items[] = ['label' => $iTahunCreate, 'url' => ['', 'tahun_create' => $iTahunCreate]]; } echo Dropdown::widget(['items' => $items]); ?> </span> </h3> <?php /*echo ExportMenu::widget([ 'dataProvider'=>$dataProvider, ]);*/ ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'emptyCell' => " ", 'columns' => [['header' => 'Bulan', 'attribute' => 'bulan_create'], ['header' => 'PO Total', 'attribute' => 'po_total'], ['header' => 'Tercapai %', 'attribute' => 'tercapai_persen'], ['header' => 'Tidak Tercapai %', 'attribute' => 'tdk_tercapai_persen'], ['header' => 'Belum Terkirim %', 'attribute' => 'blm_terkirim_persen'], ['header' => 'Total %', 'attribute' => 'total_persen']]]); ?> <?php
/** * Renders the given items as a dropdown. * This method is called to create sub-menus. * @param array $items the given items. Please refer to [[Dropdown::items]] for the array structure. * @param array $parentItem the parent item information. Please refer to [[items]] for the structure of this array. * @return string the rendering result. * @since 2.0.1 */ protected function renderDropdown($items, $parentItem) { return Dropdown::widget(['options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []), 'items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); }
/** * Initializes the widget */ public function init() { parent::init(); DropdownXAsset::register($this->view); }