You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

archive.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. function rcmail_archive(prop)
  19. {
  20. if (rcmail_is_archive())
  21. return;
  22. var post_data = rcmail.selection_post_data();
  23. // exit if selection is empty
  24. if (!post_data._uid)
  25. return;
  26. rcmail.show_contentframe(false);
  27. // Disable message command buttons until a message is selected
  28. rcmail.enable_command(rcmail.env.message_commands, false);
  29. rcmail.enable_command('plugin.archive', false);
  30. // let the server sort the messages to the according subfolders
  31. rcmail.with_selected_messages('move', post_data, null, 'plugin.move2archive');
  32. }
  33. function rcmail_is_archive()
  34. {
  35. // check if current folder is an archive folder or one of its children
  36. return rcmail.env.mailbox == rcmail.env.archive_folder
  37. || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter);
  38. }
  39. // callback for app-onload event
  40. if (window.rcmail) {
  41. rcmail.addEventListener('init', function(evt) {
  42. // register command (directly enable in message view mode)
  43. rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive());
  44. // add event-listener to message list
  45. if (rcmail.message_list)
  46. rcmail.message_list.addEventListener('select', function(list) {
  47. rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive());
  48. });
  49. // set css style for archive folder
  50. var li;
  51. if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true)))
  52. $(li).addClass('archive');
  53. });
  54. }