Clean up spellchecker attach code
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Feb 2010 06:21:53 +0000 (23:21 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Feb 2010 06:21:53 +0000 (23:21 -0700)
imp/compose-dimp.php
imp/compose.php
imp/js/compose-dimp.js
imp/js/compose.js
imp/lib/Ui/Compose.php
imp/message-dimp.php

index fd5fe81..d37a47f 100644 (file)
@@ -60,7 +60,7 @@ $imp_ui = new IMP_Ui_Compose();
 
 /* Attach spellchecker & auto completer. */
 $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc'));
-$imp_ui->attachSpellChecker('dimp');
+$imp_ui->attachSpellChecker();
 
 $show_editor = false;
 $title = _("New Message");
index edb8fdf..908bf11 100644 (file)
@@ -562,7 +562,7 @@ if ($browser->hasFeature('javascript')) {
             try {
                 Horde_SpellChecker::factory($conf['spell']['driver'], array());
                 $spellcheck = true;
-                $imp_ui->attachSpellChecker('imp', true);
+                $imp_ui->attachSpellChecker();
             } catch (Exception $e) {
                 Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
             }
index 13a18c6..34865c3 100644 (file)
@@ -187,9 +187,9 @@ var DimpCompose = {
     {
         var c = $('compose');
 
-        if (DIMP.SpellCheckerObject &&
-            DIMP.SpellCheckerObject.isActive()) {
-            DIMP.SpellCheckerObject.resume();
+        if (DIMP.SpellChecker &&
+            DIMP.SpellChecker.isActive()) {
+            DIMP.SpellChecker.resume();
             this.skip_spellcheck = true;
         }
 
@@ -203,10 +203,10 @@ var DimpCompose = {
 
                 if (!this.skip_spellcheck &&
                     DIMP.conf_compose.spellcheck &&
-                    DIMP.SpellCheckerObject &&
-                    !DIMP.SpellCheckerObject.isActive()) {
+                    DIMP.SpellChecker &&
+                    !DIMP.SpellChecker.isActive()) {
                     this.sc_submit = action;
-                    DIMP.SpellCheckerObject.spellCheck();
+                    DIMP.SpellChecker.spellCheck();
                     return;
                 }
                 break;
@@ -333,8 +333,8 @@ var DimpCompose = {
         DimpCore.loadingImg('sendingImg', 'composeMessageParent', disable);
         DimpCore.toggleButtons($('compose').select('DIV.dimpActions A'), disable);
         [ $('compose') ].invoke(disable ? 'disable' : 'enable');
-        if (DIMP.SpellCheckerObject) {
-            DIMP.SpellCheckerObject.disable(disable);
+        if (DIMP.SpellChecker) {
+            DIMP.SpellChecker.disable(disable);
         }
         if (this.editor_on) {
             this.RTELoading(disable ? 'show' : 'hide', true);
@@ -347,8 +347,8 @@ var DimpCompose = {
             return;
         }
         noupdate = noupdate || false;
-        if (DIMP.SpellCheckerObject) {
-            DIMP.SpellCheckerObject.resume();
+        if (DIMP.SpellChecker) {
+            DIMP.SpellChecker.resume();
         }
 
         var config, text;
@@ -414,7 +414,7 @@ var DimpCompose = {
 
     _onSpellCheckBefore: function()
     {
-        DIMP.SpellCheckerObject.htmlAreaParent = this.editor_on
+        DIMP.SpellChecker.htmlAreaParent = this.editor_on
             ? 'composeMessageParent'
             : null;
 
index e8c081a..5325754 100644 (file)
@@ -175,17 +175,17 @@ var ImpCompose = {
 
             if (!this.skip_spellcheck &&
                 this.spellcheck &&
-                IMP.SpellCheckerObject &&
-                !IMP.SpellCheckerObject.isActive()) {
+                IMP.SpellChecker &&
+                !IMP.SpellChecker.isActive()) {
                 this.sc_submit = { a: actionID, e: e };
-                IMP.SpellCheckerObject.spellCheck();
+                IMP.SpellChecker.spellCheck();
                 return;
             }
 
             this.skip_spellcheck = false;
 
-            if (IMP.SpellCheckerObject) {
-                IMP.SpellCheckerObject.resume();
+            if (IMP.SpellChecker) {
+                IMP.SpellChecker.resume();
             }
 
             // fall through
@@ -400,7 +400,7 @@ var ImpCompose = {
 
     _onBeforeSpellCheck: function()
     {
-        IMP.SpellCheckerObject.htmlAreaParent = 'composeMessageParent';
+        IMP.SpellChecker.htmlAreaParent = 'composeMessageParent';
         $('composeMessage').next().hide();
         CKEDITOR.instances.composeMessage.updateElement();
     },
index 0ea5ce1..664f004 100644 (file)
@@ -132,19 +132,26 @@ class IMP_Ui_Compose
     /**
      * Attach the spellchecker to the current compose form.
      */
-    public function attachSpellChecker($mode, $add_br = false)
+    public function attachSpellChecker()
     {
         $menu_view = $GLOBALS['prefs']->getValue('menu_view');
-        $show_text = ($menu_view == 'text' || $menu_view == 'both');
-        $br = ($add_br) ? '<br />' : '';
         $spell_img = Horde::img('spellcheck.png');
+
+        if (IMP::getViewMode() == 'imp') {
+            $br = '<br />';
+            $id = 'DIMP.SpellChecker';
+        } else {
+            $br = '';
+            $id = 'IMP.SpellChecker';
+        }
+
         $args = array(
-            'id' => ($mode == 'dimp' ? 'DIMP.' : 'IMP.') . 'SpellCheckerObject',
+            'id' => $id,
             'targetId' => 'composeMessage',
             'triggerId' => 'spellcheck',
             'states' => array(
-                'CheckSpelling' => $spell_img . ($show_text ? $br . _("Check Spelling") : ''),
-                'Checking' => $spell_img . $br . _("Checking ..."),
+                'CheckSpelling' => $spell_img . (($menu_view == 'text' || $menu_view == 'both') ? $br . _("Check Spelling") : ''),
+                'Checking' => $spell_img . $br . _("Checking..."),
                 'ResumeEdit' => $spell_img . $br . _("Resume Editing"),
                 'Error' => $spell_img . $br . _("Spell Check Failed")
             )
@@ -224,7 +231,7 @@ class IMP_Ui_Compose
         }
 
         Horde::addInlineScript(array(
-            'if (!window.IMP) { window.IMP = {}; }',
+            'window.IMP = window.IMP || {}',
             'IMP.ckeditor_config = {' . implode(',', $config) . '}'
         ));
     }
index 61deaed..06c6b41 100644 (file)
@@ -72,7 +72,7 @@ if (!$disable_compose) {
 
     /* Attach spellchecker & auto completer. */
     $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc'));
-    $imp_ui->attachSpellChecker('dimp');
+    $imp_ui->attachSpellChecker();
 
     $js_out = array_merge($js_out, $compose_result['js']);
     $scripts[] = array('compose-dimp.js', 'imp');