alecpl
2008-10-07 2727053c61cac4a37a76b9e58e607acff7fc8dfb
commit | author | age
a0109c 1 /*
S 2  +-----------------------------------------------------------------------+
3  | RoundCube editor js library                                           |
4  |                                                                       |
5  | This file is part of the RoundCube web development suite              |
6  | Copyright (C) 2006, RoundCube Dev, - Switzerland                      |
7  | Licensed under the GNU GPL                                            |
8  |                                                                       |
9  +-----------------------------------------------------------------------+
10  | Author: Eric Stadtherr <estadtherr@gmail.com>                         |
11  +-----------------------------------------------------------------------+
2c6337 12
a0109c 13  $Id: editor.js 000 2006-05-18 19:12:28Z roundcube $
S 14 */
15
16 // Initialize the message editor
17
4ca10b 18 function rcmail_editor_init(skin_path, editor_lang, spellcheck)
T 19 {
20   tinyMCE.init({ 
21     mode : "textareas",
22     editor_selector : "mce_editor",
23     accessibility_focus : false,
24     apply_source_formatting : true,
25     theme : "advanced",
26     language : editor_lang,
27     plugins : "emotions,media,nonbreaking,table,searchreplace,visualchars,directionality" + (spellcheck ? ",spellchecker" : ""),
28     theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,link,unlink,emotions,charmap,code,forecolor,backcolor,fontselect,fontsizeselect, separator" + (spellcheck ? ",spellchecker" : "") + ",undo,redo,image,media,ltr,rtl",
29     theme_advanced_buttons2 : "",
30     theme_advanced_buttons3 : "",
31     theme_advanced_toolbar_location : "top",
32     theme_advanced_toolbar_align : "left",
33     extended_valid_elements : "font[face|size|color|style],span[id|class|align|style]",
34     content_css : skin_path + "/editor_content.css",
35     external_image_list_url : "program/js/editor_images.js",
36     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"),
491a6e 37     gecko_spellcheck : true,
4ca10b 38     rc_client: rcube_webmail_client
T 39   });
40 }
a0109c 41
S 42 // Toggle between the HTML and Plain Text editors
43
44 function rcmail_toggle_editor(toggler)
2c6337 45   {
S 46   var selectedEditor = toggler.value;
a0109c 47
2c6337 48   // determine the currently displayed editor
S 49   var htmlFlag = document.getElementsByName('_is_html')[0];
66f12a 50   var isHtml = htmlFlag.value;
a0109c 51
66f12a 52   if (((selectedEditor == 'plain') && (isHtml == "0")) ||
S 53       ((selectedEditor == 'html') && (isHtml == "1")))
2c6337 54     {
S 55     return;
56     }
a0109c 57
2c6337 58   // do the appropriate conversion
S 59   if (selectedEditor == 'html')
60     {
f4b868 61     rcmail.display_spellcheck_controls(false);
3bd94b 62     var composeElement = document.getElementById('compose-body');
A 63     var htmlText = "<pre>" + composeElement.value + "</pre>";
2c6337 64     composeElement.value = htmlText;
d9344f 65     tinyMCE.execCommand('mceAddControl', true, 'compose-body');
2c6337 66     htmlFlag.value = "1";
S 67     }
68   else
69     {
d9344f 70     var thisMCE = tinyMCE.get('compose-body');
S 71     var existingHtml = thisMCE.getContent();
3bd94b 72     rcmail.html2plain(existingHtml, 'compose-body');
d9344f 73     tinyMCE.execCommand('mceRemoveControl', true, 'compose-body');
2c6337 74     htmlFlag.value = "0";
4ca10b 75     rcmail.display_spellcheck_controls(true);
2c6337 76     }
S 77   }