From 560f12cffca827abd7571309f73c1132f150a110 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 13 Sep 2013 16:45:54 +0200 Subject: [PATCH] [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 --- .../static/lib/ckeditor/core/resourcemanager.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/website/static/lib/ckeditor/core/resourcemanager.js b/addons/website/static/lib/ckeditor/core/resourcemanager.js index 3570580df9d..6132ee8000f 100644 --- a/addons/website/static/lib/ckeditor/core/resourcemanager.js +++ b/addons/website/static/lib/ckeditor/core/resourcemanager.js @@ -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 );