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

View File

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