Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application. The name is the fully qualified class name of the class representing it. An asset bundle can depend on other asset bundles. When registering an asset bundle with a view, all its dependent asset bundles will be automatically registered. For more details and usage information on AssetBundle, see the guide article on assets.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Object
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->setSourcePath('@vendor/branchonline/yii2-select2/assets/select2');
     $this->setupAssets('css', ['select2']);
     $this->setupAssets('js', ['select2.min']);
     parent::init();
 }
 public function initView($view)
 {
     $files = [pathinfo('@nitm/assets/js/jquery-plugins/jquery.ui.widget.js'), pathinfo('@nitm/assets/js/jquery-plugins/jquery-ui-scrollable/jquery-ui-scrollable.js')];
     foreach ($files as $f) {
         $asset = new \yii\web\AssetBundle(['sourcePath' => $f['dirname'], 'js' => [$f['basename']]]);
         $asset->publish($view->getAssetManager());
         $view->assetBundles[static::className() . '\\' . $f['basename']] = $asset;
     }
     return $this;
 }
Beispiel #3
0
 public function init()
 {
     parent::init();
     if (!file_exists(\Yii::getAlias('@bower/sticky/jquery.sticky.js'))) {
         throw new InvalidConfigException('You must include `bower-asset/sticky` package in your composer.json configuration file.');
     }
 }
Beispiel #4
0
 public static function register($view, $options = [])
 {
     parent::register($view);
     $callback = null;
     if (isset($options['callback'])) {
         $callback = $options['callback'];
     }
     $settings = $options + self::_getDefaultOptions();
     unset($options);
     if ($settings['text'] == '' && is_array($settings['type'])) {
         foreach ($settings['type'] as $type) {
             $new_settings = $settings;
             $new_settings['type'] = $type;
             $new_settings['text'] = \Yii::$app->session->getFlash($type);
             if (isset($new_settings['text']) && is_array($new_settings['text'])) {
                 foreach ($new_settings['text'] as $text) {
                     $multipleFlashesSettings = $new_settings;
                     $multipleFlashesSettings['text'] = $text;
                     $view->registerJs(self::_run($multipleFlashesSettings, $callback));
                 }
             } elseif (isset($new_settings['text'])) {
                 $view->registerJs(self::_run($new_settings, $callback));
             }
         }
     } else {
         $view->registerJs(self::_run($settings, $callback));
     }
 }
Beispiel #5
0
 public function init()
 {
     if (empty($this->js)) {
         $this->js = $this->getJs();
     }
     return parent::init();
 }
 public function init()
 {
     parent::init();
     $this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'source';
     $this->depends[] = JqueryAsset::className();
     $this->depends[] = BootstrapThemeAsset::className();
 }
 /**
  * @param View $view
  * @return static the registered asset bundle instance
  */
 public static function register($view)
 {
     $configOptions = [];
     $configSelector = self::DEFAULT_SELECTOR;
     try {
         $thisBundle = \Yii::$app->getAssetManager()->getBundle(__CLASS__);
         $configOptions = $thisBundle->options;
         $configSelector = $thisBundle->selector;
     } catch (\Exception $e) {
         // do nothing...
     }
     $options = empty($configOptions) ? '' : Json::encode($configOptions);
     if ($configSelector !== self::DEFAULT_SELECTOR) {
         $view->registerJs('
             hljs.configure(' . $options . ');
             jQuery(\'' . $configSelector . '\').each(function(i, block) {
                 hljs.highlightBlock(block);
             });');
     } else {
         $view->registerJs('
             hljs.configure(' . $options . ');
             hljs.initHighlightingOnLoad();', View::POS_END);
     }
     return parent::register($view);
 }
 public function registerAssetFiles($view)
 {
     $nodigitLib = preg_replace('/[0-9]+/', '', $this->library);
     $this->js[] = $this->library . '-editable/js/' . $nodigitLib . '-editable' . (YII_DEBUG ? '.js' : '.min.js');
     $this->css[] = $this->library . '-editable/css/' . $nodigitLib . '-editable.css';
     parent::registerAssetFiles($view);
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     $postfix = YII_DEBUG ? '' : '.min';
     $this->css[] = 'summernote.css';
     $this->js[] = 'summernote' . $postfix . '.js';
     parent::init();
 }
 /**
  * Initialize the widget.
  * 
  * If YII_ENV_DEV is defined, the not minified version of the css and the js files
  * are used.
  * @see \yii\web\AssetBundle::init()
  */
 public function init()
 {
     $this->sourcePath = __DIR__ . '/assets';
     $this->js = ['js/pnotify.custom' . (YII_ENV_DEV ? '.js' : '.min.js')];
     $this->css = ['css/pnotify.custom' . (YII_ENV_DEV ? '.css' : '.min.css')];
     return parent::init();
 }
 public function init()
 {
     // pr(Yii::$app->view->theme->selectedTheme);die;
     // $this->js = $this->_populateFiles('js');
     // $this->css = $this->_populateFiles('css');
     parent::init();
 }
 public function init()
 {
     if (!empty($this->js) && $this->enableLocale && ($language = $this->getLanguage()) !== null) {
         $this->js[] = 'js/locales/bootstrap-datepicker.' . $language . '.min.js';
     }
     parent::init();
 }
Beispiel #13
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $postfix = YII_DEBUG ? '' : '.min';
     $this->js[] = 'jstree' . $postfix . '.js';
     $this->css[] = 'themes/default/style' . $postfix . '.css';
     parent::init();
 }
 /**
  * Register language script.
  */
 public function registerAssetFiles($view)
 {
     if ($this->language) {
         $this->js[] = 'locale/bootstrap-markdown.' . $this->language . '.js';
     }
     parent::registerAssetFiles($view);
 }
