Results 1 to 7 of 7

Thread: Accessing Zimbra Javascript objects

  1. #1
    Join Date
    Mar 2006
    Posts
    21
    Rep Power
    9

    Default Accessing Zimbra Javascript objects

    So after filtering through a good number of js files I believe I can make my modifications to the UI through javascript calls which will be initiated via my zimlet js file. However, after a few tests I'm not 100% on the global names of these objects in runtime. Hopefully you'll be able to save me some time by helping me find the right ones.

    First, what's the best way to get a hold of the ZmMailApp? I'm guessing that through it I'd call the getComposeController function. I did do a few calls to ZmMailApp itself as well as ZmComposeController but I'm gathering those are more the static 'classes' than the live instance.

    I'll have more questions, undoubtedly, once I resolve this interaction. Thanks!

    Cheers,
    Marty

  2. #2
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    Assuming you have the appCtxt it's just:

    var cc = appCtxt.getApp(ZmZimbraMail.MAIL_APP).getComposeCo ntroller();


    If not you can get the appCtxt from the global window object:

    var appCtxt = ZmAppCtxt.getFromShell(DwtShell.getShell(window));
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  3. #3
    Join Date
    Mar 2006
    Posts
    21
    Rep Power
    9

    Default

    Thanks Kevin,

    That worked (sort of). Okay, I first tried putting the toolbar modifying code into the single click event of my zimlet. That worked. Of course, this was not the intended place since I want it to be installed when my zimlet is initialized. So I then moved it to the init function of my zimlet's js code and it didn't work. I'll post the code below, in case it matters. My guess is that either the init code is not running or that it's happening before the existing toolbar has been created.
    Com_Rs_Compose.prototype.init =
    function() {
    // Pre-load placeholder image
    (new Image()).src = this.getResource('blank_pixel.gif');

    var appCtxt = ZmAppCtxt.getFromShell(DwtShell.getShell(window));
    var composerCtrl = appCtxt.getApp(ZmZimbraMail.MAIL_APP).getComposeCo ntroller();
    var toolbar = composerCtrl._toolbar;
    var buttons = toolbar._buttons;

    // Add button to toolbar with Video string and send icons
    var buttonId = ZmOperation.ZIMLET + 1;
    ZmOperation.MSG_KEY[buttonId] = "video";
    ZmOperation.MSG_KEY_TT[buttonId] = "video";
    ZmOperation.IMAGE[buttonId] = "Send";
    ZmOperation.DIS_IMAGE[buttonId] = "SendDis";
    ZmOperation.addOperation(toolbar, buttonId, buttons);

    toolbar.addSelectionListener(buttonId, new AjxListener(composerCtrl, this._videoListener));

    };
    Cheers,
    Marty

  4. #4
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    Yep I bet it's a race condition with zimlets loading and the composer getting loaded. You may be able to work around this with a timed action to delay the changes but even that will leave a chance of a race condition. The toolbar gets created here:

    ZmComposeController.prototype._setView

    So may want to add a line of debug in that call to see when it's called exactly. I think we pre-create this view at start-up.
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  5. #5
    Join Date
    Mar 2006
    Posts
    21
    Rep Power
    9

    Default

    Quote Originally Posted by KevinH
    Yep I bet it's a race condition with zimlets loading and the composer getting loaded. You may be able to work around this with a timed action to delay the changes but even that will leave a chance of a race condition. The toolbar gets created here:

    ZmComposeController.prototype._setView

    So may want to add a line of debug in that call to see when it's called exactly. I think we pre-create this view at start-up.
    Hmm, I don't think the init function is being called. I put an alert call in there and it's not happening. I also populated a global value in my js and that's not happening either. Am I correct that if you create a function here:

    <zimlet name>.prototype.init =

    that it would be called when the zimlet was initialized? I based this on the other zimlets listed as examples such as Amazon and Wiki. Can you guys confirm that this is indeed being called?

    Cheers,
    Marty

  6. #6
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    It's called. You need to make sure your <zimlet>.properties lists your js file and the handlerObject (aka constructor) that will be called when it's loaded. So like:

    Code:
    <zimlet name="com_zimbra_ymaps" version="1.1" description="Yahoo Maps">
    -->   <include>ymaps.js</include>
    	<includeCSS>ymaps.css</includeCSS>
    	<resource>blank_pixel.gif</resource>
    	<resource>ymaps.gif</resource>
    -->    <handlerObject>Com_Zimbra_YMaps</handlerObject>
     .....
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  7. #7
    Join Date
    Mar 2006
    Posts
    21
    Rep Power
    9

    Default

    FYI, the issue turned out to be the order of the init function definition and the prototype construction. You want to make sure the init function is listed after you do the prototype work. Here's a short example:


    Com_Rs_Compose.prototype = new ZmZimletBase();
    Com_Rs_Compose.prototype.constructor = Com_Rs_Compose;

    Com_Rs_Compose.prototype.init = function() {
    ...
    }


    It seems obvious now that I think of it but initially I didn't think that getting it overwritten was possible. Silly me.

    Cheers,
    Marty

Similar Threads

  1. upgrade woes -made into new thread
    By JustinHarlow in forum Installation
    Replies: 18
    Last Post: 06-08-2007, 12:11 PM
  2. Can't start Zimbra!
    By zibra in forum Administrators
    Replies: 5
    Last Post: 03-22-2007, 11:34 AM
  3. Replies: 8
    Last Post: 02-27-2007, 03:10 AM
  4. Unable to start tomcat
    By chanck in forum Administrators
    Replies: 11
    Last Post: 06-11-2006, 12:58 AM
  5. Monitoring : Data not yet avalaible
    By s3nz3x in forum Installation
    Replies: 7
    Last Post: 11-30-2005, 06:18 PM

Posting Permissions

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