This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathkemoji.min.js
1 lines (1 loc) · 9.05 KB
/
kemoji.min.js
1
(function(){function n(){this.add=function(e){this.push(e)}}function r(e,n,r){function c(n){var r=document.createElement("IMG");t.attr(r,"src","img/opacity.png");t.addClass(r,"ke");t.addClass(r,"ke-"+n);t.attr(r,"emoji",n);if("onresizestart"in r)r.onresizestart=function(){return false};if(window.getSelection){var i=window.getSelection();if(i.getRangeAt&&i.rangeCount){var u=i.focusNode.tagName?i.focusNode:i.focusNode.parentNode;var a=t.parentsByClass(u,"KEmoji_Block");if(u==o|u==s&&a==e){var f=window.getSelection().getRangeAt(0);f.insertNode(r);d(r);return true}}}o.appendChild(r);v()}function h(){if(document.getSelection){var e=document.getSelection();if(e.rangeCount>0)return e.getRangeAt(0)}return false}function p(e){if(document.getSelection){var t=window.getSelection();t.removeAllRanges();t.addRange(e)}}function d(e){var t=document.createRange();t.setStartAfter(e);t.setEndAfter(e);p(t)}function v(){o.focus();if(window.getSelection&&document.createRange){var e=document.createRange();e.selectNodeContents(o);e.collapse(false);p(e)}}function y(){u.style.display="block";var e=u.offsetHeight;u.style.display="none";u.style.bottom="-"+(e+g)+"px";u.style.right="-20px";u.style.display="block";m=true}function b(){u.style.display="none";m=false}function w(){if(m==false)y();else b()}this.id=n;var i={maxHeight:200,autoresize:false,smiles:["D83DDE0A","D83DDE03","D83DDE09","D83DDE06","D83DDE1C","D83DDE0B","D83DDE0D","D83DDE0E","D83DDE12","D83DDE0F","D83DDE14","D83DDE22","D83DDE2D","D83DDE29","D83DDE28","D83DDE10","D83DDE0C","D83DDE04","D83DDE07","D83DDE30","D83DDE32","D83DDE33","D83DDE37","D83DDE02","2764","D83DDE1A","D83DDE15","D83DDE2F","D83DDE26","D83DDE35","D83DDE20","D83DDE21","D83DDE1D","D83DDE34","D83DDE18","D83DDE1F","D83DDE2C","D83DDE36","D83DDE2A","D83DDE2B","263A","D83DDE00","D83DDE25","D83DDE1B","D83DDE16","D83DDE24","D83DDE23","D83DDE27","D83DDE11","D83DDE05","D83DDE2E","D83DDE1E","D83DDE19","D83DDE13","D83DDE01","D83DDE31","D83DDE08","D83DDC7F","D83DDC7D","D83DDC4D","D83DDC4E","261D","270C","D83DDC4C","D83DDC4F","D83DDC4A","270B","D83DDE4F","D83DDC43","D83DDC46","D83DDC47","D83DDC48","D83DDCAA","D83DDC42","D83DDC8B","D83DDCA9","2744","D83CDF4A","D83CDF77","D83CDF78","D83CDF85","D83DDCA6","D83DDC7A","D83DDC28","D83DDD1E","D83DDC79","26BD","26C5","D83CDF1F","D83CDF4C","D83CDF7A","D83CDF7B","D83CDF39","D83CDF45","D83CDF52","D83CDF81","D83CDF82","D83CDF84","D83CDFC1","D83CDFC6","D83DDC0E","D83DDC0F","D83DDC1C","D83DDC2B","D83DDC2E","D83DDC03","D83DDC3B","D83DDC3C","D83DDC05","D83DDC13","D83DDC18","D83DDC94","D83DDCAD","D83DDC36","D83DDC31","D83DDC37","D83DDC11","23F3","26BE","26C4","2600","D83CDF3A","D83CDF3B","D83CDF3C","D83CDF3D","D83CDF4B","D83CDF4D","D83CDF4E","D83CDF4F","D83CDF6D","D83CDF37","D83CDF38","D83CDF46","D83CDF49","D83CDF50","D83CDF51","D83CDF53","D83CDF54","D83CDF55","D83CDF56","D83CDF57","D83CDF69","D83CDF83","D83CDFAA","D83CDFB1","D83CDFB2","D83CDFB7","D83CDFB8","D83CDFBE","D83CDFC0","D83CDFE6","D83DDE38","D83DDE39","D83DDE3C","D83DDE3D","D83DDE3E","D83DDE3F","D83DDE3B","D83DDE40","D83DDE3A","23F0","2601","260E","2615","267B","26A0","26A1","26D4","26EA","26F3","26F5","26FD","2702","2708","2709","270A","270F","2712","2728","D83CDC04","D83CDCCF","D83CDD98","D83CDF02","D83CDF0D","D83CDF1B","D83CDF1D","D83CDF1E","D83CDF30","D83CDF31","D83CDF32","D83CDF33","D83CDF34","D83CDF35","D83CDF3E","D83CDF3F","D83CDF40","D83CDF41","D83CDF42","D83CDF43","D83CDF44","D83CDF47","D83CDF48","D83CDF5A","D83CDF5B","D83CDF5C","D83CDF5D","D83CDF5E","D83CDF5F","D83CDF60","D83CDF61","D83CDF62","D83CDF63","D83CDF64","D83CDF65","D83CDF66","D83CDF67","D83CDF68","D83CDF6A","D83CDF6B","D83CDF6C","D83CDF6E","D83CDF6F","D83CDF70","D83CDF71","D83CDF72","D83CDF73","D83CDF74","D83CDF75","D83CDF76","D83CDF79","D83CDF7C","D83CDF80","D83CDF88","D83CDF89","D83CDF8A","D83CDF8B","D83CDF8C","D83CDF8D","D83CDF8E","D83CDF8F","D83CDF90","D83CDF92","D83CDF93","D83CDFA3","D83CDFA4","D83CDFA7","D83CDFA8","D83CDFA9","D83CDFAB","D83CDFAC","D83CDFAD","D83CDFAF","D83CDFB0","D83CDFB3","D83CDFB4","D83CDFB9","D83CDFBA","D83CDFBB","D83CDFBD","D83CDFBF","D83CDFC2","D83CDFC3","D83CDFC4","D83CDFC7","D83CDFC8","D83CDFC9","D83CDFCA","D83DDC00","D83DDC01","D83DDC02","D83DDC04","D83DDC06","D83DDC07","D83DDC08","D83DDC09","D83DDC0A","D83DDC0B","D83DDC0C","D83DDC0D","D83DDC10","D83DDC12"]};r=t.extend(i,r);t.addClass(e,"KEmoji_Block");t.attr(e,"emoji-id",n);var s=document.createElement("div");s.innerHTML='<div contenteditable="true" tabindex="1"> </div>';t.addClass(s,"KEmoji_Input");var o=s.firstElementChild;e.appendChild(s);var u=document.createElement("div");t.addClass(u,["KEmoji_Cont","KEmoji_Cont_Hidden"]);t.attr(u,{tabindex:"-1",readonly:"readonly"});u.innerHTML="<div></div>";for(var a in r.smiles)t.append(u.firstElementChild,'<div class="KEmoji_Smile" emoji="'+r.smiles[a]+'"><div><i class="ke ke-'+r.smiles[a]+'"></i></div></div>');t.append(u.firstElementChild,'<div class="KEmoji_Clear"></div>');e.appendChild(u);var f=document.createElement("div");t.addClass(f,"KEmoji_TollBar");var l=document.createElement("div");t.addClass(l,"KEmoji_Smiles_Show_Button");l.innerHTML="<div></div>";f.appendChild(l);e.appendChild(f);(function(e){for(var n=0;n!=e.length;n++)t.attr(e[n],{unselectable:"on",onselectstart:"return false;",onmousedown:"return false;"})})([l,u]);t.on(l,"click",function(){w()});t.on(u,"click",function(e){var n=t.parentsByClass(e.target,"KEmoji_Smile");if(n){var r=t.attr(n,"emoji");c(r)}});t.on(o,"paste",function(e){var n="";if(e.clipboardData)n=e.clipboardData.getData("text/plain");else if(window.clipboardData)n=window.clipboardData.getData("Text");else if(e.originalEvent.clipboardData)n=document.createTextNode(e.originalEvent.clipboardData.getData("text"));if(document.queryCommandSupported("insertText")){document.execCommand("insertHTML",false,n.innerText.replace(/\n/g,"<br>"));return false}else{var r=o.getElementsByTagName("*");for(var i=0;i!=r.length;i++){t.addClass(r[i],"within")}setTimeout(function(){var e=o.getElementsByTagName("*");for(var n=0;n!=e.length;n++){if(!t.hasClass(e[n],"within")){e[n].innerText=e[n].innerHTML}}},1)}});t.on(o,"keypress",function(e){if(e.keyCode==13){e.preventDefault();if(window.getSelection){var t=window.getSelection(),n=h(),r=document.createElement("br"),i=document.createTextNode(" ");n.deleteContents();n.insertNode(r);n.collapse(false);n.insertNode(document.createElement("br"));p(n);return false}}});t.on(o,"click",function(e){if(t.hasClass(e.target,"ke"))d(e.target)});var m=false,g=48;t.on(document,"click",function(n){if(m==true){var r=t.parentsByClass(n.target,"KEmoji_Block");if(r!=e)b()}});this.focus=function(){e.focus()};this.setWidth=function(t){e.style.width=t+"px"};this.setHeight=function(t){e.style.height=t+"px"};this.setSmileContainerWidth=function(e){u.firstElementChild.style.width=e+"px"};this.setSmileContainerHeight=function(e){u.style.height=e+"px"};this.showSmiles=function(){y()};this.hideSmiles=function(){b()};this.toggleSmiles=function(){w()};this.getValue=function(e){var t=o.innerHTML;if(!e||e==KEmoji.TEXT_VALUE)return t.replace(/<img.*?class="ke ke-(.*?)".*?>/g," $#$1#$ ");else if(e==KEmoji.HTML_VALUE)return t;return null};this.setValue=function(e,t){if(!t||t==KEmoji.TEXT_VALUE)o.innerHTML=e.replace(/\$#(.*?)#\$/g,'<img src="img/opacity.png" onresizestart="return false" class="ke ke-$1">');else if(t==KEmoji.HTML_VALUE)o.innerHTML=e};if(r.width)this.setWidth(r.width);if(r.height)this.setHeight(r.height);if(r.smileContainerWidth)this.setSmileContainerWidth(r.smileContainerWidth);if(r.smileContainerHeight)this.setSmileContainerHeight(r.smileContainerHeight)}var e=1;setTimeout(function(){try{document.execCommand("enableObjectResizing",false,false)}catch(e){}},1);var t=function(){function e(e){return e.className?e.className.trim().split(" "):[]}function t(e,t){e.className=t.join(" ").trim()}return{extend:function(e,t){var n=e;for(var r in t)n[r]=t[r];return n},addClass:function(n,r){if(typeof r=="object"){for(var i=0;i!=r.length;i++)this.addClass(n,r[i]);return}var s=e(n);if(s.indexOf(r)==-1){s.push(r);t(n,s)}},removeClass:function(n,r){if(typeof r=="object"){for(var i=0;i!=r.length;i++)this.removeClass(n,r[i]);return}var s=e(n);var o=s.indexOf(r);if(o>-1){delete s[o];t(n,s)}},hasClass:function(t,n){var r=e(t);return r.indexOf(n)>-1?true:false},attr:function(e,t,n){if(typeof t=="object")for(var r in t)this.attr(e,r,t[r]);else if(t&&n)e.setAttribute(t,n);else if(t)return e.getAttribute(t);return null},append:function(e,t){e.innerHTML+=t},parent:function(e){return e.parentElement},parentsByClass:function(t,n){t=t.parentElement;if(t){while(t.tagName!="BODY"){var r=e(t);if(r.indexOf(n)>-1)return t;t=t.parentElement}}return false},on:function(e,t,n){e.addEventListener(t,n,false)}}}();n.prototype=Array.prototype;window.KEmoji={HTML_VALUE:1,TEXT_VALUE:2,count:1,data:{},_init:function(t,n){var i=e++;this.data[i]=new r(t,i,n);return this.data[i]},init:function(e,t){return this._init(document.getElementById(e),t)},initByClass:function(e,t){var r=document.getElementsByClassName(e),i=new n;for(var s=0;s!=r.length;s++){i.add(this._init(r[s],t))}return i},getByEmojiId:function(e){return this.data[e]},getByElement:function(e){var n=t.attr(e,"emoji-id");if(n)return this.getByEmojiId(n);return null}}})()