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
コード例 #1
1
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->setSourcePath('@vendor/branchonline/yii2-select2/assets/select2');
     $this->setupAssets('css', ['select2']);
     $this->setupAssets('js', ['select2.min']);
     parent::init();
 }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: StickyAsset.php プロジェクト: mg-code/yii2-assets
 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.');
     }
 }
コード例 #4
0
ファイル: AlertAsset.php プロジェクト: florinmtsc/noty-widget
 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));
     }
 }
コード例 #5
0
ファイル: UeditorAsset.php プロジェクト: songhongyu/idaiyan
 public function init()
 {
     if (empty($this->js)) {
         $this->js = $this->getJs();
     }
     return parent::init();
 }
コード例 #6
0
 public function init()
 {
     parent::init();
     $this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'source';
     $this->depends[] = JqueryAsset::className();
     $this->depends[] = BootstrapThemeAsset::className();
 }
コード例 #7
0
 /**
  * @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);
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $postfix = YII_DEBUG ? '' : '.min';
     $this->css[] = 'summernote.css';
     $this->js[] = 'summernote' . $postfix . '.js';
     parent::init();
 }
コード例 #10
0
 /**
  * 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();
 }
コード例 #11
0
 public function init()
 {
     // pr(Yii::$app->view->theme->selectedTheme);die;
     // $this->js = $this->_populateFiles('js');
     // $this->css = $this->_populateFiles('css');
     parent::init();
 }
コード例 #12
0
 public function init()
 {
     if (!empty($this->js) && $this->enableLocale && ($language = $this->getLanguage()) !== null) {
         $this->js[] = 'js/locales/bootstrap-datepicker.' . $language . '.min.js';
     }
     parent::init();
 }
コード例 #13
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $postfix = YII_DEBUG ? '' : '.min';
     $this->js[] = 'jstree' . $postfix . '.js';
     $this->css[] = 'themes/default/style' . $postfix . '.css';
     parent::init();
 }
コード例 #14
0
 /**
  * Register language script.
  */
 public function registerAssetFiles($view)
 {
     if ($this->language) {
         $this->js[] = 'locale/bootstrap-markdown.' . $this->language . '.js';
     }
     parent::registerAssetFiles($view);
 }
コード例 #15
0
ファイル: CKEditorAsset.php プロジェクト: allhaze/renault
 public function init()
 {
     $this->js[] = 'ckeditor.js';
     //?v=' . microtime();
     $this->js[] = 'ckeditor.sample.init.js?v=' . microtime();
     parent::init();
 }
コード例 #16
0
 public function init()
 {
     parent::init();
     $this->sourcePath = __DIR__ . '/assets';
     $this->setupAssets('css', ['css/blockmodels']);
     $this->setupAssets('js', ['js/blockmodels']);
 }
コード例 #17
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (static::$skin) {
         $this->css[] = sprintf('css/skins/%s.min.css', static::$skin);
     }
 }
コード例 #18
0
ファイル: BootstrapSwitchAsset.php プロジェクト: fiduus/ekany
 public function init()
 {
     $this->sourcePath = __DIR__ . '/assets';
     $this->css = ['css/bootstrap-switch.min.css'];
     $this->js = ['js/bootstrap-switch.min.js'];
     parent::init();
 }
コード例 #19
0
ファイル: ThemeAsset.php プロジェクト: chabberwock/halo-dev
 public function init()
 {
     if (YII_ENV == 'dev') {
         $this->publishOptions = ['forceCopy' => true];
     }
     parent::init();
 }
コード例 #20
0
ファイル: RbacAsset.php プロジェクト: yii2mod/yii2-rbac
 /**
  * @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();
 }
コード例 #22
0
 public function init()
 {
     $this->basePath = __DIR__ . '/assets';
     list(, $url) = Yii::$app->assetManager->publish(__DIR__ . '/assets');
     $this->baseUrl = $url;
     parent::init();
 }
コード例 #23
0
 public function init()
 {
     parent::init();
     if (YII_DEBUG) {
         $this->js[] = 'intercooler-debugger.js';
     }
 }
コード例 #24
0
ファイル: Asset.php プロジェクト: sacara/yii2-quill
 /**
  * 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);
 }
コード例 #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);
 }
コード例 #26
0
ファイル: ICheckAsset.php プロジェクト: axiles89/amop
 public function init()
 {
     if ($this->skin) {
         $this->css[] = "css/plugin/iCheck/square/{$this->skin}.css";
     }
     parent::init();
 }
コード例 #27
0
 public function init()
 {
     parent::init();
     if ($this->sourcePath == null) {
         $this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'assets';
     }
 }
コード例 #28
0
ファイル: TreeAssets.php プロジェクト: dkeeper/yii2-tree
 public function init()
 {
     $this->setSourcePath(__DIR__ . '/assets');
     $this->setupAssets('css', ['css/zTreeStyle']);
     $this->setupAssets('js', ['js/jquery.ztree.all-3.5']);
     parent::init();
 }
コード例 #29
0
 /**
  * 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);
     };
 }
コード例 #30
0
 public function init()
 {
     parent::init();
     $this->publishOptions['beforeCopy'] = function ($from, $to) {
         return strpos($from, 'fonts') !== false || strpos($from, 'css') !== false;
     };
 }