Hi all, Ive been porting some of our internal squirrelmail plugins to
RC, now that RC has a plugin API. Most were quite easy to port, but
one has me a bit stumped. Im probably overlooking something.
Im using the markasjunk plugin as a base, but im trying to modify it
to not only allow marking junk, but the
reverse as well. If you're in the junk folder it should move your mail
to the inbox, and preferably also have a slightly different button.
Deciding what folder to move things to is easy. Just check your
current folder and decide accordingly. But how can I change the button
based on what folder im in? Is this possible? Can I listen to an
event on folder change and change the button?
Any help is appreciated,
Regards
Cor
ps: this plugin hooks into our internal cloudmark based spamfilters to
enable learning of mistakes.
_______________________________________________
List info: http://lists.roundcube.net/dev/
Hi all,
Deciding what folder to move things to is easy. Just check your
current folder and decide accordingly. But how can I change the button
based on what folder im in? Is this possible? Can I listen to an
event on folder change and change the button?
I've come up with this, but I have a feeling there should be a better way. Im defining my own click event on each mailboxlist entry, and in that event I change the active button image. (I can have the inactive button be the same I suppose, its not a big deal).
The listener for the message_list does an enable_command, which uses the active button url to switch the buttons.
Is there a better way to achieve the same? ie have a spam reporting button be different when you're in the actual spam folder (it reports that the email there is not spam, and move it to your inbox)
if (window.rcmail) { rcmail.addEventListener('init', function(evt) {
// register command (directly enable in message view mode)
rcmail.register_command('plugin.spambutton', rcmail_spambutton, rcmail.env.uid);
// add event-listener to message list
if (rcmail.message_list)
rcmail.message_list.addEventListener('select', function(list){
rcmail.enable_command('plugin.spambutton', list.get_selection().length == 1);
});
$('#mailboxlist li a').bind('click', function(e) {
var a_buttons = rcmail.buttons['plugin.spambutton'];
if(!a_buttons || !a_buttons.length)
return false;
for(var n=0; n<a_buttons.length; n++)
{
button = a_buttons[n];
if(rcmail.env.mailbox == rcmail.env.junk_mailbox) {
button.act = "plugins/xs4all_spambutton/report_nospam_act.png";
}
else
{
button.act = "plugins/spambutton/report_spam_act.png";
}
}
});
}); } _______________________________________________ List info: http://lists.roundcube.net/dev/
Cor Bosman wrote:
Hi all,
Deciding what folder to move things to is easy. Just check your current folder and decide accordingly. But how can I change the button based on what folder im in? Is this possible? Can I listen to an event on folder change and change the button?
I've just committed a new event named 'listupdate' which is triggered after the message list is updated (ajax response). The handler gets a field named 'folder' in its event argument.
I haven't tested it yet but this should give you the right event for activating the spam button.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
Deciding what folder to move things to is easy. Just check your current folder and decide accordingly. But how can I change the button based on what folder im in? Is this possible? Can I listen to an event on folder change and change the button?
I've just committed a new event named 'listupdate' which is triggered after the message list is updated (ajax response). The handler gets a field named 'folder' in its event argument.
I haven't tested it yet but this should give you the right event for activating the spam button.
It looks like you also committed a 'selectfolder' event, which i think is more what I was looking for. Thanks!
Works as advertised,
Regards,
Cor _______________________________________________ List info: http://lists.roundcube.net/dev/