Implement spellcheck on send for dimp
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 23:12:08 +0000 (17:12 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 23:12:53 +0000 (17:12 -0600)
imp/docs/CHANGES
imp/js/src/compose-dimp.js
imp/lib/DIMP.php

index bb6857e..80e8aff 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Implement spellcheck on send in DIMP.
 [mms] Sanity check - don't do message operations reliant on UID list if
       UIDVALIDITY of mailbox has changed.
 [mms] Simplify forwarding - always attach entire message.
index 791192b..d33c5e5 100644 (file)
@@ -11,7 +11,7 @@ var DimpCompose = {
     // Variables defaulting to empty/false:
     //   auto_save_interval, button_pressed, compose_cursor, dbtext,
     //   editor_on, mp_padding, resizebcc, resizecc, resizeto, row_height,
-    //   sbtext, uploading
+    //   sbtext, skip_spellcheck, spellcheck, uploading
     last_msg: '',
     textarea_ready: true,
 
@@ -126,16 +126,16 @@ var DimpCompose = {
         var db, params, sb,
             c = $('compose');
 
-        if (DIMP.SpellCheckerObject) {
+        if (DIMP.SpellCheckerObject &&
+            DIMP.SpellCheckerObject.isActive()) {
             DIMP.SpellCheckerObject.resume();
+            this.skip_spellcheck = true;
             if (!this.textarea_ready) {
                 this.uniqueSubmit.bind(this, action).defer();
                 return;
             }
         }
 
-        c.setStyle({ cursor: 'wait' });
-
         if (action == 'send_message' || action == 'save_draft') {
             this.button_pressed = true;
 
@@ -146,6 +146,14 @@ var DimpCompose = {
                     return;
                 }
 
+                if (!this.skip_spellcheck &&
+                    DIMP.conf_compose.spellcheck &&
+                    DIMP.SpellCheckerObject &&
+                    !DIMP.SpellCheckerObject.isActive()) {
+                    DIMP.SpellCheckerObject.spellCheck(this.onNoSpellError.bind(this, action));
+                    return;
+                }
+
                 if (!this.sbtext) {
                     sb = $('send_button');
                     this.sbtext = sb.getText();
@@ -168,6 +176,9 @@ var DimpCompose = {
                 return;
             }
         }
+
+        c.setStyle({ cursor: 'wait' });
+        this.skip_spellcheck = false;
         $('action').setValue(action);
 
         if (action == 'add_attachment') {
@@ -286,6 +297,12 @@ var DimpCompose = {
         DimpCore.showNotifications(r.msgs);
     },
 
+    onNoSpellError: function(action)
+    {
+        this.skip_spellcheck = true;
+        this.uniqueSubmit(action);
+    },
+
     toggleHtmlEditor: function(noupdate)
     {
         if (!DIMP.conf_compose.rte_avail) {
index 75250ce..2b8d8fb 100644 (file)
@@ -259,7 +259,7 @@ class DIMP
                 'attach_limit' => ($conf['compose']['attach_count_limit'] ? intval($conf['compose']['attach_count_limit']) : -1),
                 'close_draft' => $prefs->getValue('close_draft'),
                 'compose_cursor' => ($compose_cursor ? $compose_cursor : 'top'),
-
+                'spellcheck' => intval($prefs->getValue('compose_spellcheck')),
             );
 
             if ($registry->hasMethod('contacts/search')) {