registerClientScript() public method

Registers the needed JavaScript.
 public function init()
 {
     if (Yii::$app->request->isPjax) {
         $id = Yii::$app->request->headers->get('X-PJAX-Container');
         if ($id) {
             $this->id = substr($id, 1);
             $this->_pjax = Pjax::begin(ArrayHelper::merge(['id' => $this->getId(), 'linkSelector' => false, 'formSelector' => false, 'enablePushState' => false, 'enableReplaceState' => false], $this->pjaxOptions));
             $this->_pjax->registerClientScript();
         }
     }
     parent::init();
 }
示例#2
0
 public function registerClientScript()
 {
     parent::registerClientScript();
     $this->getView()->registerJs('
     var pjaxLoader_' . $this->getSanitizedId() . ' = "' . addslashes($this->loader) . '";
     jQuery(document).on("pjax:start", "#' . $this->options['id'] . '", function() {
         jQuery("#' . $this->options['id'] . '").append(pjaxLoader_' . $this->getSanitizedId() . ');
     });
     ');
 }
示例#3
0
文件: Pjax.php 项目: skeeks-cms/cms
    /**
     * Registers the needed JavaScript.
     */
    public function registerClientScript()
    {
        parent::registerClientScript();
        $errorMessage = \Yii::t('skeeks/admin', 'An unexpected error occurred. Refer to the developers.');
        if ($this->isBlock === true) {
            $this->getView()->registerJs(<<<JS
                (function(sx, \$, _)
                {
                    var blockerPanel = new sx.classes.Blocker('.sx-panel');

                    \$(document).on('pjax:send', function(e)
                    {
                        blockerPanel = new sx.classes.Blocker(\$(e.target));
                        blockerPanel.block();
                    });

                    \$(document).on('pjax:complete', function(e) {
                        blockerPanel.unblock();
                    });

                    \$(document).on('pjax:error', function(e, data) {
                        sx.notify.error('{$errorMessage}');
                        blockerPanel.unblock();
                    });

                })(sx, sx.\$, sx._);
JS
);
        }
        if ($this->blockContainer) {
            $this->getView()->registerJs(<<<JS
                (function(sx, \$, _)
                {
                    var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}"));

                    \$(document).on('pjax:send', function(e)
                    {
                        var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}"));
                        blockerPanel.block();
                    });

                    \$(document).on('pjax:complete', function(e) {
                        blockerPanel.unblock();
                    });

                    \$(document).on('pjax:error', function(e, data) {
                        sx.notify.error('{$errorMessage}');
                        blockerPanel.unblock();
                    });

                })(sx, sx.\$, sx._);
JS
);
        }
    }
示例#4
0
文件: Pjax.php 项目: Liv1020/cms
    /**
     * Registers the needed JavaScript.
     */
    public function registerClientScript()
    {
        parent::registerClientScript();
        if ($this->blockPjaxContainer === true) {
            $this->getView()->registerJs(<<<JS
            (function(sx, \$, _)
            {
                var blockerPanel = new sx.classes.Blocker('.sx-panel');

                \$(document).on('pjax:send', function(e)
                {
                    var blockerPanel = new sx.classes.Blocker(\$(e.target));
                    blockerPanel.block();
                })

                \$(document).on('pjax:complete', function(e) {
                    blockerPanel.unblock();
                })

            })(sx, sx.\$, sx._);
JS
);
        }
        if ($this->blockContainer) {
            $this->getView()->registerJs(<<<JS
            (function(sx, \$, _)
            {
                var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}"));

                \$(document).on('pjax:send', function(e)
                {
                    var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}"));
                    blockerPanel.block();
                })

                \$(document).on('pjax:complete', function(e) {
                    blockerPanel.unblock();
                })

            })(sx, sx.\$, sx._);
JS
);
        }
    }
示例#5
0
 public function registerClientScript()
 {
     $this->clientOptions['fragment'] = $this->options['id'];
     parent::registerClientScript();
 }