diff options
author | Hugues Hiegel <root@paranoid> | 2015-04-21 12:49:44 +0200 |
---|---|---|
committer | Hugues Hiegel <root@paranoid> | 2015-04-21 12:49:44 +0200 |
commit | 733f8e8d0ce6217d906d06dc4fb08e36d48ed794 (patch) | |
tree | cff28366ff63ea6596f8026e1698090bd0b9405c /plugins/archive/archive.js | |
parent | ef2e7b3f9d264ec146d4dae257b1e295ab3b462a (diff) | |
parent | a4ba3df54834ee90fb2c9930669f1229dc80261a (diff) |
Conflicts:
composer.json-dist
config/defaults.inc.php
plugins
plugins/acl/acl.js
plugins/acl/acl.php
plugins/acl/skins/classic/templates/table.html
plugins/acl/skins/larry/templates/table.html
plugins/enigma/README
plugins/enigma/config.inc.php.dist
plugins/enigma/enigma.js
plugins/enigma/enigma.php
plugins/enigma/lib/enigma_driver.php
plugins/enigma/lib/enigma_driver_gnupg.php
plugins/enigma/lib/enigma_driver_phpssl.php
plugins/enigma/lib/enigma_engine.php
plugins/enigma/lib/enigma_error.php
plugins/enigma/lib/enigma_key.php
plugins/enigma/lib/enigma_signature.php
plugins/enigma/lib/enigma_subkey.php
plugins/enigma/lib/enigma_ui.php
plugins/enigma/lib/enigma_userid.php
plugins/enigma/localization/en_US.inc
plugins/enigma/localization/ja_JP.inc
plugins/enigma/localization/ru_RU.inc
plugins/enigma/skins/classic/enigma.css
plugins/enigma/skins/classic/templates/keys.html
plugins/help/config.inc.php.dist
plugins/help/help.php
plugins/help/localization/en_US.inc
plugins/jqueryui/jqueryui.php
plugins/managesieve/Changelog
plugins/managesieve/composer.json
plugins/managesieve/config.inc.php.dist
plugins/managesieve/lib/Roundcube/rcube_sieve.php
plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
plugins/managesieve/localization/en_US.inc
plugins/managesieve/managesieve.js
plugins/managesieve/skins/classic/managesieve.css
plugins/managesieve/skins/larry/managesieve.css
plugins/password/README
plugins/password/config.inc.php.dist
plugins/password/drivers/ldap.php
plugins/password/drivers/poppassd.php
plugins/password/drivers/vpopmaild.php
plugins/vcard_attachments/vcardattach.js
plugins/zipdownload/zipdownload.php
Diffstat (limited to 'plugins/archive/archive.js')
-rw-r--r-- | plugins/archive/archive.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js new file mode 100644 index 000000000..f77bedf46 --- /dev/null +++ b/plugins/archive/archive.js @@ -0,0 +1,69 @@ +/** + * Archive plugin script + * @version 2.3 + * + * @licstart The following is the entire license notice for the + * JavaScript code in this file. + * + * Copyright (c) 2012-2014, The Roundcube Dev Team + * + * The JavaScript code in this page is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * @licend The above is the entire license notice + * for the JavaScript code in this file. + */ + +function rcmail_archive(prop) +{ + if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length)) + return; + + if (!rcmail_is_archive()) { + if (!rcmail.env.archive_type) { + // simply move to archive folder (if no partition type is set) + rcmail.command('move', rcmail.env.archive_folder); + } + else { + // let the server sort the messages to the according subfolders + rcmail.http_post('plugin.move2archive', rcmail.selection_post_data()); + } + } +} + +function rcmail_is_archive() +{ + // check if current folder is an archive folder or one of its children + if (rcmail.env.mailbox == rcmail.env.archive_folder + || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter) + ) { + return true; + } +} + +// callback for app-onload event +if (window.rcmail) { + rcmail.addEventListener('init', function(evt) { + // register command (directly enable in message view mode) + rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive()); + + // add event-listener to message list + if (rcmail.message_list) + rcmail.message_list.addEventListener('select', function(list) { + rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive()); + }); + + // set css style for archive folder + var li; + if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true))) + $(li).addClass('archive'); + + // callback for server response + rcmail.addEventListener('plugin.move2archive_response', function(result) { + if (result.update) + rcmail.command('list'); // refresh list + }); + }) +} |