Permalink
Browse files

Close GH-346: Remove need for good.require/good.provide.

  • Loading branch information...
1 parent 191a9d6 commit 60f9b505f178e5fbe49c13871dfb96f7639dc0b0 @dmlap dmlap committed with heff Feb 23, 2013
View
@@ -5,6 +5,16 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
build: {
+ src: 'src/js/dependencies.js',
+ options: {
+ baseDir: 'src/js/'
+ }
+ },
+ deps: {
+ src: 'src/js/dependencies.js',
+ options: {
+ baseDir: 'src/js/'
+ }
},
clean: {
build: ['build/files/*'],
@@ -22,13 +32,12 @@ module.exports = function(grunt) {
},
minify: {
source:{
- sourcelist: 'build/files/sourcelist.txt',
+ src: ['build/files/combined.video.js'],
externs: ['src/js/media.flash.externs.js'],
dest: 'build/files/minified.video.js'
},
tests: {
- sourcelist: 'build/files/sourcelist.txt',
- src: ['test/unit/*.js'],
+ src: ['build/files/combined.video.js', 'test/unit/*.js'],
externs: ['src/js/media.flash.externs.js', 'test/qunit/qunit-externs.js'],
dest: 'build/files/test.minified.video.js'
}
@@ -42,17 +51,6 @@ module.exports = function(grunt) {
files: [ 'src/**/*.js', 'test/unit/*.js' ],
tasks: 'dev'
}
- // Copy is broken. Waiting for an update to use.
- // copy: {
- // latest: {
- // files: [
- // { src: ['dist/video-js'], dest: 'dist/latest' } // includes files in path
- // // {src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
- // // {expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
- // // {expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
- // ]
- // }
- // },
});
grunt.loadNpmTasks('grunt-contrib-jshint');
@@ -70,48 +68,34 @@ module.exports = function(grunt) {
var fs = require('fs'),
gzip = require('zlib').gzip;
- grunt.registerTask('build', 'Building Source', function(){
- grunt.file.copy('src/css/video-js.css', 'build/files/video-js.css');
- grunt.file.copy('src/css/video-js.png', 'build/files/video-js.png');
- grunt.file.copy('src/swf/video-js.swf', 'build/files/video-js.swf');
+ grunt.registerMultiTask('build', 'Building Source', function(){
+ /*jshint undef:false, evil:true */
- var calcdeps = require('calcdeps').calcdeps;
- // caclcdeps is async
- var done = this.async();
- // In current version of calcdeps, not supplying certain
- // options that should have defaults causes errors
- // so we have all options listed here with their defaults.
- calcdeps({
- input: ['src/js/exports.js'],
- path:['src/js/'],
- dep:[],
- exclude:[],
- output_mode:'list'
- }, function(err,results){
- if (err) {
- grunt.warn({ message: err });
- grunt.log.writeln(err);
- done(false);
- }
+ // Loading predefined source order from source-loader.js
+ // Trust me, this is the easist way to do it so far.
+ var blockSourceLoading = true;
+ eval(grunt.file.read('./build/source-loader.js'));
- if (results) {
- var i = results.length;
- while (i--) {
- results[i] = results[i].replace(/\\/g, '/');
- }
- grunt.file.write('build/files/sourcelist.txt', results.join(','));
- grunt.file.write('build/files/sourcelist.js', 'var sourcelist = ["' + results.join('","') + '"]');
-
- // Create a combined sources file. https://github.com/zencoder/video-js/issues/287
- var combined = '';
- results.forEach(function(result){
- combined += grunt.file.read(result);
- });
- grunt.file.write('build/files/combined.video.js', combined);
- }
+ // Fix windows file path delimiter issue
+ var i = sourceFiles.length;
+ while (i--) {
+ sourceFiles[i] = sourceFiles[i].replace(/\\/g, '/');
+ }
- done();
+ // grunt.file.write('build/files/sourcelist.txt', sourceList.join(','));
+ // Allow time for people to update their index.html before they remove these
+ grunt.file.write('build/files/sourcelist.js', 'var sourcelist = ["' + sourceFiles.join('","') + '"]');
+
+ // Create a combined sources file. https://github.com/zencoder/video-js/issues/287
+ var combined = '';
+ sourceFiles.forEach(function(result){
+ combined += grunt.file.read(result);
});
+ grunt.file.write('build/files/combined.video.js', combined);
+
+ grunt.file.copy('src/css/video-js.css', 'build/files/video-js.css');
+ grunt.file.copy('src/css/video-js.png', 'build/files/video-js.png');
+ grunt.file.copy('src/swf/video-js.swf', 'build/files/video-js.swf');
});
grunt.registerMultiTask('minify', 'Minify JS files using Closure Compiler.', function() {
@@ -174,5 +158,17 @@ module.exports = function(grunt) {
grunt.file.copy('build/files/video-js.swf', 'dist/video-js/video-js.swf');
grunt.file.copy('build/demo-files/demo.html', 'dist/video-js/demo.html');
grunt.file.copy('build/demo-files/demo.captions.vtt', 'dist/video-js/demo.captions.vtt');
+
+ // Copy is broken. Waiting for an update to use.
+ // copy: {
+ // latest: {
+ // files: [
+ // { src: ['dist/video-js'], dest: 'dist/latest' } // includes files in path
+ // // {src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
+ // // {expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
+ // // {expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
+ // ]
+ // }
+ // },
});
};
View
@@ -0,0 +1,59 @@
+// This file is used to load the video.js source files into a page
+// in the correct order based on dependencies.
+// When you create a new source file you will need to add
+// it to the list below to use it in sandbox/index.html and
+// test/index.html
+
+// You can use the projectRoot variable to adjust relative urls
+// that this script loads. By default it's "../", which is what /sandbox
+// and /test need. If you had sandbox/newDir/index.html, in index.html you
+// would set projectRoot = "../../"
+
+// We could use somehting like requireJS to load files, and at one point
+// we used goog.require/provide to load dependencies, but that seems like
+// overkill with the small number of files we actually have.
+
+// ADD NEW SOURCE FILES HERE
+var sourceFiles = [
+ "src/js/goog.base.js",
+ "src/js/core.js",
+ "src/js/events.js",
+ "src/js/lib.js",
+ "src/js/component.js",
+ "src/js/player.js",
+ "src/js/controls.js",
+ "src/js/media.js",
+ "src/js/media.html5.js",
+ "src/js/media.flash.js",
+ "src/js/tracks.js",
+ "src/js/json.js",
+ "src/js/setup.js",
+ "src/js/plugins.js",
+ "src/js/exports.js"
+];
+
+// Allow overriding the default project root
+var projectRoot = projectRoot || '../';
+
+function loadScripts(scriptsArr){
+ for (var i = 0; i < scriptsArr.length; i++) {
+ // Using document.write because that's the easiest way to avoid triggering
+ // asynchrnous script loading
+ document.write( "<script src='" + projectRoot + scriptsArr[i] + "'><\/script>" );
+ }
+}
+
+// We use this file in the grunt build script to load the same source file list
+// and don't want to load the scripts there.
+if (typeof blockSourceLoading === 'undefined') {
+ loadScripts(sourceFiles);
+
+ // Allow for making Flash first
+ if (window.location.href.indexOf("?flash") !== -1) {
+ // Using doc.write to load this script to, otherwise when it runs videojs
+ // is undefined
+ document.write('<script>videojs.options.techOrder = ["flash"];videojs.options.flash.swf = "../src/swf/video-js.swf";</script>')
+ }
+}
+
+
View
@@ -6,43 +6,8 @@
<link href="../src/css/video-js.css" rel="stylesheet" type="text/css">
- <!--[if IE]>
- <script src="https://getfirebug.com/releases/lite/1.4/firebug-lite.js"></script>
- <!--<![endif]-->
-
- <!-- GENERATED LIST OF SOURCE FILES -->
- <script src="../build/files/sourcelist.js"></script>
-
- <script>
- (function(){
-
- // Load source list generated by build script
- if (!sourcelist) {
- console.log('run `grunt` to generate source list');
- } else {
- var root = '../';
-
- for (var i = 0; i < sourcelist.length; i++) {
- document.write( "<script src='" + root + sourcelist[i] + "'><\/script>" );
- }
- }
-
- // Easy access to test Flash over HTML5. Add ?flash to URL
- if (window.location.href.indexOf("?flash") !== -1) {
- videojs.options.techOrder = ["Flash"];
- videojs.options.flash.swf = "../src/swf/video-js.swf";
- }
-
- })()
- </script>
-
- <script type="text/javascript" charset="utf-8">
- // Easy access to test Flash over HTML5. Add ?flash to URL
- if (window.location.href.indexOf("?flash") !== -1) {
- videojs.options.techOrder = ["flash"];
- videojs.options.flash.swf = "../src/swf/video-js.swf";
- }
- </script>
+ <!-- LOAD VIDEO.JS SOURCE FILES IN ORDER -->
+ <script src="../build/source-loader.js"></script>
</head>
<body>
@@ -6,42 +6,14 @@
<link href="../src/css/video-js.css" rel="stylesheet" type="text/css">
- <!--[if IE]>
- <script src="https://getfirebug.com/releases/lite/1.4/firebug-lite.js"></script>
- <!--<![endif]-->
+ <!-- LOAD VIDEO.JS SOURCE FILES IN ORDER -->
+ <script src="../build/source-loader.js"></script>
- <!-- GENERATED LIST OF SOURCE FILES -->
- <script src="../build/files/sourcelist.js"></script>
-
- <script>
- (function(){
-
- // Load source list generated by build script
- if (!sourcelist) {
- console.log('run `grunt` to generate source list');
- } else {
- var root = '../';
-
- for (var i = 0; i < sourcelist.length; i++) {
- document.write( "<script src='" + root + sourcelist[i] + "'><\/script>" );
- }
- }
- })()
- </script>
- <script>
- // Easy access to test Flash over HTML5. Add ?flash to URL
- if (window.location.href.indexOf("?flash") !== -1) {
- videojs.options.techOrder = ["flash"];
- videojs.options.flash.swf = "../src/swf/video-js.swf";
- }
- </script>
</head>
<body>
<p style="background-color:#eee; border: 1px solid #777; padding: 10px; font-size: .8em; line-height: 1.5em; font-family: Verdana, sans-serif;">This page shows you how to create, register and initialize a Video.js plugin.</p>
- <video id="vid1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264"
- poster="http://video-js.zencoder.com/oceans-clip.png"
- data-setup='{}'>
+ <video id="vid1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png">
<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'>
View
@@ -3,11 +3,6 @@
*
*/
-goog.provide('vjs.Component');
-
-goog.require('vjs.events');
-goog.require('vjs.dom');
-
/**
* Base UI Component class
* @param {Object} player Main Player
View
@@ -2,12 +2,6 @@
* @fileoverview Controls classes for Video.js buttons, sliders, etc.
*/
-goog.provide('vjs.Control');
-goog.provide('vjs.Menu');
-goog.provide('vjs.MenuItem');
-
-goog.require('vjs.Player');
-
/**
* Base class for all control elements
* @param {vjs.Player|Object} player
@@ -531,6 +525,10 @@ vjs.Slider.prototype.onMouseUp = function() {
};
vjs.Slider.prototype.update = function(){
+ // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
+ // execution stack. The player is destroyed before then update will cause an error
+ if (!this.el_) return;
+
// If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
// On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
// var progress = (this.player_.scrubbing) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
@@ -930,7 +928,7 @@ vjs.MuteToggle.prototype.update = function(){
} else if (vol < 0.67) {
level = 2;
}
-
+
// Don't rewrite the button text if the actual text doesn't change.
// This causes unnecessary and confusing information for screen reader users.
// This check is needed because this function gets called every time the volume level is changed.
View
@@ -2,9 +2,6 @@
* @fileoverview Main function src.
*/
-goog.provide('vjs');
-goog.provide('videojs');
-
// HTML5 Shiv. Must be in <head> to support older browsers.
document.createElement('video');document.createElement('audio');
@@ -17,7 +14,7 @@ document.createElement('video');document.createElement('audio');
* @param {Function=} ready Optional ready callback
* @return {vjs.Player} A player instance
*/
-vjs = function(id, options, ready){
+var vjs = function(id, options, ready){
var tag; // Element of ID
// Allow for element or ID to be passed in
View
@@ -5,10 +5,6 @@
* robust as jquery's, so there's probably some differences.
*/
-goog.provide('vjs.events');
-
-goog.require('vjs');
-
/**
* Add an event listener to element
* It stores the handler function in a separate cache object
View
@@ -5,16 +5,6 @@
* be renamed by closure compiler.
*/
-goog.require('vjs');
-goog.require('vjs.Component');
-goog.require('vjs.Player');
-goog.require('vjs.Control');
-goog.require('vjs.Html5');
-goog.require('vjs.Flash');
-goog.require('vjs.TextTrack');
-goog.require('vjs.autoSetup');
-goog.require('vjs.plugin');
-
/**
* vjs (internal only) = videojs = _V_ (external only)
*
Oops, something went wrong.

0 comments on commit 60f9b50

Please sign in to comment.