/** * Initializes the widget. */ public function init() { Yii::app()->clientScript->registerCoreScript('jquery'); $this->attachBehavior('BsWidget', new BsWidget()); $this->copyId(); BSHtml::addCssClass('collapse', $this->htmlOptions); if (isset($this->parent)) { \bootstrap\helpers\BSArray::defaultValue('data-parent', $this->parent, $this->htmlOptions); } if (isset($this->toggle) && $this->toggle) { BSHtml::addCssClass('in', $this->htmlOptions); } if (isset($this->view)) { $controller = $this->getController(); if (isset($controller) && $controller->getViewFile($this->view) !== false) { $this->content = $this->controller->renderPartial($this->view, $this->viewData, true); } } echo BSHtml::openTag($this->tagName, $this->htmlOptions); echo $this->content; }
/** * Initializes the widget. */ public function init() { $this->attachBehavior('BsWidget', new BsWidget()); $this->copyId(); $route = $this->controller->getRoute(); if ($this->stacked) { BSHtml::addCssClass('nav-stacked', $this->htmlOptions); } $pull = \bootstrap\helpers\BSArray::popValue('pull', $this->htmlOptions); if (!empty($pull)) { if ($pull === BSHtml::PULL_RIGHT || $pull === BSHtml::PULL_LEFT) { BSHtml::addCssClass('pull-' . $pull, $this->htmlOptions); } } // if (isset($this->scrollspy)) { // if (is_string($this->scrollspy)) { // $this->scrollspy = array('target' => $this->scrollspy); // } // $this->widget('bootstrap.widgets.TbScrollspy', $this->scrollspy); // } $this->items = $this->normalizeItems($this->items, $route, $hasActiveChild); }
/** * Runs the widget. */ public function run() { $brand = $this->brandLabel !== false ? BSHtml::navbarBrandLink($this->brandLabel, $this->brandUrl, $this->brandOptions) : ''; ob_start(); foreach ($this->items as $item) { if (is_string($item)) { echo $item; } else { $widgetClassName = \bootstrap\helpers\BSArray::popValue('class', $item); if ($widgetClassName !== null) { $this->controller->widget($widgetClassName, $item); } } } $items = ob_get_clean(); ob_start(); if ($this->collapse !== false) { BSHtml::addCssClass('collapse navbar-collapse', $this->collapseOptions); ob_start(); /* @var BsCollapse $collapseWidget */ $collapseWidget = $this->controller->widget('bootstrap.widgets.BsCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions)); $collapseContent = ob_get_clean(); $collapseLink = BSHtml::navbarCollapseLink('#' . $collapseWidget->getId()); echo BSHtml::tag('div', array('class' => 'navbar-header'), $collapseLink . $brand) . $collapseContent; } else { echo BSHtml::tag('div', array('class' => 'navbar-header'), $brand) . $items; } $containerContent = ob_get_clean(); $containerOptions = \bootstrap\helpers\BSArray::popValue('containerOptions', $this->htmlOptions, array()); BSHtml::addCssClass('container', $containerOptions); $content = BSHtml::tag('div', $containerOptions, $containerContent); echo BSHtml::navbar($content, $this->htmlOptions); }
/** * set the label CssClass by Layout * @param string $layout * @param array $labelOptions * @return array new label options */ private static function setLabelOptionsByLayout($layout, $labelOptions = array()) { if (empty($layout) || $layout === BSHtml::FORM_LAYOUT_VERTICAL) { BSHtml::addCssClass('control-label', $labelOptions); return $labelOptions; } if ($layout === BSHtml::FORM_LAYOUT_INLINE) { BSHtml::addCssClass('control-label', $labelOptions); BSHtml::addCssClass('sr-only', $labelOptions); return $labelOptions; } $labelClass = \bootstrap\helpers\BSArray::popValue('class', $labelOptions, BSHtml::FORM_LAYOUT_HORIZONTAL_LABEL_CLASS); BSHtml::addCssClass('control-label', $labelOptions); BSHtml::addCssClass($labelClass, $labelOptions); return $labelOptions; }
/** * Widget's initialization method */ public function init() { $this->attachBehavior('BsWidget', new BsWidget()); \bootstrap\helpers\BSArray::defaultValue('id', $this->getId(), $this->htmlOptions); \bootstrap\helpers\BSArray::defaultValue('role', 'dialog', $this->htmlOptions); \bootstrap\helpers\BSArray::defaultValue('tabindex', '-1', $this->htmlOptions); BSHtml::addCssClass('modal hide', $this->htmlOptions); if ($this->fade) { BSHtml::addCssClass('fade', $this->htmlOptions); } if (is_array($this->footer)) { $this->footer = implode(' ', $this->footer); } $this->initOptions(); $this->initEvents(); }