Exemple #1
0
 /**
  * Initializes the widget.
  *
  * @throws InvalidConfigException if the src property ot the image is not defined
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, ['widget' => 'chip']);
     if ($this->imageOptions && !isset($this->imageOptions['src'])) {
         throw new InvalidConfigException('The "src" attribute for the image is required.');
     }
     if ($this->renderIcon && !isset($this->icon['name'])) {
         $this->icon['name'] = 'close';
     }
 }
Exemple #2
0
 /**
  * Initializes the widget.
  *
  * @throws InvalidConfigException if icon name is not specified
  */
 public function init()
 {
     parent::init();
     if (!$this->name) {
         throw new InvalidConfigException('The icon name must be specified.');
     }
     if ($this->position === null) {
         $this->position = 'left';
     }
     Html::addCssClass($this->options, ['material-icons', $this->position]);
 }
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  */
 public function run()
 {
     $this->registerAssets();
     Html::addCssClass($this->options, 'clockpicker');
     if ($this->hasModel()) {
         $this->options['data-value'] = isset($this->value) ? $this->value : Html::getAttributeValue($this->model, $this->attribute);
         return Html::activeInput('time', $this->model, $this->attribute, $this->options);
     } else {
         $this->options['data-value'] = $this->value;
         return Html::input('time', $this->name, $this->value, $this->options);
     }
 }
