Issue #698: Non-async script callbacks are now also called before starting Reveal

This commit is contained in:
Thomas Endres 2013-11-10 16:16:49 +01:00
parent 0ffbe8d09c
commit ffd8ccbffa
1 changed files with 52 additions and 43 deletions

View File

@ -250,9 +250,19 @@ var Reveal = (function(){
* will load after reveal.js has been started up. * will load after reveal.js has been started up.
*/ */
function load() { function load() {
var scripts = [], var scripts = [],
scriptsAsync = []; scriptsAsync = [],
scriptsToApply = 0;
// Called once synchronous scripts finish loading
function proceed() {
if( scriptsAsync.length ) {
// Load asynchronous scripts
head.js.apply( null, scriptsAsync );
}
start();
}
for( var i = 0, len = config.dependencies.length; i < len; i++ ) { for( var i = 0, len = config.dependencies.length; i < len; i++ ) {
var s = config.dependencies[i]; var s = config.dependencies[i];
@ -267,24 +277,23 @@ var Reveal = (function(){
} }
// Extension may contain callback functions // Extension may contain callback functions
(function(s) {
head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], function() {
if( typeof s.callback === 'function' ) { if( typeof s.callback === 'function' ) {
head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], s.callback ); 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 ); });
})(s);
} }
start();
} }
if( scripts.length ) { if( scripts.length ) {
scripts.push(proceed); scriptsToApply = scripts.length;
// Load synchronous scripts // Load synchronous scripts
head.js.apply( null, scripts ); head.js.apply( null, scripts );