1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 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) 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 ZmMiniCalendar = function(params) { 25 if (arguments.length == 0) { return; } 26 DwtCalendar.call(this, params); 27 }; 28 29 ZmMiniCalendar.prototype = new DwtCalendar; 30 ZmMiniCalendar.prototype.constructor = ZmMiniCalendar; 31 32 ZmMiniCalendar.COLOR_GREEN = 'green'; 33 ZmMiniCalendar.COLOR_RED = 'red'; 34 ZmMiniCalendar.COLOR_ORANGE = 'orange'; 35 36 //override class name selection to include color code into consideration 37 ZmMiniCalendar.prototype._setCellClassName = 38 function(cell, className, mode) { 39 var className = DwtCalendar.prototype._setCellClassName.call(this, cell, className, mode); 40 if(cell._colorCode) { 41 className += this._getSuggestionClassName(cell._colorCode); 42 } 43 return className; 44 }; 45 46 ZmMiniCalendar.prototype._getSuggestionClassName = 47 function(colorCode) { 48 return " " + this._origDayClassName + "-" + colorCode; 49 }; 50 51 /** 52 * Enables/disables the highlight (i.e. "bolding") on the dates in <code><dates></code>. 53 * 54 * @param {array} dates an array of {@link Date} objects for which to enable/disable highlighting 55 * @param {boolean} clear if <code>true</code>, clear current highlighting 56 * @param {array} string an array of strings representing color codes array ZmMiniCalendar.COLOR_GREEN, ZmMiniCalendar.COLOR_RED, ZmMiniCalendar.COLOR_ORANGE 57 */ 58 ZmMiniCalendar.prototype.setColor = 59 function(dates, clear, color) { 60 if (this._date2CellId == null) { return; } 61 62 var cell; 63 var aDate; 64 if (clear) { 65 for (aDate in this._date2CellId) { 66 cell = document.getElementById(this._date2CellId[aDate]); 67 if (cell._colorCode) { 68 cell._colorCode = null; 69 this._setClassName(cell, DwtCalendar._NORMAL); 70 } 71 } 72 } 73 74 var cellId; 75 for (var i in dates) { 76 aDate = dates[i]; 77 cellId = this._date2CellId[aDate.getFullYear() * 10000 + aDate.getMonth() * 100 + aDate.getDate()]; 78 79 if (cellId) { 80 cell = document.getElementById(cellId); 81 if (color[i]) { 82 cell._colorCode = color[i]; 83 this._setClassName(cell, DwtCalendar._NORMAL); 84 } 85 } 86 } 87 };