1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 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) 2010, 2011, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 ZmShareProxy = function(params) {
 25     params.type = ZmOrganizer.SHARE;
 26     ZmOrganizer.call(this, params);
 27 };
 28 ZmShareProxy.prototype = new ZmFolder;
 29 ZmShareProxy.prototype.constructor = ZmShareProxy;
 30 
 31 ZmShareProxy.prototype.toString = function() {
 32     return "ZmShareProxy";
 33 };
 34 
 35 // Constants
 36 
 37 ZmShareProxy.ID_LOADING = -1;
 38 ZmShareProxy.ID_NONE_FOUND = -2;
 39 ZmShareProxy.ID_WARNING = -2;
 40 ZmShareProxy.ID_ERROR = -3;
 41 
 42 // Data
 43 
 44 ZmShareProxy.prototype.TOOLTIP_TEMPLATE = "share.Widgets#ZmShareProxyToolTip";
 45 
 46 // ZmOrganizer methods
 47 
 48 ZmShareProxy.prototype.getIcon = function() {
 49     // icons for loading states
 50     var m = String(this.id).match(/^(-\d)(?::(.*))?$/);
 51     switch (Number(m && m[1])) { // NOTE: case is === !!!
 52         case ZmShareProxy.ID_LOADING: return "Spinner";
 53         case ZmShareProxy.ID_NONE_FOUND: return "Warning";
 54         case ZmShareProxy.ID_ERROR: return "Critical";
 55     }
 56 
 57     // icon for share owner
 58     if (!this.shareInfo) return "SharedMailFolder";
 59 
 60     // icon based on view type
 61     var type = ZmOrganizer.TYPE[this.shareInfo.view];
 62     var orgPackage = ZmOrganizer.ORG_PACKAGE[type];
 63     if (orgPackage) AjxDispatcher.require(orgPackage);
 64     var orgClass = window[ZmOrganizer.ORG_CLASS[type]];
 65     return orgClass ? orgClass.prototype.getIcon.call(this) : "Folder";
 66 };
 67 
 68 ZmShareProxy.prototype.getToolTip = function(force) {
 69     if (!this.shareInfo) return null;
 70     if (force || !this._tooltip) {
 71         this._tooltip = AjxTemplate.expand(this.TOOLTIP_TEMPLATE, this.shareInfo);
 72     }
 73     return this._tooltip;
 74 };