Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

archive.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Archive plugin script
  3. * @version 2.4
  4. *
  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.
  17. */
  18. function rcmail_archive(prop)
  19. {
  20. if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length))
  21. return;
  22. if (!rcmail_is_archive()) {
  23. if (!rcmail.env.archive_type) {
  24. // simply move to archive folder (if no partition type is set)
  25. rcmail.command('move', rcmail.env.archive_folder);
  26. }
  27. else {
  28. // let the server sort the messages to the according subfolders
  29. rcmail.http_post('plugin.move2archive', rcmail.selection_post_data());
  30. }
  31. }
  32. }
  33. function rcmail_is_archive()
  34. {
  35. // check if current folder is an archive folder or one of its children
  36. if (rcmail.env.mailbox == rcmail.env.archive_folder
  37. || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter)
  38. ) {
  39. return true;
  40. }
  41. }
  42. // callback for app-onload event
  43. if (window.rcmail) {
  44. rcmail.addEventListener('init', function(evt) {
  45. // register command (directly enable in message view mode)
  46. rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive());
  47. // add event-listener to message list
  48. if (rcmail.message_list)
  49. rcmail.message_list.addEventListener('select', function(list) {
  50. rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive());
  51. });
  52. // set css style for archive folder
  53. var li;
  54. if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true)))
  55. $(li).addClass('archive');
  56. // callback for server response
  57. rcmail.addEventListener('plugin.move2archive_response', function(result) {
  58. if (result.update)
  59. rcmail.command('list'); // refresh list
  60. });
  61. })
  62. }