This commit is contained in:
Hakim El Hattab 2013-11-26 17:08:43 -05:00
commit 75845a92c3
1 changed files with 55 additions and 43 deletions

View File

@ -242,58 +242,70 @@ var Reveal = (function(){
} }
/**
* Loads the dependencies of reveal.js. Dependencies are
* defined via the configuration option 'dependencies'
* and will be loaded prior to starting/binding reveal.js.
* Some dependencies may have an 'async' flag, if so they
* will load after reveal.js has been started up.
*/
function load() {
var scripts = [], /**
scriptsAsync = []; * Loads the dependencies of reveal.js. Dependencies are
* defined via the configuration option 'dependencies'
* and will be loaded prior to starting/binding reveal.js.
* Some dependencies may have an 'async' flag, if so they
* will load after reveal.js has been started up.
*/
function load() {
var scripts = [],
scriptsAsync = [],
scriptsToApply = 0;
for( var i = 0, len = config.dependencies.length; i < len; i++ ) { // Called once synchronous scripts finish loading
var s = config.dependencies[i]; function proceed() {
if( scriptsAsync.length ) {
// Load asynchronous scripts
head.js.apply( null, scriptsAsync );
}
// Load if there's no condition or the condition is truthy start();
if( !s.condition || s.condition() ) { }
if( s.async ) {
scriptsAsync.push( s.src );
}
else {
scripts.push( s.src );
}
// Extension may contain callback functions function loadDependency(s) {
if( typeof s.callback === 'function' ) { head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], function() {
head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], s.callback ); // Extension may contain callback functions
} if( typeof s.callback === 'function' ) {
} s.callback.apply(this);
} }
// Called once synchronous scripts finish loading scriptsToApply--;
function proceed() { if (scriptsToApply === 0) {
if( scriptsAsync.length ) { proceed();
// Load asynchronous scripts }
head.js.apply( null, scriptsAsync ); });
} }
start(); for( var i = 0, len = config.dependencies.length; i < len; i++ ) {
} var s = config.dependencies[i];
if( scripts.length ) { // Load if there's no condition or the condition is truthy
head.ready( proceed ); if( !s.condition || s.condition() ) {
if( s.async ) {
scriptsAsync.push( s.src );
}
else {
scripts.push( s.src );
}
// Load synchronous scripts loadDependency(s);
head.js.apply( null, scripts ); }
} }
else {
proceed();
}
} if( scripts.length ) {
scriptsToApply = scripts.length;
// Load synchronous scripts
head.js.apply( null, scripts );
}
else {
proceed();
}
}
/** /**
* Starts up reveal.js by binding input events and navigating * Starts up reveal.js by binding input events and navigating