[FIX] monkey patch CKEDITOR loading

Order of plugin initialization is apparently completely fucked, and
most definitely does not take dependencies in account (the
dependencies get loaded, but *when* they are...).

One of the things which drives init order is local (already loaded)
versus remote (js file to fetch): local plugins will be initialized
before remote, whatever the dependencies are.

Monkey patch resourcemanager's load method so it yields an object
initialized in order of its input (nb *still* not dependency order) to
ensure our local plugins are loaded after all builtin ones.

bzr revid: xmo@openerp.com-20130913144554-020u1367wto6ooh9
This commit is contained in:
Xavier Morel
2013-09-13 16:45:54 +02:00
parent 16492e4ca7
commit 560f12cffc
@@ -172,8 +172,7 @@ CKEDITOR.resourceManager.prototype = {
var loaded = this.loaded,
registered = this.registered,
urls = [],
urlsNames = {},
resources = {};
urlsNames = {};
// Loop through all names.
for ( var i = 0; i < names.length; i++ ) {
@@ -189,8 +188,7 @@ CKEDITOR.resourceManager.prototype = {
if ( !( url in urlsNames ) )
urlsNames[ url ] = [];
urlsNames[ url ].push( name );
} else
resources[ name ] = this.get( name );
}
}
CKEDITOR.scriptLoader.load( urls, function( completed, failed ) {
@@ -203,11 +201,16 @@ CKEDITOR.resourceManager.prototype = {
var nameList = urlsNames[ completed[ i ] ];
for ( var j = 0; j < nameList.length; j++ ) {
var name = nameList[ j ];
resources[ name ] = this.get( name );
loaded[ name ] = 1;
}
}
var resources = {};
for ( var k = 0; k < names.length; ++k ) {
var name_ = names[ k ];
if ( !name_ ) continue;
resources[ name_ ] = this.get( name_ );
}
callback.call( scope, resources );
}, this );