1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2008, 2009, 2010, 2011, 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) 2008, 2009, 2010, 2011, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * @overview 26 * This file defines a Zimlet Application. 27 * 28 */ 29 30 /** 31 * @class 32 * This object represents a Zimlet Application. 33 * 34 * @param {String} name the application name 35 * @param {ZmZimlet} zimlet the zimlet 36 * @param {DwtControl} container the container 37 * 38 * @extends ZmApp 39 */ 40 ZmZimletApp = function(name, zimlet, container) { 41 ZmApp.call(this, name, container); 42 this._zimlet = zimlet; 43 }; 44 45 ZmZimletApp.prototype = new ZmApp; 46 ZmZimletApp.prototype.constructor = ZmZimletApp; 47 48 /** 49 * Returns a string representation of the object. 50 * 51 * @return {String} a string representation of the object 52 */ 53 ZmZimletApp.prototype.toString = 54 function() { 55 return "ZmZimletApp"; 56 }; 57 58 // 59 // Public methods 60 // 61 62 /** 63 * Gets the controller. 64 * 65 * @return {ZmZimletAppController} the controller 66 */ 67 ZmZimletApp.prototype.getController = 68 function() { 69 if (!this._controller) { 70 this._controller = new ZmZimletAppController(this.getName(), this._container, this); 71 } 72 return this._controller; 73 }; 74 75 /** 76 * Gets the toolbar. 77 * 78 * @return {ZmToolbar} the toolbar 79 */ 80 ZmZimletApp.prototype.getToolbar = 81 function() { 82 return this.getController().getToolbar(); 83 }; 84 85 // convenience methods 86 87 /** 88 * Sets the content on the view. 89 * 90 * @param {String} html the HTML content 91 */ 92 ZmZimletApp.prototype.setContent = 93 function(html) { 94 this.getController().getView().setContent(html); 95 }; 96 97 /** 98 * Sets the view. 99 * 100 * @param {DwtComposite} view the view 101 */ 102 ZmZimletApp.prototype.setView = 103 function(view) { 104 this.getController().getView().setView(view); 105 }; 106 107 // ZmApp methods 108 109 /** 110 * Launches the application. 111 * 112 * @param {Hash} params a hash of parameters 113 * @param {AjxCallback} callback the callback 114 */ 115 ZmZimletApp.prototype.launch = 116 function(params, callback) { 117 var isNewViewShown = this.getController().show(); 118 if(!isNewViewShown) { 119 return; 120 } 121 ZmApp.prototype.launch.call(this, params); 122 if (this._zimlet.appLaunch) { 123 this._zimlet.appLaunch(this.getName(), params); 124 } 125 if (callback) { 126 callback.run(); 127 } 128 }; 129 130 /** 131 * Activates the application. 132 * 133 * @param {Boolean} active if <code>true</code>, active; <code>false</code> otherwise 134 * @param {String} viewId the view id 135 */ 136 ZmZimletApp.prototype.activate = 137 function(active, viewId) { 138 ZmApp.prototype.activate.apply(this, arguments); 139 if (this._zimlet.appActive) { 140 this._zimlet.appActive(this.getName(), active); 141 } 142 }; 143 144 /** 145 * Sets the overview tree to display overview content for this application. 146 * 147 * @param {Boolean} reset if <code>true</code>, clear the content first 148 */ 149 ZmZimletApp.prototype.setOverviewPanelContent = 150 function(reset) { 151 if (reset) { 152 this._overviewPanelContent = null; 153 this._overviewContainer = null; 154 } 155 156 // only set overview panel content if not in full screen mode 157 var avm = appCtxt.getAppViewMgr(); 158 if (!avm.isFullScreen()) { 159 var components = {}; 160 components[ZmAppViewMgr.C_TREE] = this.getOverviewPanelContent(); 161 avm.setViewComponents(ZmAppViewMgr.APP, components, true, this.getName()); 162 } 163 }; 164 165