0
|
1 /**
|
|
2 * Archive plugin script
|
|
3 * @version 3.0
|
|
4 *
|
|
5 * @licstart The following is the entire license notice for the
|
|
6 * JavaScript code in this file.
|
|
7 *
|
|
8 * Copyright (c) 2012-2016, 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.
|
|
17 */
|
|
18
|
|
19 function rcmail_archive(prop)
|
|
20 {
|
|
21 if (rcmail_is_archive())
|
|
22 return;
|
|
23
|
|
24 var post_data = rcmail.selection_post_data();
|
|
25
|
|
26 // exit if selection is empty
|
|
27 if (!post_data._uid)
|
|
28 return;
|
|
29
|
|
30 rcmail.show_contentframe(false);
|
|
31
|
|
32 // Disable message command buttons until a message is selected
|
|
33 rcmail.enable_command(rcmail.env.message_commands, false);
|
|
34 rcmail.enable_command('plugin.archive', false);
|
|
35
|
|
36 // let the server sort the messages to the according subfolders
|
|
37 rcmail.with_selected_messages('move', post_data, null, 'plugin.move2archive');
|
|
38 }
|
|
39
|
|
40 function rcmail_is_archive()
|
|
41 {
|
|
42 // check if current folder is an archive folder or one of its children
|
|
43 return rcmail.env.mailbox == rcmail.env.archive_folder
|
|
44 || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter);
|
|
45 }
|
|
46
|
|
47 // callback for app-onload event
|
|
48 if (window.rcmail) {
|
|
49 rcmail.addEventListener('init', function(evt) {
|
|
50 // register command (directly enable in message view mode)
|
|
51 rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive());
|
|
52
|
|
53 // add event-listener to message list
|
|
54 if (rcmail.message_list)
|
|
55 rcmail.message_list.addEventListener('select', function(list) {
|
|
56 rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive());
|
|
57 });
|
|
58
|
|
59 // set css style for archive folder
|
|
60 var li;
|
|
61 if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true)))
|
|
62 $(li).addClass('archive');
|
|
63 });
|
|
64 }
|