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.

markasjunk.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Mark-as-Junk plugin script
  3. *
  4. * @licstart The following is the entire license notice for the
  5. * JavaScript code in this file.
  6. *
  7. * Copyright (c) 2013, The Roundcube Dev Team
  8. *
  9. * The JavaScript code in this page is free software: you can redistribute it
  10. * and/or modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation, either version 3 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * @licend The above is the entire license notice
  15. * for the JavaScript code in this file.
  16. */
  17. function rcmail_markasjunk(prop)
  18. {
  19. if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length))
  20. return;
  21. var uids = rcmail.env.uid ? rcmail.env.uid : rcmail.message_list.get_selection().join(','),
  22. lock = rcmail.set_busy(true, 'loading');
  23. rcmail.http_post('plugin.markasjunk', '_uid='+uids+'&_mbox='+urlencode(rcmail.env.mailbox), lock);
  24. }
  25. // callback for app-onload event
  26. if (window.rcmail) {
  27. rcmail.addEventListener('init', function(evt) {
  28. // register command (directly enable in message view mode)
  29. rcmail.register_command('plugin.markasjunk', rcmail_markasjunk, rcmail.env.uid);
  30. // add event-listener to message list
  31. if (rcmail.message_list)
  32. rcmail.message_list.addEventListener('select', function(list){
  33. rcmail.enable_command('plugin.markasjunk', list.get_selection().length > 0);
  34. });
  35. })
  36. }