Beispiel #15
0
 public function init()
 {
     $this->js[] = 'ckeditor.js';
     //?v=' . microtime();
     $this->js[] = 'ckeditor.sample.init.js?v=' . microtime();
     parent::init();
 }
 public function init()
 {
     parent::init();
     $this->sourcePath = __DIR__ . '/assets';
     $this->setupAssets('css', ['css/blockmodels']);
     $this->setupAssets('js', ['js/blockmodels']);
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (static::$skin) {
         $this->css[] = sprintf('css/skins/%s.min.css', static::$skin);
     }
 }
Beispiel #18
0
 public function init()
 {
     $this->sourcePath = __DIR__ . '/assets';
     $this->css = ['css/bootstrap-switch.min.css'];
     $this->js = ['js/bootstrap-switch.min.js'];
     parent::init();
 }
Beispiel #19
0
 public function init()
 {
     if (YII_ENV == 'dev') {
         $this->publishOptions = ['forceCopy' => true];
     }
     parent::init();
 }
Beispiel #20
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->registerOnlyRouteScript) {
         $this->js = ['js/rbac-route.js'];
     }
     parent::init();
 }
 public function init()
 {
     $this->css[] = YII_DEBUG ? 'vendor/css/bootstrap-datetimepicker.css' : 'vendor/css/bootstrap-datetimepicker.min.css';
     $this->js[] = YII_DEBUG ? 'vendor/js/bootstrap-datetimepicker.js' : 'vendor/js/bootstrap-datetimepicker.min.js';
     $this->js[] = 'bootstrap-editable-datetimepicker.js';
     parent::init();
 }
 public function init()
 {
     $this->basePath = __DIR__ . '/assets';
     list(, $url) = Yii::$app->assetManager->publish(__DIR__ . '/assets');
     $this->baseUrl = $url;
     parent::init();
 }
 public function init()
 {
     parent::init();
     if (YII_DEBUG) {
         $this->js[] = 'intercooler-debugger.js';
     }
 }
Beispiel #24
0
 /**
  * Register css file based on theme.
  * @param \yii\web\View $view the view that the asset files are to be registered with.
  */
 public function registerAssetFiles($view)
 {
     if (in_array($this->theme, ['base', 'snow'])) {
         $this->css[] = 'quill.' . $this->theme . '.css';
     }
     parent::registerAssetFiles($view);
 }
Beispiel #25
0
 public function registerAssetFiles($view)
 {
     $language = strtolower(Yii::$app->language);
     $language = in_array($language, $this->languageFiles) ? $language : 'en';
     $this->js[] = "lang/{$language}/{$language}.js";
     parent::registerAssetFiles($view);
 }
Beispiel #26
0
 public function init()
 {
     if ($this->skin) {
         $this->css[] = "css/plugin/iCheck/square/{$this->skin}.css";
     }
     parent::init();
 }
Beispiel #27
0
 public function init()
 {
     parent::init();
     if ($this->sourcePath == null) {
         $this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'assets';
     }
 }
Beispiel #28
0
 public function init()
 {
     $this->setSourcePath(__DIR__ . '/assets');
     $this->setupAssets('css', ['css/zTreeStyle']);
     $this->setupAssets('js', ['js/jquery.ztree.all-3.5']);
     parent::init();
 }
 /**
  * Initializes the bundle.
  * Set publish options to copy only necessary files (in this case css and font folders)
  * @codeCoverageIgnore
  */
 public function init()
 {
     parent::init();
     $this->publishOptions['beforeCopy'] = function ($from, $to) {
         return preg_match('%(/|\\\\)(fonts|css)%', $from);
     };
 }
 public function init()
 {
     parent::init();
     $this->publishOptions['beforeCopy'] = function ($from, $to) {
         return strpos($from, 'fonts') !== false || strpos($from, 'css') !== false;
     };
 }