1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2004, 2005, 2006, 2007, 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) 2004, 2005, 2006, 2007, 2009, 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 // This class is currently not being used and has been removed from the build 25 ZmEmoticonObjectHandler = function() { 26 27 ZmObjectHandler.call(this, ZmEmoticonObjectHandler.TYPE); 28 29 this._emoticons = [ 30 { smiley: ">:)", image: "DevilEmoticon", tooltip: ZmMsg.devil }, 31 { smiley: ":)", image: "HappyEmoticon", tooltip: ZmMsg.happy }, 32 { smiley: "=))", image: "RotflEmoticon", tooltip: ZmMsg.rotfl }, 33 { smiley: "=((", image: "BrokenHeartEmoticon", tooltip: ZmMsg.brokenHeart }, 34 { smiley: ":((", image: "CryingEmoticon", tooltip: ZmMsg.crying }, 35 { smiley: "<:-P", image: "PartyEmoticon", tooltip: ZmMsg.party }, 36 { smiley: ":O)", image: "ClownEmoticon", tooltip: ZmMsg.clown } 37 ]; 38 39 this._smileyToSD = {}; 40 41 var regex = new Array(10); 42 var idx = 0; 43 var n = 0; 44 // create regex to handle all the emoticons 45 for (var i in this._emoticons) { 46 var emot = this._emoticons[i]; 47 this._smileyToSD[emot.smiley] = emot; 48 if (n++ > 0) 49 regex[idx++] = "|"; 50 regex[idx++] ="("; 51 if (emot.re != null) 52 regex[idx++] = emot.re; 53 else 54 regex[idx++] = emot.smiley.replace(ZmEmoticonObjectHandler.RE_ESCAPE_RE, "\\$1"); 55 regex[idx++] =")"; 56 } 57 this._EMOTICONS_RE = new RegExp(regex.join(""), "g"); 58 59 }; 60 61 ZmEmoticonObjectHandler.prototype = new ZmObjectHandler; 62 ZmEmoticonObjectHandler.prototype.constructor = ZmEmoticonObjectHandler; 63 64 ZmEmoticonObjectHandler.TYPE = "emoticon"; 65 66 ZmEmoticonObjectHandler.RE_ESCAPE_RE = /([\(\)\-\$])/g; 67 68 ZmEmoticonObjectHandler.prototype.match = 69 function(line, startIndex) { 70 this._EMOTICONS_RE.lastIndex = startIndex; 71 var m = this._EMOTICONS_RE.exec(line); 72 if (m) m.context = {}; 73 return m; 74 }; 75 76 ZmEmoticonObjectHandler.prototype._getHtmlContent = 77 function(html, idx, smiley, context) { 78 context.sd = this._smileyToSD[smiley]; 79 if (context.sd) { 80 html[idx++] = AjxImg.getImageHtml(context.sd.image, null, null, true); 81 } else { 82 return AjxStringUtil.htmlEncode(smiley); 83 } 84 return idx; 85 }; 86 87 ZmEmoticonObjectHandler.prototype.selected = 88 function(obj, span, ev, context) { 89 if (context.isRaw) { 90 span.innerHTML = context.html; 91 context.isRaw = false; 92 } else { 93 context.html = span.innerHTML; 94 context.isRaw = true; 95 span.innerHTML = AjxStringUtil.htmlEncode(context.sd.smiley); 96 } 97 }; 98 99 ZmEmoticonObjectHandler.prototype.getToolTipText = 100 function(smiley, context) { 101 return "<b>" + context.sd.tooltip + "</b>"; 102 }; 103 104 ZmEmoticonObjectHandler.prototype.getHoveredClassName = 105 function(object, context) { 106 return this._className; 107 } 108 109 ZmEmoticonObjectHandler.prototype.getActionMenu = 110 function(obj) { 111 return null; 112 }; 113