1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2007, 2008, 2009, 2010, 2013, 2014, 2016 Synacor, Inc.
  5  *
  6  * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at: https://www.zimbra.com/license
  9  * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15
 10  * have been added to cover use of software over a computer network and provide for limited attribution
 11  * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
 12  *
 13  * Software distributed under the License is distributed on an "AS IS" basis,
 14  * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 15  * See the License for the specific language governing rights and limitations under the License.
 16  * The Original Code is Zimbra Open Source Web Client.
 17  * The Initial Developer of the Original Code is Zimbra, Inc.  All rights to the Original Code were
 18  * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015.
 19  *
 20  * All portions of the code are Copyright (C) 2007, 2008, 2009, 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * Creates the portal view.
 26  * @class
 27  * This class represents the portal view.
 28  * 
 29  * @param {DwtComposite}	container	the containing element
 30  * @param	{ZmPortalApp}	app			the application
 31  * @param	{DwtDropTarget}	dropTgt		the drop target
 32  * 
 33  * @extends		ZmListView
 34  */
 35 ZmPortalView = function(parent, controller, dropTgt) {
 36 	var headerList = this._getHeaderList();
 37 	ZmListView.call(this, {parent:parent, className:"ZmPortalView",
 38 						   posStyle:Dwt.ABSOLUTE_STYLE, view:ZmId.VIEW_PORTAL,
 39 						   controller:controller, headerList:headerList, dropTgt:dropTgt});
 40     this.setLocation(Dwt.LOC_NOWHERE, Dwt.LOC_NOWHERE);
 41 	this.setScrollStyle(Dwt.SCROLL);
 42 }
 43 ZmPortalView.prototype = new ZmListView;
 44 ZmPortalView.prototype.constructor = ZmPortalView;
 45 
 46 /**
 47  * Returns a string representation of the object.
 48  * 
 49  * @return		{String}		a string representation of the object
 50  */
 51 ZmPortalView.prototype.toString = function() {
 52 	return "ZmPortalView";
 53 };
 54 
 55 //
 56 // Public methods
 57 //
 58 
 59 /**
 60  * Gets the portlet ids.
 61  * 
 62  * @return	{Array}		an array of portlet ids
 63  */
 64 ZmPortalView.prototype.getPortletIds = function() {
 65     return this._portletIds || [];
 66 };
 67 
 68 //
 69 // Protected methods
 70 //
 71 
 72 ZmPortalView.prototype._getHeaderList = function() {
 73     return [];
 74 };
 75 
 76 //ZmPortalView.prototype._initializeView = function() {
 77 ZmPortalView.prototype.set = function() {
 78 	if (this._rendered)  { 
 79 		Dwt.setTitle(this.getTitle()); //bug:24787
 80 		return;
 81 	}
 82 	var callback = new AjxCallback(this, this._initializeView2);
 83     appCtxt.getApp(ZmApp.PORTAL).getManifest(callback);
 84 };
 85 
 86 ZmPortalView.prototype._initializeView2 = function(manifest) {
 87     // layout view
 88     var portalDef = manifest && manifest.portal;
 89     if (portalDef) {
 90         this.getHtmlElement().innerHTML = portalDef.html || "";
 91     }
 92 
 93     // create portlets
 94     var portletMgr = appCtxt.getApp(ZmApp.PORTAL).getPortletMgr();
 95     this._portletIds = portletMgr.createPortlets();
 96 
 97 	this._rendered = true;
 98 };
 99 
100 /**
101  * Gets the view title.
102  * 
103  * @return	{String}	the title
104  */
105 ZmPortalView.prototype.getTitle =
106 function() {
107 	return [ZmMsg.zimbraTitle, this._controller.getApp().getDisplayName()].join(": ");
108 };
109