// Variables defaulting to empty/false:
// auto_save_interval, compose_cursor, disabled, drafts_mbox, editor_on,
// is_popup, knl_p, knl_sm, mp_padding, resizebcc, resizecc, resizeto,
- // row_height, rte, skip_spellcheck, spellcheck, uploading
+ // row_height, rte, skip_spellcheck, spellcheck, sc_submit, uploading
last_msg: '',
confirmCancel: function()
DIMP.conf_compose.spellcheck &&
DIMP.SpellCheckerObject &&
!DIMP.SpellCheckerObject.isActive()) {
- DIMP.SpellCheckerObject.spellCheck(this.onNoSpellError.bind(this, action));
+ this.sc_submit = action;
+ DIMP.SpellCheckerObject.spellCheck();
return;
}
break;
}
},
- onNoSpellError: function(action)
- {
- this.skip_spellcheck = true;
- this.uniqueSubmit(action);
- },
-
toggleHtmlEditor: function(noupdate)
{
if (!DIMP.conf_compose.rte_avail) {
initializeSpellChecker: function()
{
- if (!DIMP.conf_compose.rte_avail) {
- return;
+ document.observe('SpellChecker:noerror', this._onSpellCheckNoError.bind(this));
+
+ if (DIMP.conf_compose.rte_avail) {
+ document.observe('SpellChecker:after', this._onSpellCheckAfter.bind(this));
+ document.observe('SpellChecker:before', this._onSpellCheckBefore.bind(this));
}
+ },
- if (typeof DIMP.SpellCheckerObject != 'object') {
- // If we fired before the onload that initializes the spellcheck,
- // wait.
- this.initializeSpellChecker.bind(this).defer();
- return;
+ _onSpellCheckAfter: function()
+ {
+ if (this.editor_on) {
+ this.rte.setData($F('composeMessage'));
+ $('composeMessage').next().show();
}
+ this.sc_submit = false;
+ },
- DIMP.SpellCheckerObject.onBeforeSpellCheck = function() {
- if (!this.editor_on) {
- return;
- }
- DIMP.SpellCheckerObject.htmlAreaParent = 'composeMessageParent';
+ _onSpellCheckBefore: function()
+ {
+ DIMP.SpellCheckerObject.htmlAreaParent = this.editor_on
+ ? 'composeMessageParent'
+ : null;
+
+ if (this.editor_on) {
this.rte.updateElement();
$('composeMessage').next().hide();
- }.bind(this);
- DIMP.SpellCheckerObject.onAfterSpellCheck = function() {
- if (!this.editor_on) {
- return;
- }
- DIMP.SpellCheckerObject.htmlAreaParent = null;
- this.rte.setData($F('composeMessage'));
- $('composeMessage').next().show();
- }.bind(this);
+ }
+ },
+
+ _onSpellCheckNoError: function()
+ {
+ if (this.sc_submit) {
+ this.skip_spellcheck = true;
+ this.uniqueSubmit(this.sc_submit);
+ } else {
+ DimpCore.showNotifications([ { type: 'horde.message', message: DIMP.text_compose.spell_noerror } ]);
+ this._onSpellCheckAfter();
+ }
},
setMessageText: function(r)
var ImpCompose = {
// Variables defined in compose.php:
// cancel_url, spellcheck, cursor_pos, identities, last_msg,
- // max_attachments, popup, redirect, reloaded, rtemode, smf_check,
- // skip_spellcheck
+ // max_attachments, popup, redirect, reloaded, rtemode, sc_submit,
+ // smf_check, skip_spellcheck
display_unload_warning: true,
confirmCancel: function(e)
this.spellcheck &&
IMP.SpellCheckerObject &&
!IMP.SpellCheckerObject.isActive()) {
- IMP.SpellCheckerObject.spellCheck(this.onNoSpellError.bind(this, actionID, e));
+ this.sc_submit = { a: actionID, e: e };
+ IMP.SpellCheckerObject.spellCheck();
return;
}
form.submit();
},
- onNoSpellError: function(actionID, e)
- {
- this.skip_spellcheck = true;
- this.uniqSubmit(actionID, e);
- },
-
_autoSaveDraft: function(r, o)
{
if (r.responseJSON && r.responseJSON.response) {
}
},
- initializeSpellChecker: function()
- {
- if (typeof IMP.SpellCheckerObject != 'object') {
- // If we fired before the onload that initializes the spellcheck,
- // wait.
- this.initializeSpellChecker.bind(this).defer();
- return;
- }
-
- IMP.SpellCheckerObject.onBeforeSpellCheck = this._beforeSpellCheck.bind(this);
- IMP.SpellCheckerObject.onAfterSpellCheck = this._afterSpellCheck.bind(this);
- },
-
- _beforeSpellCheck: function()
- {
- IMP.SpellCheckerObject.htmlAreaParent = 'composeMessageParent';
- $('composeMessage').next().hide();
- CKEDITOR.instances.composeMessage.updateElement();
- },
-
- _afterSpellCheck: function()
- {
- IMP.SpellCheckerObject.htmlAreaParent = null;
- CKEDITOR.instances.composeMessage.setData($F('composeMessage'));
- $('composeMessage').next().show();
- },
-
clickHandler: function(e)
{
if (e.isRightClick()) {
}
if (this.rtemode) {
- this.initializeSpellChecker();
+ document.observe('SpellChecker:after', this._onAfterSpellCheck.bind(this));
+ document.observe('SpellChecker:before', this._onBeforeSpellCheck.bind(this));
}
if ($('to') && !$F('to')) {
document.observe('click', this.clickHandler.bindAsEventListener(this));
document.observe('change', this.changeHandler.bindAsEventListener(this));
+ document.observe('SpellChecker:noerror', this._onNoErrorSpellCheck.bind(this));
if (this.auto_save) {
new PeriodicalExecuter(this.uniqSubmit.bind(this, 'auto_save_draft'), this.auto_save * 60);
this.resize.bind(this).delay(0.25);
},
+ _onAfterSpellCheck: function()
+ {
+ CKEDITOR.instances.composeMessage.setData($F('composeMessage'));
+ $('composeMessage').next().show();
+ this.sc_submit = null;
+ },
+
+ _onBeforeSpellCheck: function()
+ {
+ IMP.SpellCheckerObject.htmlAreaParent = 'composeMessageParent';
+ $('composeMessage').next().hide();
+ CKEDITOR.instances.composeMessage.updateElement();
+ },
+
+ onNoSpellError: function()
+ {
+ if (this.sc_submit) {
+ this.skip_spellcheck = true;
+ this.uniqSubmit(this.sc_submit.a, this.sc_submit.e);
+ } else if (this.rtemode) {
+ this._onAfterSpellCheck();
+ } else {
+ this.sc_submit = null;
+ }
+ },
+
resize: function()
{
var d, e = this.redirect ? $('redirect') : $('compose');