Example #1
0
 public function registerClientScript()
 {
     $view = $this->getView();
     PjaxAsset::register($view);
     $js = $this->generateClientScript();
     if ($js !== '') {
         $view->registerJs($js);
     }
 }
Example #2
0
 public function registerClientScript()
 {
     $id = $this->options['id'];
     $this->clientOptions['push'] = $this->enablePushState;
     $this->clientOptions['replace'] = $this->enableReplaceState;
     $this->clientOptions['timeout'] = $this->timeout;
     $this->clientOptions['scrollTo'] = $this->scrollTo;
     $options = Json::encode($this->clientOptions);
     $linkSelector = Json::encode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a');
     $formSelector = Json::encode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]');
     $basePoint = $this->basePoint === 'document' ? $this->basePoint : Json::encode($this->basePoint);
     $view = $this->getView();
     PjaxAsset::register($view);
     $js = "jQuery({$basePoint}).off('click', {$linkSelector});";
     $js .= "jQuery({$basePoint}).pjax({$linkSelector}, \"#{$id}\", {$options});";
     $js .= "\njQuery({$basePoint}).off('submit', {$formSelector});";
     $js .= "\njQuery({$basePoint}).on('submit', {$formSelector}, function (event) {jQuery.pjax.submit(event, '#{$id}', {$options});});";
     $view->registerJs($js);
 }
Example #3
0
 /**
  * Registers the needed JavaScript.
  */
 public function registerClientScript()
 {
     $id = $this->options['id'];
     $this->clientOptions['push'] = $this->enablePushState;
     $this->clientOptions['replace'] = $this->enableReplaceState;
     $this->clientOptions['timeout'] = $this->timeout;
     $this->clientOptions['scrollTo'] = $this->scrollTo;
     $options = Json::htmlEncode($this->clientOptions);
     $js = '';
     if ($this->linkSelector !== false) {
         $linkSelector = Json::htmlEncode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a');
         $js .= "jQuery(document).pjax({$linkSelector}, \"#{$id}\", {$options});";
     }
     if ($this->formSelector !== false) {
         $formSelector = Json::htmlEncode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]');
         $submitEvent = Json::htmlEncode($this->submitEvent);
         $js .= "\njQuery(document).on({$submitEvent}, {$formSelector}, function (event) {jQuery.pjax.submit(event, '#{$id}', {$options});});";
     }
     $view = $this->getView();
     PjaxAsset::register($view);
     if ($js !== '') {
         $view->registerJs($js);
     }
 }
Example #4
0
use im\tree\widgets\JsTreeToolbar;
use im\tree\widgets\TreeDetails;
use yii\bootstrap\Modal;
use yii\helpers\Url;
use yii\web\JqueryAsset;
use yii\widgets\ActiveFormAsset;
use yii\widgets\PjaxAsset;
/* @var $this yii\web\View */
/* @var $searchModel im\catalog\models\CategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('category', 'Categories');
$this->params['subtitle'] = Module::t('category', 'Categories list');
$this->params['breadcrumbs'][] = $this->title;
ActiveFormAsset::register($this);
JqueryAsset::register($this);
PjaxAsset::register($this);
$treeId = 'categories-tree';
$treeDetailsId = 'category-details';
$confirmationModalId = 'confirmation-modal';
?>
<div class="row">
    <div class="col-xs-4">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title"><?php 
echo $this->params['subtitle'];
?>
</h3>
                <div class="box-tools pull-right">
                    <form method="post" action="#">
                        <div class="input-group">
Example #5
0
<?php

/**
 * Configuration file for the "yii asset" console command.
 * Note that in the console environment, some path aliases like '@webroot' and '@web' may not exist.
 * Please define these missing path aliases.
 */
return ['jsCompressor' => 'java -jar /root/compiler.jar --js {from} --js_output_file {to}', 'cssCompressor' => 'yui-compressor --type css {from} -o {to}', 'bundles' => ['app\\assets\\AppAsset', 'yii\\bootstrap\\BootstrapAsset', 'app\\modules\\admin\\assets\\AdminAsset', \dmstr\web\AdminLteAsset::className(), \yii\grid\GridViewAsset::className(), \yii\widgets\PjaxAsset::className()], 'targets' => ['frontend' => ['class' => 'yii\\web\\AssetBundle', 'basePath' => '@app/web/assets-prod', 'baseUrl' => '@web/assets-prod', 'js' => 'js/frontend-{hash}.js', 'css' => 'css/frontend-{hash}.css', 'depends' => ['app\\assets\\AppAsset']], 'backend' => ['class' => 'yii\\web\\AssetBundle', 'basePath' => '@app/web/assets-prod', 'baseUrl' => '@web/assets-prod', 'js' => 'js/backend-{hash}.js', 'css' => 'css/backend-{hash}.css', 'depends' => ['app\\modules\\admin\\assets\\AdminAsset', \dmstr\web\AdminLteAsset::className()]], 'all' => ['class' => 'yii\\web\\AssetBundle', 'basePath' => '@app/web/assets-prod', 'baseUrl' => '@web/assets-prod', 'js' => 'js/all-{hash}.js', 'css' => 'css/all-{hash}.css']], 'assetManager' => ['basePath' => '/app/web/assets-prod', 'baseUrl' => '/assets-prod']];
Example #6
0
 /**
  * Registers the needed JavaScript.
  */
 public function registerClientScript()
 {
     $id = $this->options['id'];
     $this->clientOptions['push'] = $this->enablePushState;
     $this->clientOptions['replace'] = $this->enableReplaceState;
     $this->clientOptions['timeout'] = $this->timeout;
     $this->clientOptions['scrollTo'] = $this->scrollTo;
     $options = Json::htmlEncode($this->clientOptions);
     $js = '';
     if ($this->linkSelector !== false) {
         $linkSelector = Json::htmlEncode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a');
         //$js .= "jQuery(document).pjax($linkSelector, \"#$id\", $options);";
         //fix
         $js .= '$(document).on(\'click\', ' . $linkSelector . ', function (event) {
             var container = $(this).closest(\'[data-pjax-container]\');
             if ($(this).attr("data-pjax-reload-id")) {
                 container = $("#" + $(this).attr("data-pjax-reload-id"));                    
             };
             if ("' . $id . '" != container.attr("id")) return true;
             $.pjax.click(event, "#' . $id . '", ' . $options . ');
         });';
     }
     if ($this->formSelector !== false) {
         $formSelector = Json::htmlEncode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]');
         //$js .= "\njQuery(document).on('submit', $formSelector, function (event) {jQuery.pjax.submit(event, '#$id', $options);});";
         //fix
         $js .= 'jQuery(document).on(\'submit\', ' . $formSelector . ', function (event) {
             var container = $(this).closest(\'[data-pjax-container]\');
             if ($(this).attr("data-pjax-reload-id")) {
                 container = $("#" + $(this).attr("data-pjax-reload-id"));
             };
             if ("' . $id . '" != container.attr("id")) return true;
             jQuery.pjax.submit(event, "#' . $id . '", ' . $options . ');
         });';
     }
     $view = $this->getView();
     PjaxAsset::register($view);
     if ($js !== '') {
         $view->registerJs($js);
     }
 }