From: Michael M Slusarz Date: Thu, 25 Feb 2010 06:21:53 +0000 (-0700) Subject: Clean up spellchecker attach code X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fb2ab22128332933c1eaf5e4900d0c08c99ca9b5;p=horde.git Clean up spellchecker attach code --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index fd5fe8107..d37a47f1f 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -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"); diff --git a/imp/compose.php b/imp/compose.php index edb8fdfd3..908bf1188 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -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); } diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index 13a18c63e..34865c3ab 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -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; diff --git a/imp/js/compose.js b/imp/js/compose.js index e8c081a95..53257548c 100644 --- a/imp/js/compose.js +++ b/imp/js/compose.js @@ -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(); }, diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index 0ea5ce185..664f00453 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -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) ? '
' : ''; $spell_img = Horde::img('spellcheck.png'); + + if (IMP::getViewMode() == 'imp') { + $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) . '}' )); } diff --git a/imp/message-dimp.php b/imp/message-dimp.php index 61deaedbf..06c6b41ab 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -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');