1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 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) 2009, 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * @overview 26 */ 27 28 /** 29 * Creates an overview container. 30 * @constructor 31 * @class 32 * Creates a header tree item for an account if mailbox has multiple accounts 33 * configured. For each account header, a {@link ZmOverview} is added a child. If mailbox 34 * only has one account configured, no account header is created and the 35 * {@link ZmOverview} is added as a child of the container. 36 * 37 * @param {Hash} params a hash of parameters 38 * @author Parag Shah 39 */ 40 ZmOverviewContainer = function(params) { 41 if (arguments.length == 0) { return; } 42 43 params.className = params.className || "ZmOverviewContainer"; 44 params.id = params.id || ZmId.getOverviewContainerId(params.containerId); 45 DwtTree.call(this, params); 46 47 this.setScrollStyle(params.scroll || Dwt.SCROLL_Y); 48 49 this.containerId = params.containerId; 50 this._appName = params.appName; 51 this._controller = params.controller; 52 this._headerItems = {}; 53 this._overview = {}; 54 55 // add listeners 56 this.addSelectionListener(new AjxListener(this, this._treeViewListener)); 57 this.addTreeListener(new AjxListener(this, this._treeListener)); 58 }; 59 60 ZmOverviewContainer.prototype = new DwtTree; 61 ZmOverviewContainer.prototype.constructor = ZmOverviewContainer; 62 63 ZmOverviewContainer.prototype.toString = 64 function() { 65 return "ZmOverviewContainer"; 66 }; 67 68 /** 69 * Initializes the overview container. 70 * 71 * @param {Hash} params a hash of parameters 72 */ 73 ZmOverviewContainer.prototype.initialize = 74 function(params) { 75 // overload 76 }; 77 78 /** 79 * Gets the overview. 80 * 81 * @param {String} overviewId the overview id 82 * @return {ZmOverview} the overview 83 */ 84 ZmOverviewContainer.prototype.getOverview = 85 function(overviewId) { 86 return this._overview[overviewId]; 87 }; 88 89 /** 90 * Gets the overviews. 91 * 92 * @return {Array} an array of {ZmOverview} objects 93 */ 94 ZmOverviewContainer.prototype.getOverviews = 95 function() { 96 return this._overview; 97 }; 98 99 /** 100 * Gets the header item. 101 * 102 * 103 */ 104 ZmOverviewContainer.prototype.getHeaderItem = 105 function() { 106 // overload 107 }; 108 109 /** 110 * Gets the selected overview. 111 * 112 * @return {ZmOverview} the overview 113 */ 114 ZmOverviewContainer.prototype.getSelected = 115 function() { 116 var selected; 117 for (var i in this._overview) { 118 selected = this._overview[i].getSelected(); 119 if (selected) { 120 return selected; 121 } 122 } 123 }; 124 125 /** 126 * Deselects all tree views for each overview in this container 127 * 128 * @param exception [ZmOverview]* If set, this overview is skipped during deselection 129 */ 130 ZmOverviewContainer.prototype.deselectAll = 131 function(exception) { 132 DwtTree.prototype.deselectAll.call(this); 133 this._deselectAllTreeViews(exception); 134 }; 135 136 /** 137 * Sets the overview trees. 138 * 139 * @param {Array} treeIds an array of tree ids 140 */ 141 ZmOverviewContainer.prototype.setOverviewTrees = 142 function(treeIds) { 143 for (var i in this._overview) { 144 this._overview[i].set(treeIds); 145 } 146 }; 147 148 /** 149 * Resets the operations. 150 * 151 * 152 */ 153 ZmOverviewContainer.prototype.resetOperations = 154 function(parent, acctId) { 155 // overload me 156 }; 157 158 ZmOverviewContainer.prototype._treeViewListener = 159 function(ev) { 160 // overload 161 }; 162 163 ZmOverviewContainer.prototype._treeListener = 164 function(ev) { 165 // overload 166 }; 167 168 ZmOverviewContainer.prototype._initializeActionMenu = 169 function(account) { 170 // overload 171 }; 172 173 ZmOverviewContainer.prototype._getActionMenu = 174 function(ev) { 175 if (this._actionMenu instanceof AjxCallback) { 176 var callback = this._actionMenu; 177 this._actionMenu = callback.run(); 178 } 179 return this._actionMenu; 180 }; 181 182 ZmOverviewContainer.prototype._createActionMenu = 183 function(parent, menuItems, account) { 184 // overload 185 }; 186 187 ZmOverviewContainer.prototype._actionMenuListener = 188 function(ev) { 189 // overload 190 }; 191 192 /** 193 * Deselects any selection for each overview this container is managing. 194 * 195 * @param exception [ZmOverview]* If set, deselects all overviews except this one. 196 */ 197 ZmOverviewContainer.prototype._deselectAllTreeViews = 198 function(exception) { 199 // make sure none of the other items in the other overviews are selected 200 for (var i in this._overview) { 201 var overview = this._overview[i]; 202 if (exception && exception == overview ) { continue; } 203 204 var trees = overview._treeHash; 205 for (var j in trees) { 206 if (trees[j].getSelectionCount() > 0) { 207 trees[j].deselectAll(); 208 break; 209 } 210 } 211 } 212 }; 213