예제 #1
0
 protected function registerPlugin()
 {
     $id = $this->options['id'];
     //get the displayed view and register the needed assets
     $view = $this->getView();
     yii2masonryAsset::register($view);
     $js = array();
     $options = Json::encode($this->clientOptions);
     $js[] = "var mscontainer{$id} = document.querySelector('#{$id}');";
     $js[] = "var msnry{$id} = new Masonry( mscontainer{$id}, {$options});";
     $view->registerJs(implode("\n", $js), View::POS_LOAD);
 }
예제 #2
0
 /**
  * Registers the widget and the related events
  */
 protected function registerPlugin()
 {
     $id = $this->options['id'];
     //get the displayed view and register the needed assets
     $view = $this->getView();
     yii2masonryAsset::register($view);
     yii2imagesloadedAsset::register($view);
     $js = array();
     $options = Json::encode($this->clientOptions);
     $js[] = "var mscontainer{$id} = \$('#{$id}');";
     $js[] = "var msnry{$id} = mscontainer{$id}.masonry({$options});";
     $js[] = "msnry{$id}.imagesLoaded(function(){  msnry{$id}.masonry(); });";
     $view->registerJs(implode("\n", $js), View::POS_READY);
 }