From 65a0607d8acf22d86b7e1c20d4151ac0543b4896 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 24 Apr 2013 08:54:34 +0200 Subject: [PATCH] [FIX] finally fix problems with popups in chrome --- web_ckeditor4/static/src/js/web_ckeditor4.js | 34 ++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/web_ckeditor4/static/src/js/web_ckeditor4.js b/web_ckeditor4/static/src/js/web_ckeditor4.js index a2f7ebe3..b73f404e 100644 --- a/web_ckeditor4/static/src/js/web_ckeditor4.js +++ b/web_ckeditor4/static/src/js/web_ckeditor4.js @@ -22,6 +22,32 @@ openerp.web_ckeditor4 = function(openerp) { + var ckeditor_addFunction_org = CKEDITOR.tools.addFunction; + //this is a quite complicated way to kind of monkey patch the private + //method onDomReady of ckeditor's plugin wysiwigarea, which causes problems + //when the editor is about to be destroyed but because of OpenERP's + //architecture updated one last time with its current value + CKEDITOR.tools.addFunction = function(fn, scope) + { + if(scope && scope._ && scope._.attrChanges && scope._.detach) + { + var scope_reference = scope; + return ckeditor_addFunction_org(function() + { + var self = this, + self_arguments=arguments; + setTimeout(function() + { + if(CKEDITOR.instances[self.editor.name]) + { + fn.apply(self, self_arguments); + } + }, 0); + }, scope); + } + return ckeditor_addFunction_org(fn, scope); + }; + CKEDITOR.lang.load(openerp.connection.user_context.lang.split('_')[0], 'en', function() {}); CKEDITOR.on('dialogDefinition', function(e) @@ -161,11 +187,7 @@ openerp.web_ckeditor4 = function(openerp) } else { - //set_value is called shortly before saving and closing - //popups. if we don't suppress ckeditor's events about - //that, we get a lot of strange errors concerning - //already cleaned up elements - self.editor.setData(value || '', null, true); + self.editor.setData(value || ''); } } this._super.apply(this, arguments); @@ -176,7 +198,7 @@ openerp.web_ckeditor4 = function(openerp) { if(this.editor) { - this.editor.destroy(); + CKEDITOR.remove(this.editor); } return this._super.apply(this, arguments); }