From 55ca06ecb77f684da42bc230e37842a64335317c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 30 Mar 2009 17:11:40 -0600 Subject: [PATCH] Request #6892: If using spellcheck on send, automatically send if no spelling errors exist --- imp/docs/CHANGES | 2 ++ imp/js/src/SpellChecker.js | 22 +++++++++++++++++----- imp/js/src/compose.js | 16 +++++++++++++--- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 61a688376..bb6857e0f 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -66,6 +66,8 @@ v4.3.4-cvs [mms] SECURITY: Don't cache local PGP public keys retrieved from the addressbook (found by Peter Meier ). +[mms] If using spellcheck on send, automatically send if no spelling errors + exist (Request #6892). [jan] Show all addresses when printing messages. [mms] Fix cache issues in folder tree when deleting a mailbox (Bug #7745). [mms] Fix updating POP3 indices when deleting in mailbox view (Bug #8035). diff --git a/imp/js/src/SpellChecker.js b/imp/js/src/SpellChecker.js index 1413e95c5..e21d90818 100644 --- a/imp/js/src/SpellChecker.js +++ b/imp/js/src/SpellChecker.js @@ -10,10 +10,11 @@ */ var SpellChecker = Class.create({ + // Vars used and defaulting to null: // bad, choices, choicesDiv, curWord, htmlArea, htmlAreaParent, locale, - // localeChoices, onAfterSpellCheck, onBeforeSpellCheck, reviewDiv, - // statusButton, statusClass, suggestions, target, url + // localeChoices, onAfterSpellCheck, onBeforeSpellCheck, onNoError, + // reviewDiv, statusButton, statusClass, suggestions, target, url options: {}, resumeOnDblClick: true, state: 'CheckSpelling', @@ -94,7 +95,10 @@ var SpellChecker = Class.create({ e.stop(); }, - spellCheck: function() + // noerror - (function) A callback function to run if no errors are + // identified. If not specified, will remain in spell check + // mode even if no errors are present. + spellCheck: function(noerror) { if (this.onBeforeSpellCheck) { this.onBeforeSpellCheck(); @@ -107,6 +111,8 @@ var SpellChecker = Class.create({ this.status('Checking'); this.removeChoices(); + this.onNoError = noerror; + p.set(this.target, this.targetValue()); opts.parameters = p.toQueryString(); @@ -160,14 +166,20 @@ var SpellChecker = Class.create({ this.removeChoices(); if (Object.isUndefined(result)) { - this.resume(); this.status('Error'); return; } - bad = result.bad || []; this.suggestions = result.suggestions || []; + if (this.onNoError && !this.suggestions.size()) { + this.status('CheckSpelling'); + this.onNoError(); + return; + } + + bad = result.bad || []; + content = this.targetValue(); if (this.htmlAreaParent) { content = content.replace(/\r?\n/g, ''); diff --git a/imp/js/src/compose.js b/imp/js/src/compose.js index 419545033..6fbb430b3 100644 --- a/imp/js/src/compose.js +++ b/imp/js/src/compose.js @@ -8,7 +8,7 @@ var ImpCompose = { /* Variables defined in compose.php: * cancel_url, spellcheck, cursor_pos, identities, max_attachments, - * popup, redirect, reloaded, rtemode, smf_check */ + * popup, redirect, reloaded, rtemode, smf_check, skip_spellcheck */ display_unload_warning: true, textarea_ready: true, @@ -172,14 +172,18 @@ var ImpCompose = { return; } - if (this.spellcheck && + if (!this.skip_spellcheck && + this.spellcheck && IMP.SpellCheckerObject && !IMP.SpellCheckerObject.isActive()) { - IMP.SpellCheckerObject.spellCheck(); + IMP.SpellCheckerObject.spellCheck(this.onNoSpellError.bind(this, actionID, e)); return; } + } + this.skip_spellcheck = false; + if (IMP.SpellCheckerObject) { IMP.SpellCheckerObject.resume(); } @@ -203,6 +207,12 @@ var ImpCompose = { } }, + onNoSpellError: function(actionID, e) + { + this.skip_spellcheck = true; + this.uniqSubmit(actionID, e); + }, + attachmentChanged: function() { var fields = [], -- 2.11.0