Exemple #4
0
 /**
  * Check to see if a child item is active optionally activating the parent.
  * @param array $items @see items
  * @param boolean $active should the parent be active too
  * @return array @see items
  */
 protected function isChildActive($items, &$active)
 {
     foreach ($items as $i => $child) {
         if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
             Html::addCssClass($items[$i]['options'], 'active');
             if ($this->activateParents) {
                 $active = true;
             }
         }
     }
     return $items;
 }
 /**
  * Renders a textarea.
  * @param array $options
  * @return ActiveField
  */
 public function textarea($options = [])
 {
     Html::addCssClass($options, ['textarea' => 'materialize-textarea']);
     return parent::textarea($options);
 }
 /**
  * Set inital default options.
  */
 protected function initDefaults()
 {
     switch ($this->modalType) {
         case self::TYPE_FIXED_FOOTER:
             Html::addCssClass($this->options, ['modalType' => 'modal-fixed-footer']);
             break;
         case self::TYPE_BOTTOM_SHEET:
             Html::addCssClass($this->options, ['modalType' => 'bottom-sheet']);
             break;
         default:
             break;
     }
     Html::addCssClass($this->options, ['widget' => 'modal']);
     if ($this->closeButton !== false) {
         $this->closeButton = ArrayHelper::merge(['class' => 'modal-close'], $this->closeButton);
     }
     if ($this->toggleButton !== false) {
         $this->toggleButton = ArrayHelper::merge(['class' => 'modal-trigger btn'], $this->toggleButton);
     }
     if ($this->clientOptions !== false) {
         $this->clientOptions = ArrayHelper::merge(['show' => false], $this->clientOptions);
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $this->clientOptions = false;
     Html::addCssClass($this->options, ['widget' => 'btn']);
     switch ($this->type) {
         case self::TYPE_FLOATING:
         case self::TYPE_FLAT:
             Html::addCssClass($this->options, ['btn_type' => "btn-{$this->type}"]);
             break;
     }
     if ($this->large) {
         Html::addCssClass($this->options, ['btn_size' => 'btn-large']);
     }
     if ($this->disabled) {
         Html::addCssClass($this->options, ['btn_disabled' => 'disabled']);
     }
 }
 /**
  * Renders a single breadcrumb item.
  * @param array $link the link to be rendered. It must contain the "label" element. The "url" element is optional.
  * @param string $template the template to be used to rendered the link. The token "{link}" will be replaced by the link.
  * @return string the rendering result
  * @throws InvalidConfigException if `$link` does not have "label" element.
  */
 protected function renderItem($link, $template)
 {
     $encodeLabel = ArrayHelper::remove($link, 'encode', $this->encodeLabels);
     if (array_key_exists('label', $link)) {
         $label = $encodeLabel ? Html::encode($link['label']) : $link['label'];
     } else {
         throw new InvalidConfigException('The "label" element is required for each link.');
     }
     if (isset($link['template'])) {
         $template = $link['template'];
     }
     if (isset($link['url'])) {
         $options = $link;
         Html::addCssClass($options, ['link' => 'breadcrumb']);
         unset($options['template'], $options['label'], $options['url']);
         $link = Html::a($label, $link['url'], $options);
     } else {
         $link = $label;
     }
     return strtr($template, ['{link}' => $link]);
 }
 /**
  * Initialize the widget.
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, ['container' => 'switch']);
     if ($this->hasModel()) {
         if (!isset($this->inputOptions['name'])) {
             $this->inputOptions['name'] = Html::getInputName($this->model, $this->attribute);
         }
         if (!isset($this->inputOptions['id'])) {
             $this->inputOptions['id'] = Html::getInputId($this->model, $this->attribute);
         }
     } else {
         $this->inputOptions['name'] = $this->name;
     }
     $this->inputOptions['uncheck'] = isset($this->uncheck) ? $this->uncheck : is_null($this->uncheck) ? null : '0';
     $this->inputOptions['value'] = isset($this->value) ? $this->value : '1';
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->buttonOptions, ['widget' => 'btn-floating']);
     if ($this->clickToToggle) {
         Html::addCssClass($this->options, ['container' => 'click-to-toggle']);
     }
     if ($this->horizontal) {
         Html::addCssClass($this->options, ['containerLayout' => 'horizontal']);
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, ['widget' => 'progress']);
     Html::addCssClass($this->progressOptions, ['type' => $this->type]);
     if ($this->type === 'determinate') {
         Html::addCssStyle($this->progressOptions, ['width' => $this->value . '%']);
     }
 }
 /**
  * Renders menu items.
  *
  * @param array $items the menu items to be rendered
  * @param array $options the container HTML attributes
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  * @used-by [[run()]]
  */
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         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'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if (empty($item['items'])) {
             if ($url === null) {
                 $content = $label;
                 Html::addCssClass($itemOptions, ['widget' => 'dropdown-header']);
             } else {
                 $content = Html::a($label, $url, $linkOptions);
             }
         } else {
             $submenuOptions = $this->submenuOptions;
             if (isset($item['submenuOptions'])) {
                 $submenuOptions = array_merge($submenuOptions, $item['submenuOptions']);
             }
             $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
             Html::addCssClass($itemOptions, ['widget' => 'dropdown-submenu']);
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  * @uses [[renderSpinner()]]
  */
 public function run()
 {
     $html[] = Html::beginTag('div', $this->options);
     if ($this->flashColors !== false) {
         foreach ($this->colors as $color) {
             Html::addCssClass($this->spinnerOptions, ['color' => 'spinner-' . $color]);
             $html[] = Html::beginTag('div', $this->spinnerOptions);
             $html[] = $this->renderSpinner();
             $html[] = Html::endTag('div');
             Html::removeCssClass($this->spinnerOptions, ['color' => 'spinner-' . $color]);
         }
     } else {
         $html[] = Html::beginTag('div', $this->spinnerOptions);
         $html[] = $this->renderSpinner();
         $html[] = Html::endTag('div');
     }
     $html[] = Html::endTag('div');
     return implode("\n", $html);
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $this->clientOptions = false;
     $html = [];
     if (empty($this->options['role'])) {
         $this->options['role'] = 'navigation';
     }
     if ($this->fixed) {
         Html::addCssClass($this->fixedContainerOptions, 'navbar-fixed');
         $html[] = Html::beginTag('div', $this->fixedContainerOptions);
     }
     $html[] = Html::beginTag('nav', $this->options);
     Html::addCssClass($this->wrapperOptions, 'nav-wrapper');
     $html[] = Html::beginTag('div', $this->wrapperOptions);
     if ($this->brandLabel !== false) {
         Html::addCssClass($this->brandOptions, ['widget' => 'brand-logo']);
         $html[] = Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions);
     }
     if (!isset($this->containerOptions['id'])) {
         $this->containerOptions['id'] = "{$this->id}-collapse";
     }
     $html[] = $this->renderToggleButton();
     $html[] = Html::beginTag('div', $this->containerOptions);
     echo implode("\n", $html);
 }