/** * Registers a JS code block for the widget. * * @param string $js the JS code block to be registered * @param integer $pos the position at which the JS script tag should be inserted in a page. The possible values * are: * - [[View::POS_HEAD]]: in the head section * - [[View::POS_BEGIN]]: at the beginning of the body section * - [[View::POS_END]]: at the end of the body section * - [[View::POS_LOAD]]: enclosed within jQuery(window).load(). Note that by using this position, the method will * automatically register the jQuery js file. * - [[View::POS_READY]]: enclosed within jQuery(document).ready(). This is the default value. Note that by using * this position, the method will automatically register the jQuery js file. * @param string $key the key that identifies the JS code block. If null, it will use `$js` as the key. If two JS * code blocks are registered with the same key, the latter will overwrite the former. */ public function registerWidgetJs($js, $pos = View::POS_READY, $key = null) { if (empty($js)) { return; } $view = $this->getView(); WidgetAsset::register($view); $view->registerJs($js, $pos, $key); if (!empty($this->pjaxContainerId) && ($pos === View::POS_LOAD || $pos === View::POS_READY)) { $pjax = 'jQuery("#' . $this->pjaxContainerId . '")'; $evComplete = 'pjax:complete.' . hash('crc32', $js); $script = "setTimeout(function(){ {$js} }, 100);"; $view->registerJs("{$pjax}.off('{$evComplete}').on('{$evComplete}',function(){ {$script} });"); // hack fix for browser back and forward buttons if ($this->enablePopStateFix) { $view->registerJs("window.addEventListener('popstate',function(){window.location.reload();});"); } } }
/** * @inheritdoc */ public function init() { parent::init(); if (!isset($this->language)) { $this->language = Yii::$app->language; } $this->_lang = Config::getLang($this->language); if ($this->pluginLoading) { $this->_loadIndicator = self::LOAD_PROGRESS; } if ($this->hasModel()) { $this->name = empty($this->options['name']) ? Html::getInputName($this->model, $this->attribute) : $this->options['name']; $this->value = Html::getAttributeValue($this->model, $this->attribute); } $this->initDisability($this->options); $view = $this->getView(); WidgetAsset::register($view); }
<?php /** * @file blank.php. * @author Agiel K. Saputra * @date 5/8/2015 * @time 3:13 PM * @var $this \yii\web\View * @var $content string */ use yii\helpers\Html; use codezeen\yii2\adminlte\AdminLteAsset; use kartik\base\WidgetAsset as KvAsset; AdminLteAsset::register($this); KvAsset::register($this); /** * If you're using AdminLteAsset as dependency in AppAsset, then use AppAsset. * ```php * use \backend\assets\AppAsset * AppAsset::register($this) * ``` * Yii::$app->params['bodyClass'] is a skin of admin-lte, ex: skin-blue, skin-black, etc. * You can define it in the controller or config/params.php */ ?> <?php $this->beginPage(); $this->title = 'Admin Zone'; ?> <!DOCTYPE html>