Results 1 to 4 of 4

Thread: zimlet listeners

  1. #1
    psalm121 is offline Junior Member
    Join Date
    Oct 2006
    Posts
    9
    Rep Power
    8

    Default zimlet listeners

    Hi,

    I'm looking to generate a popup window to interact with a custom zimlet I've written when a user opens a message in Zimbra.

    I can code the window just fine but need to know how to trigger it.

    I'm guessing I need to setup some kind of event listener, I was wondering if anyone could point me in the direction of a working example or maybe just share some simple code.

    Many thanks,
    Geoff

  2. #2
    JoshuaPrismon is offline Zimlet Guru & Moderator
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    Quote Originally Posted by psalm121 View Post
    Hi,

    I'm looking to generate a popup window to interact with a custom zimlet I've written when a user opens a message in Zimbra.

    I can code the window just fine but need to know how to trigger it.

    I'm guessing I need to setup some kind of event listener, I was wondering if anyone could point me in the direction of a working example or maybe just share some simple code.

    Many thanks,
    Geoff
    Take a look at the view code for the mail viewers. In particular look in ZmMailMsgView.js:
    // notify zimlets that a new message has been opened
    if (this._appCtxt.zimletsPresent()) {
    this._appCtxt.getZimletMgr().notifyZimlets("onMsgV iew", msg, oldMsg);
    }
    Or in ZmComposeView.js:
    /**
    * Called automatically by the attached ZmMailMsg object when data is
    * changed, in order to support Zimlets modify subject or other values
    * (bug: 10540)
    */
    ZmComposeView.prototype._onMsgDataChange =
    function(what, val) {
    switch (what) {
    case "subject":
    this._subjectField.value = val;
    break;
    }
    };
    Unfortunitly this code only handles the subject field. It would be nice to extend this just a little bit further to support message body, to/cc/bcc, and the other headers.

  3. #3
    JoshuaPrismon is offline Zimlet Guru & Moderator
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    Quote Originally Posted by JoshuaPrismon View Post
    Take a look at the view code for the mail viewers. In particular look in ZmMailMsgView.js:


    Or in ZmComposeView.js:

    Unfortunitly this code only handles the subject field. It would be nice to extend this just a little bit further to support message body, to/cc/bcc, and the other headers.
    Here is the code that actually handles the notification:

    ZmZimletMgr.prototype.notifyZimlets = function(event) {
    var args = new Array(arguments.length - 1);
    for (var i = 0; i < args.length
    args[i] = arguments[++i];
    var a = this._ZIMLETS;
    for (var i = 0; i < a.length; ++i) {
    var z = a[i].handlerObject;
    if (z
    && z instanceof ZmZimletBase // we might get here even if Zimlets were not initialized
    && z.getEnabled() // avoid calling any hooks on disabled Zimlets
    && typeof z[event] == "function")
    z[event].apply(z, args);
    }
    };
    I believe that means you can do something like this:

    Org_Technicaldetails_Zimlety["onMsgView"] = function(field1, field2, field3)
    {
    //do stuff.

    }
    Note that it's not just mail that does this, a lot of the other code uses this exact same message system.

  4. #4
    psalm121 is offline Junior Member
    Join Date
    Oct 2006
    Posts
    9
    Rep Power
    8

    Default thank you!

    Thank you so much for your reply I wouldn't have known where to start:

    The following code seems to work great:

    Org_Technicaldetails_Zimlety.prototype.onMsgView = function()
    {
    //do stuff.

    }

    Cheers again!
    Geoff


LinkBacks (?)

  1. 07-24-2007, 11:32 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  2. Replies: 5
    Last Post: 01-11-2008, 05:34 AM
  3. Replies: 13
    Last Post: 07-20-2007, 03:21 AM
  4. Domain Admin Error: Permission Denied
    By shanson in forum Administrators
    Replies: 3
    Last Post: 05-29-2007, 05:48 AM
  5. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •