Results 1 to 4 of 4

Thread: [SOLVED] Controlling tab positions

  1. #1
    Join Date
    Feb 2010
    Location
    WNY
    Posts
    12
    Rep Power
    5

    Default [SOLVED] Controlling tab positions

    One of my challenges for this project I am working on is to add a new 'Tab' Application / Zimlet, but the tab itself needs to be the second tab in the row appearing after the MAIL tab.

    I have tried looking for some sort of control for this handling this, but I am either overlooking it or there is nothing really written on this.

    Would something like this be accomplished by editing one of the initial .js files like zimbra.js or startup? If so, can anyone target a specific area of the code?

    Can anyone offer advice?

  2. #2
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    6

    Default

    Hi cmac,

    You better see ZmAppChooser.js, which is the container for application tabs.

    When you do "createApp" in your zimlet, it actually execute ZmZimletBase.js 's createApp. And In that function, you get the appchooser and execute addButton of it like below.

    controller.getAppChooser().addButton(appName, {text:label, image:image, tooltip:tooltip});
    But this method can not be called with some index, which specify where the button should be added. So the button gets added at the last in the row.

    If you want to modify Zimbra's original source code, maybe you can add one method like addButton to ZmAppChooser.js, but with index parameter like;

    insertButton(appName, {text:label, image:image, tooltip:tooltip,index:index});
    Implementation of this method could be as exactly same as addButton method.
    But the only difference is "buttonParams", which is used as parameter when executing constructor of ZmAppButton
    and it should include "index:params.index".

    Then you can exectute the method something like this in your zimlet.
    controller.getAppChooser().insertButton(appName, {text:label, image:image, tooltip:tooltip, index:2});
    I did not try this idea yet.
    So it is great if you try and tell me result.

    I hope it will help you.

  3. #3
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    Instead of overwriting the core code in ZmZimletBase.js (and avoid that getting overridden when you upgrade), you can call the code to construct the tab directly in your zimlet for now.

    Here is example code that you would call in your zimlet init() function to create the tab. Notice the index is being set as one of the params sent to addButton():

    Code:
    com_zimbra_example_simpletab_HandlerObject.prototype.init =
    function() {
    
    var label = "Simple Tab App";
    var image = "zimbraIcon";
    var tooltip = "A simple app in a new tab";
    var index = 2;
    	
    var params = {
    	text:label,
    	image:image,
    	tooltip:tooltip,
    	index:index
    	};
    	
    AjxDispatcher.require("ZimletApp");
    
    var appName = [this.name, Dwt.getNextId()].join("_");
    var controller = appCtxt.getAppController();
    	
    var appChooser = controller.getAppChooser();
    	
    appChooser.addButton(appName, params);
    
    var app = new ZmZimletApp(appName, this, DwtShell.getShell(window));
    controller.addApp(app);
    
    this._simpleAppName = appName
    }

    We have filed and are making this enhancement to add support for setting the index when creating the tab. This will become available with ZCS 6.0.6 and when that happens, you can return to using ZmZimletBase.createApp() and optionally specify an index (vs. using the code above):

    Bug 44720 – Tab Zimlet support for index

  4. #4
    Join Date
    Feb 2010
    Location
    WNY
    Posts
    12
    Rep Power
    5

    Default Fantastic Fix!

    Thanks very much!

    Once I changed "_simpleAppName" (in the last line of your code) to my own application name, and commented out my original two lines in my init function, everything just worked without modifying or changing anything else.

    Glad to also hear it will be a fix in the new release!

    Cheers!

Similar Threads

  1. [SOLVED] Tab Order
    By Ericx in forum Zimlets
    Replies: 3
    Last Post: 08-25-2010, 01:17 PM
  2. Replies: 0
    Last Post: 12-07-2009, 04:08 PM
  3. embed single document in new tab (or home tab)
    By captainmish in forum Administrators
    Replies: 0
    Last Post: 03-09-2009, 08:14 AM
  4. Replies: 1
    Last Post: 04-23-2008, 08:11 PM
  5. Tab Key: Focus Mechanism or Composition Tool?
    By bhickey in forum Administrators
    Replies: 0
    Last Post: 03-29-2007, 10:45 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
  •