Пример #1
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     MaterializePluginAsset::register($this->getView());
     $this->registerClientEvents();
     /*$this->getView()->registerJs("
     $('#{$this->id}-btn').dropdown({
           inDuration: 300,
           outDuration: 225,
           constrain_width: false, // Does not change width of dropdown to that of the activator
           hover: false, // Activate on click
           alignment: 'left', // Aligns dropdown to left or right edge (works with constrain_width)
           gutter: 0, // Spacing from edge
           belowOrigin: false // Displays dropdown below the button
     });
             ");*/
     $optionsJsonString = '';
     if (count($this->clientOptions) > 0) {
         $optionsJsonString = \yii\helpers\Json::encode($this->clientOptions);
     }
     $this->getView()->registerJs("\n\$('#{$this->id}-btn').dropdown(" . $optionsJsonString . ");\n        ");
     if ($this->buttonLabel !== null) {
         return Html::tag($this->buttontagName, $this->buttonLabel, $this->buttonOptions) . $this->renderItems($this->items, $this->options);
     } else {
         return $this->renderItems($this->items, $this->options);
     }
 }
Пример #2
0
 /**
  * Registers a specific Materialize plugin and the related events
  * @param string $name the name of the Materialize plugin
  */
 protected function registerPlugin($name)
 {
     $view = $this->getView();
     MaterializePluginAsset::register($view);
     $id = $this->options['id'];
     if ($this->clientOptions !== false) {
         $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
         $js = "jQuery('#{$id}').{$name}({$options});";
         $view->registerJs($js);
     }
     $this->registerClientEvents();
 }
Пример #3
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     //echo Html::endTag('div');
     $tag = ArrayHelper::remove($this->options, 'tag', 'nav');
     echo Html::endTag($tag, $this->options);
     if ($this->fixed) {
         echo Html::endTag('div');
     }
     MaterializePluginAsset::register($this->getView());
 }
Пример #4
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     MaterializeAsset::register($this->getView());
     if ($this->buttonCollapse) {
         MaterializePluginAsset::register($this->getView());
         $this->getView()->registerJs('$("#' . $this->id . '-button-collapse").sideNav();');
     }
     return $this->renderItems();
 }