/**
  * @param bool $loadGrowl
  * @param null $view
  */
 public function run($loadGrowl = true, $view = null)
 {
     if ($view === null) {
         $view = Yii::$app->getView();
     }
     //$view->registerJs("window.actireresponse_root_url='" . Url::to(['/']) . "';");
     if ($loadGrowl) {
         //http://bootstrap-notify.remabledesigns.com/
         \kartik\growl\GrowlAsset::register($view);
     }
 }
Exemplo n.º 2
0
 public static function reload($view)
 {
     GrowlAsset::register($view);
     AnimateAsset::register($view);
 }
Exemplo n.º 3
0
 /**
  * Register client assets
  */
 protected function registerAssets()
 {
     $view = $this->getView();
     if (in_array($this->type, self::$_themes)) {
         GrowlAsset::register($view)->addTheme($this->type);
     } else {
         GrowlAsset::register($view);
     }
     if ($this->useAnimation) {
         AnimateAsset::register($view);
     }
     $this->registerPluginOptions('notify');
     $js = '$.notify(' . Json::encode($this->_settings) . ', ' . $this->_hashVar . ');';
     if (!empty($this->delay) && $this->delay > 0) {
         $js = 'setTimeout(function () {' . $js . '}, ' . $this->delay . ');';
     }
     $view->registerJs($js);
 }
Exemplo n.º 4
0
 /**
  * Register client assets
  */
 protected function registerAssets()
 {
     $view = $this->getView();
     GrowlAsset::register($view);
     if ($this->useAnimation) {
         AnimateAsset::register($view);
     }
     $this->registerPluginOptions('growl');
     $js = '$.growl(' . Json::encode($this->_settings) . ', ' . $this->_hashVar . ');';
     if (!empty($this->delay) && $this->delay > 0) {
         $js = 'setTimeout(function () {' . $js . '}, ' . $this->delay . ');';
     }
     $view->registerJs($js);
 }
Exemplo n.º 5
0
 /**
  * Adjusted version of 'Register client assets' method
  */
 protected function registerAssets()
 {
     $view = $this->getView();
     if (in_array($this->type, self::$_themes)) {
         GrowlAsset::register($view)->addTheme($this->type);
     } else {
         GrowlAsset::register($view);
     }
     if ($this->useAnimation) {
         AnimateAsset::register($view);
     }
     $this->registerPluginOptions('notify');
     // Apply AJAX if specified //
     if ($this->ajaxOptions) {
         $ajax_js = "\$.ajax({\n                url: '{$this->ajaxOptions['url']}',\n                method: '{$this->ajaxOptions['method']}',\n                " . ($this->ajaxOptions['data'] ? "data: {$this->ajaxOptions['data']}," : null) . "\n            }).success(function(data) {\n                if( data.success ) {\n                    var notify_settings = " . Json::encode($this->_settings) . ";\n                    var successFunction = {$this->ajaxOptions['successCallback']}\n                    successFunction.call(this, data, notify_settings);\n                    \n                    // Loop through results - Could have more than one notification at a time //\n                    for(var i=0; i<data.notifications.length; i++) {\n                        // These values can now be determined by the AJAX data sent back //\n                        notify_settings.message = data.notifications[i].body;\n                        notify_settings.title = data.notifications[i].title + '<hr>';\n                        \n                        // Only show if the 'notification.show' variable is true.\n                        // This allows us to poll for notifications without them\n                        // appearing non-stop - Could implement an AJAX callback\n                        // to server side code to dismiss the notification...\n                        if( data.notifications[i].show )\n                            \$.notify(notify_settings, " . $this->_hashVar . ");\n                    }\n                }\n            }).fail({$this->ajaxOptions['failCallback']});";
         // Apply interval if one is passed in //
         if ($this->ajaxOptions['interval']) {
             $js = "\n                // Call on page load up //\n                {$ajax_js}\n                \n                // Call on an interval //\n                setInterval(function() {\n                    {$ajax_js}\n                }, {$this->ajaxOptions['interval']});";
         } else {
             // Call on page load up but don't repeat //
             $js = $ajax_js;
         }
     } else {
         $js = '$.notify(' . Json::encode($this->_settings) . ', ' . $this->_hashVar . ');';
         if (!empty($this->delay) && $this->delay > 0) {
             $js = 'setTimeout(function () {' . $js . '}, ' . $this->delay . ');';
         }
     }
     $view->registerJs($js);
 }