Author: Philipp Frenzel (philipp@frenzel.net)
Inheritance: extends yii\web\AssetBundle
コード例 #1
0
 /**
  * Registers the FullCalendar javascript assets and builds the requiered js  for the widget and the related events
  */
 protected function registerPlugin()
 {
     $id = $this->options['id'];
     $view = $this->getView();
     /** @var \yii\web\AssetBundle $assetClass */
     $assets = CoreAsset::register($view);
     if (isset($this->options['lang'])) {
         $assets->language = $this->options['lang'];
     }
     $js = array();
     if ($this->ajaxEvents != NULL) {
         $this->clientOptions['events'] = $this->ajaxEvents;
     }
     /*if(is_array($this->header)){
           $this->clientOptions['header'] = $this->header;
       }*/
     /* updated by AmitG on Dt. 27-04-2015  */
     if (is_array($this->header) && isset($this->clientOptions['header'])) {
         $this->clientOptions['header'] = array_merge($this->header, $this->clientOptions['header']);
     } else {
         $this->clientOptions['header'] = $this->header;
     }
     $cleanOptions = Json::encode($this->clientOptions);
     $js[] = "\$('#{$id}').fullCalendar({$cleanOptions});";
     //lets check if we have an event for the calendar...
     if (count($this->events) > 0) {
         foreach ($this->events as $event) {
             $jsonEvent = Json::encode($event);
             $isSticky = $this->stickyEvents;
             $js[] = "\$('#{$id}').fullCalendar('renderEvent',{$jsonEvent},{$isSticky});";
         }
     }
     $view->registerJs(implode("\n", $js), View::POS_READY);
 }
コード例 #2
0
 /**
  * Registers the FullCalendar javascript assets and builds the requiered js  for the widget and the related events
  */
 protected function registerPlugin()
 {
     $id = $this->options['id'];
     $view = $this->getView();
     /** @var \yii\web\AssetBundle $assetClass */
     $assets = CoreAsset::register($view);
     //by default we load the jui theme, but if you like you can set the theme to false and nothing gets loaded....
     if ($this->options['theme'] == true) {
         ThemeAsset::register($view);
     }
     if (isset($this->options['lang'])) {
         $assets->language = $this->options['lang'];
     }
     if ($this->googleCalendar) {
         $assets->googleCalendar = $this->googleCalendar;
     }
     $js = array();
     if ($this->ajaxEvents != NULL) {
         $this->clientOptions['events'] = $this->ajaxEvents;
     }
     if (is_array($this->header) && isset($this->clientOptions['header'])) {
         $this->clientOptions['header'] = array_merge($this->header, $this->clientOptions['header']);
     } else {
         $this->clientOptions['header'] = $this->header;
     }
     $cleanOptions = $this->getClientOptions();
     $js[] = "jQuery('#{$id}').fullCalendar({$cleanOptions});";
     //lets check if we have an event for the calendar...
     if (count($this->events) > 0) {
         foreach ($this->events as $event) {
             $jsonEvent = Json::encode($event);
             $isSticky = $this->stickyEvents;
             $js[] = "jQuery('#{$id}').fullCalendar('renderEvent',{$jsonEvent},{$isSticky});";
         }
     }
     $view->registerJs(implode("\n", $js), View::POS_READY);
 }
コード例 #3
0
 /**
  * Registers the FullCalendar javascript assets and builds the requiered js  for the widget and the related events
  */
 protected function registerPlugin()
 {
     $id = $this->options['id'];
     $view = $this->getView();
     /** @var \yii\web\AssetBundle $assetClass */
     $assets = CoreAsset::register($view);
     //by default we load the jui theme, but if you like you can set the theme to false and nothing gets loaded....
     if ($this->theme == true) {
         ThemeAsset::register($view);
     }
     if (isset($this->options['lang'])) {
         $assets->language = $this->options['lang'];
     }
     if ($this->googleCalendar) {
         $assets->googleCalendar = $this->googleCalendar;
     }
     $js = array();
     if ($this->ajaxEvents != NULL) {
         $this->clientOptions['events'] = $this->ajaxEvents;
     }
     if (is_array($this->header) && isset($this->clientOptions['header'])) {
         $this->clientOptions['header'] = array_merge($this->header, $this->clientOptions['header']);
     } else {
         $this->clientOptions['header'] = $this->header;
     }
     if (isset($this->defaultView) && !isset($this->clientOptions['defaultView'])) {
         $this->clientOptions['defaultView'] = $this->defaultView;
     }
     // clear existing calendar display before rendering new fullcalendar instance
     // this step is important when using the fullcalendar widget with pjax
     $js[] = "var loading_container = jQuery('#{$id} .fc-loading');";
     // take backup of loading container
     $js[] = "jQuery('#{$id}').empty().append(loading_container);";
     // remove/empty the calendar container and append loading container bakup
     $cleanOptions = $this->getClientOptions();
     $js[] = "jQuery('#{$id}').fullCalendar({$cleanOptions});";
     /**
      * Loads events separately from the calendar creation. Uncomment if you need this functionality.
      *
      * lets check if we have an event for the calendar...
      * if(count($this->events)>0)
      * {
      *    foreach($this->events AS $event)
      *    {
      *        $jsonEvent = Json::encode($event);
      *        $isSticky = $this->stickyEvents;
      *        $js[] = "jQuery('#$id').fullCalendar('renderEvent',$jsonEvent,$isSticky);";
      *    }
      * }
      */
     $view->registerJs(implode("\n", $js), View::POS_READY);
 }