Ejemplo n.º 1
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $this->initOptions();
     echo Html::beginTag('div', $this->options) . "\n";
     echo $this->renderBodyBegin() . "\n";
 }
 /**
  * Renders the widget.
  */
 public function run()
 {
     // @todo use [[options]] instead of [[containerOptions]] and introduce [[buttonOptions]] before 2.1 release
     Html::addCssClass($this->containerOptions, ['widget' => 'btn-group']);
     $options = $this->containerOptions;
     $tag = ArrayHelper::remove($options, 'tag', 'div');
     $this->registerPlugin('button');
     return implode("\n", [Html::beginTag($tag, $options), $this->renderButton(), $this->renderDropdown(), Html::endTag($tag)]);
 }
 /**
  * Generates a bar
  * @param integer $percent the percentage of the bar
  * @param string $label, optional, the label to display at the bar
  * @param array $options the HTML attributes of the bar
  * @return string the rendering result.
  */
 protected function renderBar($percent, $label = '', $options = [])
 {
     $defaultOptions = ['role' => 'progressbar', 'aria-valuenow' => $percent, 'aria-valuemin' => 0, 'aria-valuemax' => 100, 'style' => "width:{$percent}%"];
     $options = array_merge($defaultOptions, $options);
     Html::addCssClass($options, ['widget' => 'progress-bar']);
     $out = Html::beginTag('div', $options);
     $out .= $label;
     $out .= Html::tag('span', \Yii::t('yii', '{percent}% Complete', ['percent' => $percent]), ['class' => 'sr-only']);
     $out .= Html::endTag('div');
     return $out;
 }
 /**
  * Renders the widget.
  */
 public function run()
 {
     $this->registerPlugin('collapse');
     return implode("\n", [Html::beginTag('div', $this->options), $this->renderItems(), Html::endTag('div')]) . "\n";
 }
Ejemplo n.º 5
0
 /**
  * Renders the opening tag of the modal body.
  * @return string the rendering result
  */
 protected function renderBodyBegin()
 {
     return Html::beginTag('div', ['class' => 'modal-body']);
 }
 /**
  * @param string|null $label the label or null to use model label
  * @param array $options the tag options
  */
 protected function renderLabelParts($label = null, $options = [])
 {
     $options = array_merge($this->labelOptions, $options);
     if ($label === null) {
         if (isset($options['label'])) {
             $label = $options['label'];
             unset($options['label']);
         } else {
             $attribute = Html::getAttributeName($this->attribute);
             $label = Html::encode($this->model->getAttributeLabel($attribute));
         }
     }
     if (!isset($options['for'])) {
         $options['for'] = Html::getInputId($this->model, $this->attribute);
     }
     $this->parts['{beginLabel}'] = Html::beginTag('label', $options);
     $this->parts['{endLabel}'] = Html::endTag('label');
     if (!isset($this->parts['{labelTitle}'])) {
         $this->parts['{labelTitle}'] = $label;
     }
 }
 /**
  * Renders the widget.
  */
 public function run()
 {
     $this->registerPlugin('carousel');
     return implode("\n", [Html::beginTag('div', $this->options), $this->renderIndicators(), $this->renderItems(), $this->renderControls(), Html::endTag('div')]) . "\n";
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $this->clientOptions = false;
     if (empty($this->options['class'])) {
         Html::addCssClass($this->options, ['navbar', 'navbar-default']);
     } else {
         Html::addCssClass($this->options, ['widget' => 'navbar']);
     }
     if (empty($this->options['role'])) {
         $this->options['role'] = 'navigation';
     }
     $options = $this->options;
     $tag = ArrayHelper::remove($options, 'tag', 'nav');
     echo Html::beginTag($tag, $options);
     if ($this->renderInnerContainer) {
         if (!isset($this->innerContainerOptions['class'])) {
             Html::addCssClass($this->innerContainerOptions, 'container');
         }
         echo Html::beginTag('div', $this->innerContainerOptions);
     }
     echo Html::beginTag('div', ['class' => 'navbar-header']);
     if (!isset($this->containerOptions['id'])) {
         $this->containerOptions['id'] = "{$this->options['id']}-collapse";
     }
     echo $this->renderToggleButton();
     if ($this->brandLabel !== false) {
         Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
         echo Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions);
     }
     echo Html::endTag('div');
     Html::addCssClass($this->containerOptions, ['collapse' => 'collapse', 'widget' => 'navbar-collapse']);
     $options = $this->containerOptions;
     $tag = ArrayHelper::remove($options, 'tag', 'div');
     echo Html::beginTag($tag, $options);
 }