Issue #698: Non-async script callbacks are now also called before starting Reveal
This commit is contained in:
parent
0ffbe8d09c
commit
ffd8ccbffa
35
js/reveal.js
35
js/reveal.js
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user