From 4be86f3a3779ef86be30e8451750130569d2cacd Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 9 Mar 2012 13:23:24 +0000 Subject: - Unified (single) spellchecker button --- CHANGELOG | 1 + program/js/app.js | 76 ++++++++++++++++++++-------------- program/js/editor.js | 13 +++++- program/steps/mail/compose.inc | 5 ++- skins/default/common.css | 14 ++++++- skins/default/functions.js | 38 +++++++++++++++++ skins/default/images/messageicons.gif | Bin 1998 -> 2030 bytes skins/default/images/messageicons.png | Bin 4062 -> 4098 bytes skins/default/mail.css | 11 +++++ skins/default/templates/compose.html | 12 +++++- skins/larry/mail.css | 8 +--- skins/larry/styles.css | 10 ++++- skins/larry/templates/compose.html | 12 +++++- skins/larry/ui.js | 47 ++++++++++++++++++--- 14 files changed, 194 insertions(+), 53 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5a704d705..67dbff9b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Unified (single) spellchecker button - Fix encoding of attachment with comma in name (#1488389) - Scroll long lists on drag&drop (#1485946) - Fix handling of % character in IMAP protocol (#1488382) diff --git a/program/js/app.js b/program/js/app.js index d406844ae..755f10725 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -261,11 +261,9 @@ function rcube_webmail() $.merge(this.env.compose_commands, ['add-recipient', 'firstpage', 'previouspage', 'nextpage', 'lastpage']); if (this.env.spellcheck) { - this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); }; + this.env.spellcheck.spelling_state_observer = function(s) { ref.spellcheck_state(); }; this.env.compose_commands.push('spellcheck') - this.set_spellcheck_state('ready'); - if ($("input[name='_is_html']").val() == '1') - this.display_spellcheck_controls(false); + this.enable_command('spellcheck', true); } document.onmouseup = function(e){ return p.doc_mouse_up(e); }; @@ -898,13 +896,18 @@ function rcube_webmail() break; case 'spellcheck': - if (window.tinyMCE && tinyMCE.get(this.env.composebody)) { - tinyMCE.execCommand('mceSpellCheck', true); + if (this.spellcheck_state()) { + this.stop_spellchecking(); } - else if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) { - this.env.spellcheck.spellCheck(); - this.set_spellcheck_state('checking'); + else { + if (window.tinyMCE && tinyMCE.get(this.env.composebody)) { + tinyMCE.execCommand('mceSpellCheck', true); + } + else if (this.env.spellcheck && this.env.spellcheck.spellCheck) { + this.env.spellcheck.spellCheck(); + } } + this.spellcheck_state(); break; case 'savedraft': @@ -3116,8 +3119,9 @@ function rcube_webmail() this.toggle_editor = function(props) { + this.stop_spellchecking(); + if (props.mode == 'html') { - this.display_spellcheck_controls(false); this.plain2html($('#'+props.id).val(), props.id); tinyMCE.execCommand('mceAddControl', false, props.id); @@ -3128,8 +3132,6 @@ function rcube_webmail() } else { var thisMCE = tinyMCE.get(props.id), existingHtml; - if (thisMCE.plugins.spellchecker && thisMCE.plugins.spellchecker.active) - thisMCE.execCommand('mceSpellCheck', false); if (existingHtml = thisMCE.getContent()) { if (!confirm(this.get_label('editorwarning'))) { @@ -3138,7 +3140,6 @@ function rcube_webmail() this.html2plain(existingHtml, props.id); } tinyMCE.execCommand('mceRemoveControl', false, props.id); - this.display_spellcheck_controls(true); } return true; @@ -3147,43 +3148,52 @@ function rcube_webmail() this.stop_spellchecking = function() { var ed; + if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody))) { if (ed.plugins.spellchecker && ed.plugins.spellchecker.active) ed.execCommand('mceSpellCheck'); } - else if ((ed = this.env.spellcheck) && !this.spellcheck_ready) { - $(ed.spell_span).trigger('click'); - this.set_spellcheck_state('ready'); + else if (ed = this.env.spellcheck) { + if (ed.state && ed.state != 'ready' && ed.state != 'no_error_found') + $(ed.spell_span).trigger('click'); } + + this.spellcheck_state(); }; - this.display_spellcheck_controls = function(vis) + this.spellcheck_state = function() { - if (this.env.spellcheck) { - // stop spellchecking process - if (!vis) - this.stop_spellchecking(); + var ed, active; - $(this.env.spellcheck.spell_container)[vis ? 'show' : 'hide'](); - } - }; + if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody)) && ed.plugins.spellchecker) + active = ed.plugins.spellchecker.active; + else if ((ed = this.env.spellcheck) && ed.state) + active = ed.state != 'ready' && ed.state != 'no_error_found'; - this.set_spellcheck_state = function(s) - { - this.spellcheck_ready = (s == 'ready' || s == 'no_error_found'); - this.enable_command('spellcheck', this.spellcheck_ready); + $('#'+rcmail.buttons.spellcheck[0].id)[active ? 'addClass' : 'removeClass']('selected'); + + return active; }; // get selected language this.spellcheck_lang = function() { var ed; - if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody)) && ed.plugins.spellchecker) { + + if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody)) && ed.plugins.spellchecker) return ed.plugins.spellchecker.selectedLang; - } - else if (this.env.spellcheck) { + else if (this.env.spellcheck) return GOOGIE_CUR_LANG; - } + }; + + this.spellcheck_lang_set = function(lang) + { + var editor; + + if (window.tinyMCE && (editor = tinyMCE.get(this.env.composebody))) + editor.plugins.spellchecker.selectedLang = lang; + else if (this.env.spellcheck) + this.env.spellcheck.setCurrentLanguage(lang); }; // resume spellchecking, highlight provided mispellings without new ajax request @@ -3202,6 +3212,8 @@ function rcube_webmail() sp.prepare(false, true); sp.processData(data); } + + this.spellcheck_state(); } this.set_draft_id = function(id) diff --git a/program/js/editor.js b/program/js/editor.js index e95ead16e..ce3b38c0e 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -44,11 +44,11 @@ function rcmail_editor_init(config) theme_advanced_buttons1: 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor', theme_advanced_buttons2: ',fontselect,fontsizeselect' }); - else // mail compose + else { // mail compose $.extend(conf, { plugins: 'paste,emotions,media,nonbreaking,table,searchreplace,visualchars,directionality,tabfocus' + (config.spellcheck ? ',spellchecker' : ''), theme_advanced_buttons1: 'bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,fontselect,fontsizeselect', - theme_advanced_buttons2: 'link,unlink,table,|,emotions,charmap,image,media,|,code,search' + (config.spellcheck ? ',spellchecker' : '') + ',undo,redo', + theme_advanced_buttons2: 'link,unlink,table,|,emotions,charmap,image,media,|,code,search,undo,redo', spellchecker_languages: (rcmail.env.spellcheck_langs ? rcmail.env.spellcheck_langs : 'Dansk=da,Deutsch=de,+English=en,Espanol=es,Francais=fr,Italiano=it,Nederlands=nl,Polski=pl,Portugues=pt,Suomi=fi,Svenska=sv'), spellchecker_rpc_url: '?_task=utils&_action=spell_html', spellchecker_enable_learn_rpc: config.spelldict, @@ -56,6 +56,15 @@ function rcmail_editor_init(config) oninit: 'rcmail_editor_callback' }); + // add handler for spellcheck button state update + conf.setup = function(ed) { + ed.onSetProgressState.add(function(ed, active) { + if (!active) + rcmail.spellcheck_state(); + }); + } + } + // support external configuration settings e.g. from skin if (window.rcmail_editor_settings) $.extend(conf, window.rcmail_editor_settings); diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 8c3e61183..56abd2456 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -813,6 +813,9 @@ function rcmail_compose_body($attrib) if (!$spellcheck_langs[$lang]) $lang = 'en'; + $OUTPUT->set_env('spell_langs', $spellcheck_langs); + $OUTPUT->set_env('spell_lang', $lang); + $editor_lang_set = array(); foreach ($spellcheck_langs as $key => $name) { $editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key); @@ -830,7 +833,7 @@ function rcmail_compose_body($attrib) "googie.lang_learn_word = \"%s\";\n". "googie.setLanguages(%s);\n". "googie.setCurrentLanguage('%s');\n". - "googie.setSpellContainer('spellcheck-control');\n". + "googie.setDecoration(false);\n". "googie.decorateTextarea('%s');\n". "%s.set_env('spellcheck', googie);", $RCMAIL->output->get_skin_path(), diff --git a/skins/default/common.css b/skins/default/common.css index 31ecbe905..57fc1275a 100644 --- a/skins/default/common.css +++ b/skins/default/common.css @@ -495,6 +495,7 @@ body.iframe .boxtitle padding: 2px 10px; text-decoration: none; min-height: 14px; + background: transparent; } .popupmenu li a.active, @@ -504,7 +505,8 @@ body.iframe .boxtitle color: #333; } -.popupmenu li a.active:hover +.popupmenu li a.active:hover, +.popupmenu.selectable li a.selected:hover { color: #fff; background-color: #c00; @@ -515,6 +517,16 @@ body.iframe .boxtitle float: left; } +.popupmenu.selectable li a.selected +{ + background: url(images/messageicons.png) 2px -372px no-repeat; +} + +.popupmenu.selectable li a +{ + padding-left: 20px; +} + .darkbg { background-color: #F2F2F2 !important; diff --git a/skins/default/functions.js b/skins/default/functions.js index aab386b5e..fb7a05d4b 100644 --- a/skins/default/functions.js +++ b/skins/default/functions.js @@ -102,6 +102,7 @@ function rcube_mail_ui() groupmenu: {id:'groupoptionsmenu', above:1}, mailboxmenu: {id:'mailboxoptionsmenu', above:1}, composemenu: {id:'composeoptionsmenu', editable:1, overlap:1}, + spellmenu: {id:'spellmenu'}, // toggle: #1486823, #1486930 uploadmenu: {id:'attachment-form', editable:1, above:1, toggle:!bw.ie&&!bw.linux }, uploadform: {id:'upload-form', editable:1, toggle:!bw.ie&&!bw.linux } @@ -351,6 +352,43 @@ save_listmenu: function() rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0); }, +spellmenu: function(show) +{ + var link, li, + lang = rcmail.spellcheck_lang(), + menu = this.popups.spellmenu.obj, + ul = $('ul', menu); + + if (!ul.length) { + ul = $('