From 1fedcaac02aa680fd20720be8a6176dc54292fed Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 28 Jan 2010 01:14:46 -0700 Subject: [PATCH] Fix/improve disabling of ckeditor instance in dimp --- imp/js/compose-dimp.js | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index 057628514..592214ab9 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -355,42 +355,32 @@ var DimpCompose = { var config, text; if (this.editor_on) { - this.editor_on = false; - text = this.rte.getData(); - $('composeMessageParent').childElements().invoke('hide'); - $('composeMessage').show().setStyle({ visibility: null }).focus(); - this.RTELoading('show'); + this.rte.destroy(); + this.RTELoading('show'); DimpCore.doAction('Html2Text', { text: text }, { callback: this.setMessageText.bind(this), ajaxopts: { asynchronous: false } }); - this.RTELoading('hide'); } else { - this.editor_on = true; if (!noupdate) { DimpCore.doAction('Text2Html', { text: $F('composeMessage') }, { callback: this.setMessageText.bind(this), ajaxopts: { asynchronous: false } }); } - // Try to reuse the old fckeditor instance. - try { - this.rte.setData($F('composeMessage')); - $('composeMessageParent').childElements().invoke('show'); - $('composeMessage').hide(); - this.resizeMsgArea(); - } catch (e) { - config = Object.clone(IMP.ckeditor_config); - if (!config.on) { - config.on = {}; - } - config.on.instanceReady = function(evt) { - this.resizeMsgArea(); - this.RTELoading('hide'); - this.rte.focus(); - }.bind(this); - this.RTELoading('show'); - this.rte = CKEDITOR.replace('composeMessage', config); + config = Object.clone(IMP.ckeditor_config); + if (!config.on) { + config.on = {}; } + config.on.instanceReady = function(evt) { + this.resizeMsgArea(); + this.RTELoading('hide'); + this.rte.focus(); + }.bind(this); + this.RTELoading('show'); + this.rte = CKEDITOR.replace('composeMessage', config); } + + this.editor_on = !this.editor_on; + $('htmlcheckbox').setValue(this.editor_on); $('html').setValue(this.editor_on ? 1 : 0); }, -- 2.11.0