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

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 Display Modes
  #1 (permalink)  
Old 07-07-2008, 11:26 AM
Intermediate Member
 
Posts: 17
Default Main Toolbar

Does anyone know how to get the main toolbar?
There are examples of how to add a button to the Compose toolbar, but I have been having trouble finding a way to add a button to the main toolbar. That is, the toolbar with Mail, Address Book, Calendar, Tasks,...

L. Jay
Reply With Quote
  #2 (permalink)  
Old 07-30-2008, 11:23 AM
Zimbra Employee
 
Posts: 10
Default

ZmApp.registerApp adds buttons to that tab control. It also defines a lot of other data for an app. Definitely not a trivial thing to do.
Reply With Quote
  #3 (permalink)  
Old 08-12-2008, 10:22 AM
Intermediate Member
 
Posts: 17
Smile Alternative Method

We were able to do this a little easier by creating a ZmChicletButton and adding it to the appChooser. It was still tricky, but probably not as complicated as using ZmApp.registerApp.
I'm not sure if this is a bad way to do it, but it seems to work great.
Reply With Quote
  #4 (permalink)  
Old 08-12-2008, 10:23 AM
Zimbra Employee
 
Posts: 10
Default

No, that's not a bad way to do it at all.
Reply With Quote
  #5 (permalink)  
Old 01-22-2009, 10:57 AM
Active Member
 
Posts: 41
Default

hi, anybody have running example
Reply With Quote
  #6 (permalink)  
Old 01-22-2009, 11:20 AM
Zimbra Employee
 
Posts: 115
Default

Quote:
Originally Posted by gregor View Post
hi, anybody have running example
check out com_zimbra_discover zimlet (in gallery.zimbra.com) It shows you how to add toolbar buttons to conversation view and traditional views. There will be easier way to achieve that in 6.x
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #7 (permalink)  
Old 01-22-2009, 12:03 PM
Active Member
 
Posts: 41
Default

thanks for the hint but the zimlet does not work with my release, does it work on your zwc?
source: Get or contribute Zimlets, UI themes, and languages in the Zimbra Gallery - discover!
Reply With Quote
  #8 (permalink)  
Old 01-22-2009, 06:44 PM
Zimbra Employee
 
Posts: 115
Default

It works for me since I wrote it . you just need to get the code that adds button on toolbars

Code:
com_zimbra_discover.prototype.initToolbarButton = function() {
	if (!appCtxt.get(ZmSetting.MAIL_ENABLED))
		this._toolbar = true;

	if (this._toolbar)
		return;
	// Add the discover Button to the conversation page
	var viewid = appCtxt.getAppViewMgr().getCurrentViewId();
	if(viewid == ZmId.VIEW_CONVLIST) {
		this._cnvController = AjxDispatcher.run("GetConvListController");
		this._cnvController._discover = this;
		if (!this._cnvController._toolbar) {
			// initialize the conv controller's toolbar
			this._cnvController._initializeToolBar();
		}
		this._toolbar = this._cnvController._toolbar.CLV;
	} else if(viewid == ZmId.VIEW_TRAD) {
		this._tradController = AjxDispatcher.run("GetTradController");
		this._tradController._discover = this;
		if (!this._tradController._toolbar) {
			// initialize the trad controller's toolbar
			this._tradController._initializeToolBar();
		}
		this._toolbar = this._tradController._toolbar.TV;
	}

	if(!this._toolbar)
		return;//dont add button

	var indx = this._toolbar.getItemCount() + 1;

	// Add button to toolbar
	if (!this._toolbar.getButton(com_zimbra_discover.discover)) {
		ZmMsg.discoverlabel = "discover!";
		ZmMsg.discovertip = "Opens websites based on topics of your choice";

		var btn = this._toolbar.createOp(
			com_zimbra_discover.discover,
		{
			text	: ZmMsg.discoverlabel,
			tooltip : ZmMsg.discovertip,
			index   :indx,
			image   : "dy-panelIcon"
		}
			);

		btn.addSelectionListener(new AjxListener(this, this.discBtnListener));
	}
};
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #9 (permalink)  
Old 02-07-2009, 12:44 AM
Intermediate Member
 
Posts: 23
Default

Quote:
Originally Posted by rrao View Post
It works for me since I wrote it . you just need to get the code that adds button on toolbars

Code:
com_zimbra_discover.prototype.initToolbarButton = function() {
	if (!appCtxt.get(ZmSetting.MAIL_ENABLED))
		this._toolbar = true;

	if (this._toolbar)
		return;
	// Add the discover Button to the conversation page
	var viewid = appCtxt.getAppViewMgr().getCurrentViewId();
	if(viewid == ZmId.VIEW_CONVLIST) {
		this._cnvController = AjxDispatcher.run("GetConvListController");
		this._cnvController._discover = this;
		if (!this._cnvController._toolbar) {
			// initialize the conv controller's toolbar
			this._cnvController._initializeToolBar();
		}
		this._toolbar = this._cnvController._toolbar.CLV;
	} else if(viewid == ZmId.VIEW_TRAD) {
		this._tradController = AjxDispatcher.run("GetTradController");
		this._tradController._discover = this;
		if (!this._tradController._toolbar) {
			// initialize the trad controller's toolbar
			this._tradController._initializeToolBar();
		}
		this._toolbar = this._tradController._toolbar.TV;
	}

	if(!this._toolbar)
		return;//dont add button

	var indx = this._toolbar.getItemCount() + 1;

	// Add button to toolbar
	if (!this._toolbar.getButton(com_zimbra_discover.discover)) {
		ZmMsg.discoverlabel = "discover!";
		ZmMsg.discovertip = "Opens websites based on topics of your choice";

		var btn = this._toolbar.createOp(
			com_zimbra_discover.discover,
		{
			text	: ZmMsg.discoverlabel,
			tooltip : ZmMsg.discovertip,
			index   :indx,
			image   : "dy-panelIcon"
		}
			);

		btn.addSelectionListener(new AjxListener(this, this.discBtnListener));
	}
};
Is it possible to add the button to both the traditional and conversation toolbars at the same time? I'm trying to use this code and it seems that if the user starts in normal view the button gets added, but if the switch to conversation view there's no button. The reverse is also true.
Reply With Quote
  #10 (permalink)  
Old 02-09-2009, 01:39 PM
Zimbra Employee
 
Posts: 115
Default

There is a way to make it work even when user changes the views.
There is a zimlet hook called onShowView which is called by core-zimbra whenever there is a change in view. And you can do whatever you need when that is called.
Here is an example usage:
Code:
com_zimbra_myzimlet.prototype.onShowView = function(viewId, isNewView) {
      if(viewid != ZmId.VIEW_CONVLIST || viewid != ZmId.VIEW_TRAD)
             return;

      if...
      <add code to check if traditional and conversation view already has button, if so exit from funtion>

       //call inittoolbar to add button..
        this.initToolbarButton();
};



PS: I wouldn't generally add it in this context since users don't change views on a daily basis and also due to performance reasons since this method is called for all views. You might want to make-sure you do all proper checks before using this.
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
Reply


Thread Tools
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.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0