commit | author | age
|
538e64
|
1 |
/** |
48e9c1
|
2 |
* Archive plugin script |
7fce8f
|
3 |
* @version 2.3 |
b34d67
|
4 |
* |
TB |
5 |
* @licstart The following is the entire license notice for the |
|
6 |
* JavaScript code in this file. |
|
7 |
* |
|
8 |
* Copyright (c) 2012-2014, The Roundcube Dev Team |
|
9 |
* |
|
10 |
* The JavaScript code in this page is free software: you can redistribute it |
|
11 |
* and/or modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation, either version 3 of |
|
13 |
* the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* @licend The above is the entire license notice |
|
16 |
* for the JavaScript code in this file. |
48e9c1
|
17 |
*/ |
T |
18 |
|
|
19 |
function rcmail_archive(prop) |
|
20 |
{ |
|
21 |
if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length)) |
|
22 |
return; |
3e3f39
|
23 |
|
343363
|
24 |
if (!rcmail_is_archive()) { |
67cb01
|
25 |
if (!rcmail.env.archive_type) { |
TB |
26 |
// simply move to archive folder (if no partition type is set) |
3e3f39
|
27 |
rcmail.command('move', rcmail.env.archive_folder); |
67cb01
|
28 |
} |
TB |
29 |
else { |
|
30 |
// let the server sort the messages to the according subfolders |
691cbc
|
31 |
rcmail.http_post('plugin.move2archive', rcmail.selection_post_data()); |
67cb01
|
32 |
} |
TB |
33 |
} |
48e9c1
|
34 |
} |
T |
35 |
|
07f161
|
36 |
function rcmail_is_archive() |
AM |
37 |
{ |
|
38 |
// check if current folder is an archive folder or one of its children |
|
39 |
if (rcmail.env.mailbox == rcmail.env.archive_folder |
6a9144
|
40 |
|| rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter) |
07f161
|
41 |
) { |
AM |
42 |
return true; |
|
43 |
} |
|
44 |
} |
|
45 |
|
48e9c1
|
46 |
// callback for app-onload event |
T |
47 |
if (window.rcmail) { |
|
48 |
rcmail.addEventListener('init', function(evt) { |
|
49 |
// register command (directly enable in message view mode) |
343363
|
50 |
rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive()); |
3e3f39
|
51 |
|
48e9c1
|
52 |
// add event-listener to message list |
T |
53 |
if (rcmail.message_list) |
3e3f39
|
54 |
rcmail.message_list.addEventListener('select', function(list) { |
343363
|
55 |
rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive()); |
48e9c1
|
56 |
}); |
3e3f39
|
57 |
|
48e9c1
|
58 |
// set css style for archive folder |
T |
59 |
var li; |
|
60 |
if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true))) |
|
61 |
$(li).addClass('archive'); |
67cb01
|
62 |
|
TB |
63 |
// callback for server response |
|
64 |
rcmail.addEventListener('plugin.move2archive_response', function(result) { |
|
65 |
if (result.update) |
442f37
|
66 |
rcmail.command('list'); // refresh list |
67cb01
|
67 |
}); |
48e9c1
|
68 |
}) |
T |
69 |
} |