Ejemplo n.º 1
0
 /**
  * Initalizes and retrieves all required options for intercooler and user defined options
  */
 protected function initOptions()
 {
     $options = ArrayHelper::merge($this->_handler->getOptions($this->id), $this->options);
     if ($this->fallbackHtml) {
         $options[Intercooler::attr(Intercooler::ATTR_EVT_ON_ERROR)] = new \yii\web\JsExpression("var e = document.querySelector('#{$this->id} .ic-fallback'); if (typeof(e) != 'undefined' && e != null) {e.style.display = null;}");
         $options[Intercooler::attr(Intercooler::ATTR_EVT_ON_BEFORE_SEND)] = new \yii\web\JsExpression("var icf = document.querySelector('#{$this->id} .ic-fallback'); if (typeof(icf) != 'undefined' && icf != null) {icf.style.display = 'none';} var icl = document.querySelector('#{$this->id} .ic-loading'); if (typeof(icl) != 'undefined' && icl != null) {icl.style.display = null;}");
         $options[Intercooler::attr(Intercooler::ATTR_EVT_ON_COMPLETE)] = new \yii\web\JsExpression("var e = document.querySelector('#{$this->id} .ic-loading'); if (typeof(e) != 'undefined' && e != null) {e.style.display = 'none';}");
     }
     if ($this->_handler->indicator) {
         // hides request indicator after document is ready
         $js = new \yii\web\JsExpression("var e = document.querySelector('{$this->_handler->indicator}'); if (typeof(e) != 'undefined' && e != null) {e.style.display = 'none';}");
         $this->getView()->registerJs($js);
     }
     return $options;
 }
Ejemplo n.º 2
0
 /**
  * Retrieves all required page button options
  * @return array
  */
 protected function getPageBtnOptions($page)
 {
     $additionals = [Intercooler::attr(self::ATTR_REPLACE_TARGET) => $this->replaceTarget ? "true" : "false"];
     if ($this->indicatorError) {
         $additionals[Intercooler::attr(Intercooler::ATTR_EVT_ON_ERROR)] = new \yii\web\JsExpression("var e = document.querySelector('#{$this->indicatorErrorId}'); if (typeof(e) != 'undefined' && e != null) {e.style.display = null;}");
         $additionals[Intercooler::attr(Intercooler::ATTR_EVT_ON_BEFORE_SEND)] = new \yii\web\JsExpression("var icf = document.querySelector('#{$this->indicatorErrorId}'); if (typeof(icf) != 'undefined' && icf != null) {icf.style.display = 'none';} var icl = document.querySelector('#{$this->indicatorLoadingId}'); if (typeof(icl) != 'undefined' && icl != null) {icl.style.display = null;}");
         $additionals[Intercooler::attr(Intercooler::ATTR_EVT_ON_COMPLETE)] = new \yii\web\JsExpression("var e = document.querySelector('#{$this->indicatorLoadingId}'); if (typeof(e) != 'undefined' && e != null) {e.style.display = 'none';}");
     }
     $js = new \yii\web\JsExpression("jQuery('#{$this->id}').on('success.ic', function(e) {console.log(e)})");
     $this->getView()->registerJs($js);
     return ArrayHelper::merge($this->_handler->getOptions($this->getTriggerId(), $additionals), $this->linkOptions);
 }
Ejemplo n.º 3
0
 /**
  * Indicates if current request is refresh
  * @return boolean
  */
 public static function isRefresh($id)
 {
     $trigger = \Yii::$app->request->get(Intercooler::attr(Intercooler::QP_TRIGGER), false);
     return $id == $trigger;
 }