Issue #698: Non-async script callbacks are now also called before starting Reveal
This commit is contained in:
parent
0ffbe8d09c
commit
ffd8ccbffa
1 changed files with 52 additions and 43 deletions
95
js/reveal.js
95
js/reveal.js
|
@ -242,58 +242,67 @@ var Reveal = (function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the dependencies of reveal.js. Dependencies are
|
* Loads the dependencies of reveal.js. Dependencies are
|
||||||
* defined via the configuration option 'dependencies'
|
* defined via the configuration option 'dependencies'
|
||||||
* and will be loaded prior to starting/binding reveal.js.
|
* and will be loaded prior to starting/binding reveal.js.
|
||||||
* Some dependencies may have an 'async' flag, if so they
|
* Some dependencies may have an 'async' flag, if so they
|
||||||
* will load after reveal.js has been started up.
|
* will load after reveal.js has been started up.
|
||||||
*/
|
*/
|
||||||
function load() {
|
function load() {
|
||||||
|
var scripts = [],
|
||||||
|
scriptsAsync = [],
|
||||||
|
scriptsToApply = 0;
|
||||||
|
|
||||||
var scripts = [],
|
// Called once synchronous scripts finish loading
|
||||||
scriptsAsync = [];
|
function proceed() {
|
||||||
|
if( scriptsAsync.length ) {
|
||||||
|
// Load asynchronous scripts
|
||||||
|
head.js.apply( null, scriptsAsync );
|
||||||
|
}
|
||||||
|
|
||||||
for( var i = 0, len = config.dependencies.length; i < len; i++ ) {
|
start();
|
||||||
var s = config.dependencies[i];
|
}
|
||||||
|
|
||||||
// Load if there's no condition or the condition is truthy
|
for( var i = 0, len = config.dependencies.length; i < len; i++ ) {
|
||||||
if( !s.condition || s.condition() ) {
|
var s = config.dependencies[i];
|
||||||
if( s.async ) {
|
|
||||||
scriptsAsync.push( s.src );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scripts.push( s.src );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extension may contain callback functions
|
// Load if there's no condition or the condition is truthy
|
||||||
if( typeof s.callback === 'function' ) {
|
if( !s.condition || s.condition() ) {
|
||||||
head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], s.callback );
|
if( s.async ) {
|
||||||
}
|
scriptsAsync.push( s.src );
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
scripts.push( s.src );
|
||||||
|
}
|
||||||
|
|
||||||
// Called once synchronous scripts finish loading
|
// Extension may contain callback functions
|
||||||
function proceed() {
|
(function(s) {
|
||||||
if( scriptsAsync.length ) {
|
head.ready( s.src.match( /([\w\d_\-]*)\.?js$|[^\\\/]*$/i )[0], function() {
|
||||||
// Load asynchronous scripts
|
if( typeof s.callback === 'function' ) {
|
||||||
head.js.apply( null, scriptsAsync );
|
s.callback.apply(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
scriptsToApply--;
|
||||||
}
|
if (scriptsToApply === 0) {
|
||||||
|
proceed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proceed();
|
proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up reveal.js by binding input events and navigating
|
* Starts up reveal.js by binding input events and navigating
|
||||||
|
|
Loading…
Reference in a new issue