Author: Christoph Erdmann (yii2-materializecss@pluspunkt-coding.de)
Inheritance: extends yii\base\Widget, use trait MaterializeWidgetTrait
Esempio n. 1
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]);
 }
Esempio n. 2
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';
     }
 }
Esempio n. 3
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if ($this->route === null && Yii::$app->controller !== null) {
         $this->route = Yii::$app->controller->getRoute();
     }
     if ($this->params === null) {
         $this->params = Yii::$app->request->getQueryParams();
     }
     if ($this->dropDownCaret === null) {
         $this->dropDownCaret = Html::tag('i', 'arrow_drop_down', ['class' => 'material-icons right']);
     }
 }
Esempio n. 4
0
 /**
  * Initializes the widget.
  * @uses [[renderCloseButton()]]
  * @uses [[registerPlugin()]]
  */
 public function init()
 {
     parent::init();
     $this->initDefaults();
     $options = $this->options;
     $html = $this->renderToggleButton();
     $tag = ArrayHelper::remove($options, 'tag', 'div');
     $html .= Html::beginTag($tag, $options);
     if ($this->closeButtonPosition === self::CLOSE_BUTTON_POSITION_PRECEDE_CONTENT_CONTAINER) {
         $html .= $this->renderCloseButton();
     }
     $html .= Html::beginTag('div', ['class' => 'modal-content']);
     if ($this->closeButtonPosition === self::CLOSE_BUTTON_POSITION_BEFORE_CONTENT) {
         $html .= $this->renderCloseButton();
     }
     echo $html;
     $this->registerPlugin('leanModal', '.modal-trigger');
 }
Esempio n. 5
0
 /**
  * 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']);
     }
 }
 /**
  * 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']);
     }
 }
Esempio n. 7
0
 /**
  * Initializes the widget.
  *
  * @uses [yii\helper\BaseArrayHelper::merge()](http://www.yiiframework.com/doc-2.0/yii-helpers-basearrayhelper.html#merge()-detail)
  */
 public function init()
 {
     parent::init();
     $this->alertLevels = ArrayHelper::merge($this->predefinedAlertLevels, $this->alertLevels);
 }
Esempio n. 8
0
 /**
  * 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 . '%']);
     }
 }
Esempio n. 9
0
 /**
  * Initializes the widget.
  * If you override this method, make sure you call the parent implementation first.
  */
 public function init()
 {
     // TODO: combined rendering of trigger and dropdown 1.0.8
     if ($this->submenuOptions === null) {
         $this->submenuOptions = $this->options;
         unset($this->submenuOptions['id']);
     }
     parent::init();
     Html::addCssClass($this->options, ['widget' => 'dropdown-content']);
     $this->options['id'] = $this->toggleTarget;
 }
Esempio n. 10
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, ['widget' => 'preloader-wrapper active']);
     Html::addCssClass($this->spinnerOptions, ['spinner' => 'spinner-layer']);
     switch ($this->size) {
         case self::SIZE_SMALL:
             Html::addCssClass($this->options, ['spinner-size' => 'small']);
             break;
         case self::SIZE_BIG:
             Html::addCssClass($this->options, ['spinner-size' => 'big']);
             break;
     }
     if ($this->flashColors === false && $this->color) {
         $color = ArrayHelper::getValue($this->colors, $this->color);
         Html::addCssClass($this->spinnerOptions, ['spinner-color' => "spinner-{$color}-only"]);
     }
 }
Esempio n. 11
0
 /**
  * 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);
 }