1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2008, 2009, 2010, 2012, 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, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 25 /** 26 * This class represents an alert that highlights and flashes an application tab. 27 * 28 * @param {ZmApp} app the application 29 * @class 30 * @private 31 */ 32 ZmAppAlert = function(app) { 33 this.app = app; 34 }; 35 36 ZmAppAlert.prototype.isZmAppAlert = true; 37 ZmAppAlert.prototype.toString = function() { return "ZmAppAlert"; }; 38 39 /** 40 * Starts the alert. 41 */ 42 ZmAppAlert.prototype.start = 43 function() { 44 var appButton = this._getAppButton(); 45 if (!appButton) { return; } 46 47 if (!appButton.isSelected) { 48 appButton.showAlert(true); 49 //add a stop alert listener 50 if (!this._stopAlertListenerObj) { 51 this._stopAlertListenerObj = new AjxListener(this, this.stop); 52 appButton.addSelectionListener(this._stopAlertListenerObj); 53 } 54 } 55 }; 56 57 /** 58 * Stops the alert. 59 */ 60 ZmAppAlert.prototype.stop = 61 function() { 62 var appButton = this._getAppButton(); 63 if (!appButton) { return; } 64 if (appButton.isSelected) { 65 appButton.showAlert(false); 66 } 67 }; 68 69 ZmAppAlert.prototype._getAppButton = 70 function() { 71 return appCtxt.getAppController().getAppChooserButton(this.app.getName()); 72 }; 73 74