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/

Reply via email to