1 line
64 KiB
JavaScript
1 line
64 KiB
JavaScript
|
|
window=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};document=window.document||{};(function(factory,global){if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){factory(require("jquery"))}else if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{factory(global.jQuery)}})(function($){"use strict";var unique=0;var eventStorage={};var possibleEvents={};var emojione=window.emojione;var readyCallbacks=[];function emojioneReady(fn){if(emojione){fn()}else{readyCallbacks.push(fn)}}var blankImg="data:image/gif;base64,R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==";var slice=[].slice;var css_class="emojionearea";var emojioneSupportMode=0;var invisibleChar="​";function trigger(self,event,args){var result=true,j=1;if(event){event=event.toLowerCase();do{var _event=j==1?"@"+event:event;if(eventStorage[self.id][_event]&&eventStorage[self.id][_event].length){$.each(eventStorage[self.id][_event],function(i,fn){return result=fn.apply(self,args||[])!==false})}}while(result&&!!j--)}return result}function attach(self,element,events,target){target=target||function(event,callerEvent){return $(callerEvent.currentTarget)};$.each(events,function(event,link){event=$.isArray(events)?link:event;(possibleEvents[self.id][link]||(possibleEvents[self.id][link]=[])).push([element,event,target])})}function getTemplate(template,unicode,shortname){var imageType=emojione.imageType,imagePath;if(imageType=="svg"){imagePath=emojione.imagePathSVG}else{imagePath=emojione.imagePathPNG}var friendlyName="";if(shortname){friendlyName=shortname.substr(1,shortname.length-2).replace(/_/g," ").replace(/\w\S*/g,function(txt){return txt.charAt(0).toUpperCase()+txt.substr(1).toLowerCase()})}var fname="";if(unicode.uc_base&&emojioneSupportMode>4){fname=unicode.uc_base;unicode=unicode.uc_output.toUpperCase()}else{fname=unicode}return template.replace("{name}",shortname||"").replace("{friendlyName}",friendlyName).replace("{img}",imagePath+(emojioneSupportMode<2?fname.toUpperCase():fname)+"."+imageType).replace("{uni}",unicode).replace("{alt}",emojione.convert(unicode))}function shortnameTo(str,template,clear){return str.replace(/:?\+?[\w_\-]+:?/g,function(shortname){shortname=":"+shortname.replace(/:$/,"").replace(/^:/,"")+":";var unicode=emojione.emojioneList[shortname];if(unicode){if(emojioneSupportMode>4){return getTemplate(template,unicode,shortname)}else{if(emojioneSupportMode>3)unicode=unicode.unicode;return getTemplate(template,unicode[unicode.length-1],shortname)}}return clear?"":shortname})}function pasteHtmlAtCaret(html){var sel,range;if(window.getSelection){sel=window.getSelection();if(sel.getRangeAt&&sel.rangeCount){range=sel.getRangeAt(0);range.deleteContents();var el=document.createElement("div");el.innerHTML=html;var frag=document.createDocumentFragment(),node,lastNode;while(node=el.firstChild){lastNode=frag.appendChild(node)}range.insertNode(frag);if(lastNode){range=range.cloneRange();range.setStartAfter(lastNode);range.collapse(true);sel.removeAllRanges();sel.addRange(range)}}}else if(document.selection&&document.selection.type!="Control"){document.selection.createRange().pasteHTML(html)}}var emojioneVersion=window.emojioneVersion||"2.2.7";function isObject(variable){return typeof variable==="object"}function detectVersion(emojione){var version;if(emojione.cacheBustParam){version=emojione.cacheBustParam;if(!isObject(emojione["jsEscapeMap"]))return"1.5.2";if(version==="?v=1.2.4")return"2.0.0";if(version==="?v=2.0.1")return"2.1.0";if(version==="?v=2.1.1")return"2.1.1";if(version==="?v=2.1.2")return"2.1.2";if(version==="?v=2.1.3")return"2.1.3";if(version==="?v=2.1.4")return"2.1.4";if(version==="?v=2.2.7")return"2.2.7";return"2.2.7"}else{return emojione.emojiVersion}}function getSupportMode(version){switch(version){case"1.5.2":return 0;case"2.0.0":return 1;case"2.1.0":case"2.1.1":return 2;case"2.1.2":return 3;case"2.1.3":case"2.1.4":case"2.2.7":return 4;case"3.0.1":case"3.0.2":case"3.0.3":case"3.0":return 5;case"3.1.0":case"3
|