/**
  * @param AssetBundle $bundle
  */
 public function registerMonolith($bundle)
 {
     // Remove bundle and its dependencies from list
     unset($this->bundles[$bundle->className()]);
     if (!empty($bundle->publishOptions['accIncluded'])) {
         foreach ($bundle->publishOptions['accIncluded'] as $name) {
             if (isset($this->bundles[$name])) {
                 unset($this->bundles[$name]);
             }
         }
     }
     // Register files
     foreach ($bundle->js as $filename) {
         $this->owner->registerJsFile($bundle->baseUrl . '/' . $filename, $bundle->jsOptions);
     }
     foreach ($bundle->css as $filename) {
         $this->owner->registerCssFile($bundle->baseUrl . '/' . $filename, $bundle->cssOptions);
     }
 }
示例#2
0
 /**
  * Registers a JS file.
  * @param string $url the JS file to be registered.
  * @param array $options the HTML attributes for the script tag. The following options are specially handled
  * and are not treated as HTML attributes:
  *
  * - `depends`: array, specifies the names of the asset bundles that this JS file depends on.
  * - `position`: specifies where the JS script tag should be inserted in a page. The possible values are:
  *     * [[POS_HEAD]]: in the head section
  *     * [[POS_BEGIN]]: at the beginning of the body section
  *     * [[POS_END]]: at the end of the body section. This is the default value.
  *
  * Please refer to [[Html::jsFile()]] for other supported options.
  *
  * @param string $key the key that identifies the JS script file. If null, it will use
  * $url as the key. If two JS files are registered with the same key at the same position, the latter
  * will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
  * but different position option will not override each other.
  */
 public function registerJsFile($url, $options = [], $key = null)
 {
     $url = Yii::getAlias($url);
     $key = $key ?: $url;
     $depends = ArrayHelper::remove($options, 'depends', []);
     if (empty($depends)) {
         $position = ArrayHelper::remove($options, 'position', self::POS_END);
         $this->jsFiles[$position][$key] = Html::jsFile($url, $options);
     } else {
         $this->getAssetManager()->bundles[$key] = Yii::createObject(['class' => AssetBundle::className(), 'baseUrl' => '', 'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'jsOptions' => $options, 'depends' => (array) $depends]);
         $this->registerAssetBundle($key);
     }
 }
示例#3
0
<?php

use yii\web\View;
use yii\web\AssetBundle;
?>

<?php 
$this->registerJsFile('/js/last/jquery.js', [AssetBundle::className()]);
$this->registerJsFile('/player/video.js', [AssetBundle::className()]);
$this->registerCssFile('/player/video-js.css');
$this->registerJsFile('/player/video-init.js', [View::POS_END]);
?>

<h3>Player</h3

<!--<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"-->
<!--       poster="http://video-js.zencoder.com/oceans-clip.png"-->
<!--       data-setup="{}">-->
<!--    <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />-->
<!--    <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />-->
<!--    <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />-->
<!--    <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->-->
<!--    <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->-->
<!--    <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>-->
<!--</video>-->


<video id="example_video_2" class="video-js vjs-default-skin"
       controls preload="true" width="640" height="480"
<!--       poster="http://video-js.zencoder.com/oceans-clip.png"-->
<!--       data-setup='{"example_option":true}'>-->