commit | author | age
|
5f660c
|
1 |
/** |
A |
2 |
* RoundCube functions for default skin interface |
|
3 |
*/ |
|
4 |
|
|
5 |
/** |
|
6 |
* Settings |
|
7 |
*/ |
|
8 |
|
|
9 |
function rcube_init_settings_tabs() |
|
10 |
{ |
cc97ea
|
11 |
var tab = '#settingstabdefault'; |
5f660c
|
12 |
if (window.rcmail && rcmail.env.action) |
cc97ea
|
13 |
tab = '#settingstab' + (rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action.replace(/\./g, ''))); |
T |
14 |
|
|
15 |
$(tab).addClass('tablink-selected'); |
a4865a
|
16 |
$(tab + '> a').removeAttr('onclick').unbind('click').bind('click', function(){return false;}); |
5f660c
|
17 |
} |
A |
18 |
|
|
19 |
function rcube_show_advanced(visible) |
|
20 |
{ |
cc97ea
|
21 |
$('tr.advanced').css('display', (visible ? (bw.ie ? 'block' : 'table-row') : 'none')); |
5f660c
|
22 |
} |
A |
23 |
|
|
24 |
/** |
|
25 |
* Mail Composing |
|
26 |
*/ |
|
27 |
|
4fb1e8
|
28 |
function rcmail_show_header_form(id) |
5f660c
|
29 |
{ |
a80405
|
30 |
var row, s, |
A |
31 |
link = document.getElementById(id + '-link'); |
5f660c
|
32 |
|
a80405
|
33 |
if ((s = rcmail_next_sibling(link))) |
A |
34 |
s.style.display = 'none'; |
|
35 |
else if ((s = rcmail_prev_sibling(link))) |
|
36 |
s.style.display = 'none'; |
5f660c
|
37 |
|
4fb1e8
|
38 |
link.style.display = 'none'; |
5f660c
|
39 |
|
a80405
|
40 |
if ((row = document.getElementById('compose-' + id))) { |
A |
41 |
var div = document.getElementById('compose-div'), |
|
42 |
headers_div = document.getElementById('compose-headers-div'); |
5f660c
|
43 |
row.style.display = (document.all && !window.opera) ? 'block' : 'table-row'; |
a4865a
|
44 |
div.style.top = parseInt(headers_div.offsetHeight, 10) + 'px'; |
a80405
|
45 |
} |
4fb1e8
|
46 |
|
A |
47 |
return false; |
|
48 |
} |
|
49 |
|
|
50 |
function rcmail_hide_header_form(id) |
|
51 |
{ |
a80405
|
52 |
var row, ns, |
A |
53 |
link = document.getElementById(id + '-link'), |
|
54 |
parent = link.parentNode, |
|
55 |
links = parent.getElementsByTagName('a'); |
4fb1e8
|
56 |
|
A |
57 |
link.style.display = ''; |
|
58 |
|
|
59 |
for (var i=0; i<links.length; i++) |
|
60 |
if (links[i].style.display != 'none') |
|
61 |
for (var j=i+1; j<links.length; j++) |
a80405
|
62 |
if (links[j].style.display != 'none') |
4fb1e8
|
63 |
if ((ns = rcmail_next_sibling(links[i]))) { |
a80405
|
64 |
ns.style.display = ''; |
A |
65 |
break; |
|
66 |
} |
4fb1e8
|
67 |
|
A |
68 |
document.getElementById('_' + id).value = ''; |
|
69 |
|
a80405
|
70 |
if ((row = document.getElementById('compose-' + id))) { |
A |
71 |
var div = document.getElementById('compose-div'), |
|
72 |
headers_div = document.getElementById('compose-headers-div'); |
4fb1e8
|
73 |
row.style.display = 'none'; |
a4865a
|
74 |
div.style.top = parseInt(headers_div.offsetHeight, 10) + 'px'; |
a80405
|
75 |
} |
5f660c
|
76 |
|
A |
77 |
return false; |
|
78 |
} |
|
79 |
|
|
80 |
function rcmail_next_sibling(elm) |
|
81 |
{ |
|
82 |
var ns = elm.nextSibling; |
|
83 |
while (ns && ns.nodeType == 3) |
|
84 |
ns = ns.nextSibling; |
|
85 |
return ns; |
|
86 |
} |
|
87 |
|
|
88 |
function rcmail_prev_sibling(elm) |
|
89 |
{ |
|
90 |
var ps = elm.previousSibling; |
|
91 |
while (ps && ps.nodeType == 3) |
|
92 |
ps = ps.previousSibling; |
|
93 |
return ps; |
|
94 |
} |
|
95 |
|
|
96 |
function rcmail_init_compose_form() |
|
97 |
{ |
a80405
|
98 |
var cc_field = document.getElementById('_cc'), |
A |
99 |
bcc_field = document.getElementById('_bcc'), |
|
100 |
div = document.getElementById('compose-div'), |
|
101 |
headers_div = document.getElementById('compose-headers-div'); |
|
102 |
|
|
103 |
if (cc_field && cc_field.value != '') |
4fb1e8
|
104 |
rcmail_show_header_form('cc'); |
A |
105 |
|
a80405
|
106 |
if (bcc_field && bcc_field.value != '') |
4fb1e8
|
107 |
rcmail_show_header_form('bcc'); |
59ed6f
|
108 |
|
A |
109 |
// prevent from form data loss when pressing ESC key in IE |
|
110 |
if (bw.ie) { |
|
111 |
var form = rcube_find_object('form'); |
a80405
|
112 |
form.onkeydown = function (e) { |
A |
113 |
if (rcube_event.get_keycode(e) == 27) |
|
114 |
rcube_event.cancel(e); |
|
115 |
}; |
59ed6f
|
116 |
} |
39f9d3
|
117 |
|
A |
118 |
// fix editor position on some browsers |
|
119 |
div.style.top = parseInt(headers_div.offsetHeight, 10) + 'px'; |
5f660c
|
120 |
} |
A |
121 |
|
|
122 |
/** |
|
123 |
* Mailbox view |
|
124 |
*/ |
|
125 |
|
|
126 |
function rcube_mail_ui() |
|
127 |
{ |
a61bbb
|
128 |
this.popupmenus = { |
T |
129 |
markmenu:'markmessagemenu', |
|
130 |
searchmenu:'searchmenu', |
|
131 |
messagemenu:'messagemenu', |
|
132 |
listmenu:'listmenu', |
|
133 |
dragmessagemenu:'dragmessagemenu', |
|
134 |
groupmenu:'groupoptionsmenu' |
|
135 |
}; |
|
136 |
|
|
137 |
var obj; |
|
138 |
for (var k in this.popupmenus) { |
|
139 |
obj = $('#'+this.popupmenus[k]) |
|
140 |
if (obj.length) |
|
141 |
this[k] = obj; |
|
142 |
} |
5f660c
|
143 |
} |
A |
144 |
|
|
145 |
rcube_mail_ui.prototype = { |
|
146 |
|
a61bbb
|
147 |
show_popupmenu: function(obj, refname, show, above) |
5f660c
|
148 |
{ |
A |
149 |
if (typeof show == 'undefined') |
a61bbb
|
150 |
show = obj.is(':visible') ? false : true; |
6c9d49
|
151 |
|
a61bbb
|
152 |
var ref = rcube_find_object(refname); |
T |
153 |
if (show && ref) { |
|
154 |
var pos = $(ref).offset(); |
|
155 |
obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) }); |
|
156 |
} |
5f660c
|
157 |
|
a61bbb
|
158 |
obj[show?'show':'hide'](); |
T |
159 |
}, |
|
160 |
|
|
161 |
show_markmenu: function(show) |
|
162 |
{ |
|
163 |
this.show_popupmenu(this.markmenu, 'markreadbutton', show); |
511420
|
164 |
}, |
A |
165 |
|
|
166 |
show_messagemenu: function(show) |
|
167 |
{ |
a61bbb
|
168 |
this.show_popupmenu(this.messagemenu, 'messagemenulink', show); |
T |
169 |
}, |
511420
|
170 |
|
a61bbb
|
171 |
show_groupmenu: function(show) |
T |
172 |
{ |
|
173 |
this.show_popupmenu(this.groupmenu, 'groupactionslink', show, true); |
5f660c
|
174 |
}, |
A |
175 |
|
30b152
|
176 |
show_searchmenu: function(show) |
A |
177 |
{ |
|
178 |
if (typeof show == 'undefined') |
|
179 |
show = this.searchmenu.is(':visible') ? false : true; |
|
180 |
|
|
181 |
var ref = rcube_find_object('searchmod'); |
|
182 |
if (show && ref) { |
|
183 |
var pos = $(ref).offset(); |
|
184 |
this.searchmenu.css({ left:pos.left, top:(pos.top + ref.offsetHeight + 2)}); |
7910c0
|
185 |
this.searchmenu.find(":checked").attr('checked', false); |
30b152
|
186 |
|
A |
187 |
if (rcmail.env.search_mods) { |
7910c0
|
188 |
var search_mods = rcmail.env.search_mods[rcmail.env.mailbox] ? rcmail.env.search_mods[rcmail.env.mailbox] : rcmail.env.search_mods['*']; |
T |
189 |
for (var n in search_mods) |
|
190 |
$('#s_mod_' + n).attr('checked', true); |
30b152
|
191 |
} |
A |
192 |
} |
|
193 |
this.searchmenu[show?'show':'hide'](); |
|
194 |
}, |
|
195 |
|
|
196 |
set_searchmod: function(elem) |
|
197 |
{ |
|
198 |
if (!rcmail.env.search_mods) |
a4865a
|
199 |
rcmail.env.search_mods = {}; |
30b152
|
200 |
|
7910c0
|
201 |
if (!rcmail.env.search_mods[rcmail.env.mailbox]) |
T |
202 |
rcmail.env.search_mods[rcmail.env.mailbox] = rcube_clone_object(rcmail.env.search_mods['*']); |
|
203 |
|
30b152
|
204 |
if (!elem.checked) |
7910c0
|
205 |
delete(rcmail.env.search_mods[rcmail.env.mailbox][elem.value]); |
30b152
|
206 |
else |
7910c0
|
207 |
rcmail.env.search_mods[rcmail.env.mailbox][elem.value] = elem.value; |
30b152
|
208 |
}, |
A |
209 |
|
f52c93
|
210 |
show_listmenu: function(show) |
T |
211 |
{ |
|
212 |
if (typeof show == 'undefined') |
|
213 |
show = this.listmenu.is(':visible') ? false : true; |
|
214 |
|
|
215 |
var ref = rcube_find_object('listmenulink'); |
|
216 |
if (show && ref) { |
6c9d49
|
217 |
var pos = $(ref).offset(), |
A |
218 |
menuwidth = this.listmenu.width(), |
|
219 |
pagewidth = $(document).width(); |
|
220 |
|
|
221 |
if (pagewidth - pos.left < menuwidth && pos.left > menuwidth) |
|
222 |
pos.left = pos.left - menuwidth; |
|
223 |
|
f52c93
|
224 |
this.listmenu.css({ left:pos.left, top:(pos.top + ref.offsetHeight + 2)}); |
T |
225 |
// set form values |
|
226 |
$('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').attr('checked', 1); |
|
227 |
$('input[name="sort_ord"][value="DESC"]').attr('checked', rcmail.env.sort_order=='DESC' ? 1 : 0); |
|
228 |
$('input[name="sort_ord"][value="ASC"]').attr('checked', rcmail.env.sort_order=='DESC' ? 0 : 1); |
|
229 |
$('input[name="view"][value="thread"]').attr('checked', rcmail.env.threading ? 1 : 0); |
|
230 |
$('input[name="view"][value="list"]').attr('checked', rcmail.env.threading ? 0 : 1); |
|
231 |
// list columns |
|
232 |
var cols = $('input[name="list_col[]"]'); |
|
233 |
for (var i=0; i<cols.length; i++) { |
|
234 |
var found = 0; |
|
235 |
if (cols[i].value != 'from') |
|
236 |
found = jQuery.inArray(cols[i].value, rcmail.env.coltypes) != -1; |
|
237 |
else |
|
238 |
found = (jQuery.inArray('from', rcmail.env.coltypes) != -1 |
|
239 |
|| jQuery.inArray('to', rcmail.env.coltypes) != -1); |
|
240 |
$(cols[i]).attr('checked',found ? 1 : 0); |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
this.listmenu[show?'show':'hide'](); |
|
245 |
|
|
246 |
if (show) { |
|
247 |
var maxheight=0; |
|
248 |
$('#listmenu fieldset').each(function() { |
|
249 |
var height = $(this).height(); |
|
250 |
if (height > maxheight) { |
|
251 |
maxheight = height; |
|
252 |
} |
|
253 |
}); |
|
254 |
$('#listmenu fieldset').css("min-height", maxheight+"px") |
|
255 |
// IE6 complains if you set this attribute using either method: |
|
256 |
//$('#listmenu fieldset').css({'height':'auto !important'}); |
|
257 |
//$('#listmenu fieldset').css("height","auto !important"); |
|
258 |
.height(maxheight); |
|
259 |
}; |
|
260 |
}, |
|
261 |
|
|
262 |
open_listmenu: function(e) |
|
263 |
{ |
|
264 |
this.show_listmenu(); |
|
265 |
}, |
|
266 |
|
|
267 |
save_listmenu: function() |
|
268 |
{ |
|
269 |
this.show_listmenu(); |
|
270 |
|
a80405
|
271 |
var sort = $('input[name="sort_col"]:checked').val(), |
A |
272 |
ord = $('input[name="sort_ord"]:checked').val(), |
|
273 |
thread = $('input[name="view"]:checked').val(), |
|
274 |
cols = $('input[name="list_col[]"]:checked') |
|
275 |
.map(function(){ return this.value; }).get(); |
f52c93
|
276 |
|
T |
277 |
rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0); |
|
278 |
}, |
|
279 |
|
5f660c
|
280 |
body_mouseup: function(evt, p) |
A |
281 |
{ |
f52c93
|
282 |
var target = rcube_event.get_target(evt); |
T |
283 |
|
|
284 |
if (this.markmenu && this.markmenu.is(':visible') && target != rcube_find_object('markreadbutton')) |
5f660c
|
285 |
this.show_markmenu(false); |
f52c93
|
286 |
else if (this.messagemenu && this.messagemenu.is(':visible') && target != rcube_find_object('messagemenulink')) |
511420
|
287 |
this.show_messagemenu(false); |
9b3fdc
|
288 |
else if (this.dragmessagemenu && this.dragmessagemenu.is(':visible') && !rcube_mouse_is_over(evt, rcube_find_object('dragmessagemenu'))) |
A |
289 |
this.dragmessagemenu.hide(); |
a61bbb
|
290 |
else if (this.groupmenu && this.groupmenu.is(':visible') && target != rcube_find_object('groupactionslink')) |
T |
291 |
this.show_groupmenu(false); |
f52c93
|
292 |
else if (this.listmenu && this.listmenu.is(':visible') && target != rcube_find_object('listmenulink')) { |
T |
293 |
var menu = rcube_find_object('listmenu'); |
|
294 |
while (target.parentNode) { |
|
295 |
if (target.parentNode == menu) |
|
296 |
return; |
|
297 |
target = target.parentNode; |
|
298 |
} |
|
299 |
this.show_listmenu(false); |
|
300 |
} |
|
301 |
else if (this.searchmenu && this.searchmenu.is(':visible') && target != rcube_find_object('searchmod')) { |
30b152
|
302 |
var menu = rcube_find_object('searchmenu'); |
A |
303 |
while (target.parentNode) { |
|
304 |
if (target.parentNode == menu) |
|
305 |
return; |
|
306 |
target = target.parentNode; |
|
307 |
} |
|
308 |
this.show_searchmenu(false); |
|
309 |
} |
5f660c
|
310 |
}, |
A |
311 |
|
|
312 |
body_keypress: function(evt, p) |
|
313 |
{ |
30b152
|
314 |
if (rcube_event.get_keycode(evt) == 27) { |
a61bbb
|
315 |
for (var k in this.popupmenus) { |
T |
316 |
if (this[k] && this[k].is(':visible')) |
|
317 |
this[k].hide(); |
|
318 |
} |
30b152
|
319 |
} |
5f660c
|
320 |
} |
A |
321 |
|
|
322 |
}; |
|
323 |
|
59ed6f
|
324 |
var rcmail_ui; |
5f660c
|
325 |
|
A |
326 |
function rcube_init_mail_ui() |
|
327 |
{ |
|
328 |
rcmail_ui = new rcube_mail_ui(); |
|
329 |
rcube_event.add_listener({ object:rcmail_ui, method:'body_mouseup', event:'mouseup' }); |
|
330 |
rcube_event.add_listener({ object:rcmail_ui, method:'body_keypress', event:'keypress' }); |
a61bbb
|
331 |
if (rcmail.env.task == 'mail') { |
T |
332 |
rcmail.addEventListener('menu-open', 'open_listmenu', rcmail_ui); |
|
333 |
rcmail.addEventListener('menu-save', 'save_listmenu', rcmail_ui); |
|
334 |
rcmail.gui_object('message_dragmenu', 'dragmessagemenu'); |
|
335 |
} |
5f660c
|
336 |
} |