Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-2010, 06:36 AM
Junior Member
 
Posts: 9
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?
Reply With Quote
  #2 (permalink)  
Old 02-18-2010, 03:14 PM
Project Contributor
 
Posts: 92
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.

Quote:
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;

Quote:
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.
Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 02-19-2010, 11:10 AM
Zimbra Employee
 
Posts: 105
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
Reply With Quote
  #4 (permalink)  
Old 02-25-2010, 08:58 AM
Junior Member
 
Posts: 9
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.