Skip to content

Commit

Permalink
Merge branch 'feature/api-ready-refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
heff committed Feb 3, 2012
2 parents 56355e5 + 4fdbf91 commit 0f45812
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 145 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,3 +1,4 @@
* Refactored API to be more immediately available.
--------------------------------------------------------------------------------
^ ADD NEW CHANGES ABOVE ^
--------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/component.js
Expand Up @@ -184,6 +184,9 @@ _V_.Component = _V_.Class.extend({

// Reset Ready Queue
this.readyQueue = [];

// Allow for using event listeners also, in case you want to do something everytime a source is ready.
this.triggerEvent("ready");
}
},

Expand Down
52 changes: 1 addition & 51 deletions src/core.js
Expand Up @@ -113,54 +113,4 @@ VideoJS.options = {
// Set CDN Version of swf
if (CDN_VERSION != "GENERATED_CDN_VSN") {
_V_.options.flash.swf = "http://vjs.zencdn.net/"+CDN_VERSION+"/video-js.swf"
}

// Automatically set up any tags that have a data-setup attribute
_V_.autoSetup = function(){
var options, vid, player,
vids = document.getElementsByTagName("video");

// Check if any media elements exist
if (vids && vids.length > 0) {

for (var i=0,j=vids.length; i<j; i++) {
vid = vids[i];

// Check if element exists, has getAttribute func.
// IE seems to consider typeof el.getAttribute == "object" instead of "function" like expected, at least when loading the player immediately.
if (vid && vid.getAttribute) {

// Make sure this player hasn't already been set up.
if (vid.player === undefined) {
options = vid.getAttribute("data-setup");

// Check if data-setup attr exists.
// We only auto-setup if they've added the data-setup attr.
if (options !== null) {

// Parse options JSON
// If empty string, make it a parsable json object.
options = JSON.parse(options || "{}");

// Create new video.js instance.
player = _V_(vid, options);
}
}

// If getAttribute isn't defined, we need to wait for the DOM.
} else {
_V_.autoSetupTimeout(1);
break;
}
}

// No videos were found, so keep looping unless page is finisehd loading.
} else if (!_V_.windowLoaded) {
_V_.autoSetupTimeout(1);
}
};

// Pause to let the DOM keep processing
_V_.autoSetupTimeout = function(wait){
setTimeout(_V_.autoSetup, wait);
};
}

0 comments on commit 0f45812

Please sign in to comment.