commit | author | age
|
a0109c
|
1 |
/* |
S |
2 |
+-----------------------------------------------------------------------+ |
e019f2
|
3 |
| Roundcube editor js library | |
a0109c
|
4 |
| | |
e019f2
|
5 |
| This file is part of the Roundcube web development suite | |
e224b0
|
6 |
| Copyright (C) 2006, The Roundcube Dev Team | |
a0109c
|
7 |
| Licensed under the GNU GPL | |
S |
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 |
|
b8ae50
|
16 |
// Initialize HTML editor |
A |
17 |
function rcmail_editor_init(skin_path, editor_lang, spellcheck, mode) |
4ca10b
|
18 |
{ |
2d889e
|
19 |
var ret, conf = { |
e0a5ce
|
20 |
mode: 'textareas', |
A |
21 |
editor_selector: 'mce_editor', |
|
22 |
apply_source_formatting: true, |
|
23 |
theme: 'advanced', |
|
24 |
language: editor_lang, |
|
25 |
content_css: skin_path + '/editor_content.css', |
|
26 |
theme_advanced_toolbar_location: 'top', |
|
27 |
theme_advanced_toolbar_align: 'left', |
|
28 |
theme_advanced_buttons3: '', |
2d889e
|
29 |
extended_valid_elements: 'font[face|size|color|style],span[id|class|align|style]', |
e0a5ce
|
30 |
relative_urls: false, |
A |
31 |
remove_script_host: false, |
2d889e
|
32 |
gecko_spellcheck: true, |
A |
33 |
convert_urls: false, // #1486944 |
|
34 |
external_image_list_url: 'program/js/editor_images.js', |
|
35 |
rc_client: rcmail |
|
36 |
}; |
|
37 |
|
|
38 |
if (mode == 'identity') |
|
39 |
$.extend(conf, { |
|
40 |
plugins: 'paste,tabfocus', |
|
41 |
theme_advanced_buttons1: 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor', |
90550b
|
42 |
theme_advanced_buttons2: ',fontselect,fontsizeselect' |
b8ae50
|
43 |
}); |
A |
44 |
else // mail compose |
2d889e
|
45 |
$.extend(conf, { |
630f0e
|
46 |
plugins: 'paste,emotions,media,nonbreaking,table,searchreplace,visualchars,directionality,tabfocus' + (spellcheck ? ',spellchecker' : ''), |
e0a5ce
|
47 |
theme_advanced_buttons1: 'bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,fontselect,fontsizeselect', |
630f0e
|
48 |
theme_advanced_buttons2: 'link,unlink,table,|,emotions,charmap,image,media,|,code,search' + (spellcheck ? ',spellchecker' : '') + ',undo,redo', |
e0a5ce
|
49 |
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'), |
b4edf7
|
50 |
spellchecker_rpc_url: '?_task=utils&_action=spell_html', |
2d889e
|
51 |
accessibility_focus: false, |
e0a5ce
|
52 |
oninit: 'rcmail_editor_callback' |
b8ae50
|
53 |
}); |
2d889e
|
54 |
|
A |
55 |
// support external configuration settings e.g. from skin |
|
56 |
if (window.rcmail_editor_settings) |
|
57 |
$.extend(conf, window.rcmail_editor_settings); |
|
58 |
|
|
59 |
tinyMCE.init(conf); |
4ca10b
|
60 |
} |
b8ae50
|
61 |
|
A |
62 |
// react to real individual tinyMCE editor init |
b2f3e6
|
63 |
function rcmail_editor_callback() |
b8ae50
|
64 |
{ |
c288f9
|
65 |
var elem = rcube_find_object('_from'), |
A |
66 |
fe = rcmail.env.compose_focus_elem; |
|
67 |
|
|
68 |
if (elem && elem.type == 'select-one') { |
1f019c
|
69 |
rcmail.change_identity(elem); |
882b0f
|
70 |
// Focus previously focused element |
43fb35
|
71 |
if (fe && fe.id != rcmail.env.composebody) { |
A |
72 |
window.focus(); // for WebKit (#1486674) |
c288f9
|
73 |
fe.focus(); |
43fb35
|
74 |
} |
882b0f
|
75 |
} |
c288f9
|
76 |
|
5cff85
|
77 |
// set tabIndex and set focus to element that was focused before |
c288f9
|
78 |
rcmail_editor_tabindex(fe && fe.id == rcmail.env.composebody); |
eb9eff
|
79 |
// Trigger resize (needed for proper editor resizing in some browsers using default skin) |
A |
80 |
$(window).resize(); |
665cc5
|
81 |
} |
A |
82 |
|
|
83 |
// set tabIndex on tinyMCE editor |
5cff85
|
84 |
function rcmail_editor_tabindex(focus) |
665cc5
|
85 |
{ |
A |
86 |
if (rcmail.env.task == 'mail') { |
a01b3b
|
87 |
var editor = tinyMCE.get(rcmail.env.composebody); |
4cdc70
|
88 |
if (editor) { |
A |
89 |
var textarea = editor.getElement(); |
|
90 |
var node = editor.getContentAreaContainer().childNodes[0]; |
|
91 |
if (textarea && node) |
|
92 |
node.tabIndex = textarea.tabIndex; |
5cff85
|
93 |
if (focus) |
T |
94 |
editor.getWin().focus(); |
4cdc70
|
95 |
} |
665cc5
|
96 |
} |
b8ae50
|
97 |
} |
A |
98 |
|
|
99 |
// switch html/plain mode |
5821ff
|
100 |
function rcmail_toggle_editor(select, textAreaId, flagElement) |
b8ae50
|
101 |
{ |
5821ff
|
102 |
var flag, ishtml; |
A |
103 |
|
|
104 |
if (select.tagName != 'SELECT') |
|
105 |
ishtml = select.checked; |
|
106 |
else |
|
107 |
ishtml = select.value == 'html'; |
b8ae50
|
108 |
|
3940ba
|
109 |
var res = rcmail.command('toggle-editor', {id:textAreaId, mode:ishtml?'html':'plain'}); |
832594
|
110 |
|
3940ba
|
111 |
if (ishtml) { |
4cdc70
|
112 |
// #1486593 |
5cff85
|
113 |
setTimeout("rcmail_editor_tabindex(true);", 500); |
b8ae50
|
114 |
if (flagElement && (flag = rcube_find_object(flagElement))) |
A |
115 |
flag.value = '1'; |
087c7d
|
116 |
} |
A |
117 |
else { |
3940ba
|
118 |
if (!res && select.tagName == 'SELECT') |
5cff85
|
119 |
select.value = 'html'; |
b8ae50
|
120 |
if (flagElement && (flag = rcube_find_object(flagElement))) |
A |
121 |
flag.value = '0'; |
5cff85
|
122 |
|
bdf6de
|
123 |
if (rcmail.env.composebody) |
A |
124 |
rcube_find_object(rcmail.env.composebody).focus(); |
087c7d
|
125 |
} |
A |
126 |
} |