/*! jquery.emojiarea.js | https://github.com/diy/jquery-emojiarea | Apache License (v2) */ (function(d,i,e){var p=["p","div","pre","form"];d.emojiarea={path:"",icons:{},defaults:{button:null,buttonLabel:"Emojis",buttonPosition:"after"}};d.fn.emojiarea=function(a){a=d.extend({},d.emojiarea.defaults,a);return this.each(function(){var b=d(this);"contentEditable"in e.body&&!1!==a.wysiwyg?new l(b,a):new m(b,a)})};var g={},k;k=i.getSelection?function(a){var b=i.getSelection();b.removeAllRanges();for(var c=0,f=a.length;c/g, ">").replace(/"/g,""")};var j=function(){};j.prototype.setup=function(){var a=this;this.$editor.on("focus",function(){a.hasFocus=!0});this.$editor.on("blur",function(){a.hasFocus=!1});this.setupButton()};j.prototype.setupButton=function(){var a=this,b;this.options.button?b=d(this.options.button):!1!==this.options.button?(b=d(''),b.html(this.options.buttonLabel),b.addClass("emoji-button"),b.attr({title:this.options.buttonLabel}),this.$editor[this.options.buttonPosition](b)): b=d("");b.on("click",function(b){h.show(a);b.stopPropagation()});this.$button=b};j.createIcon=function(a){var b=d.emojiarea.icons[a],c=d.emojiarea.path||"";c.length&&"/"!==c.charAt(c.length-1)&&(c+="/");return''+g.htmlEntities(a)+''};var m=function(a,b){this.options=b;this.$editor=this.$textarea=a;this.setup()};m.prototype.insert=function(a){d.emojiarea.icons.hasOwnProperty(a)&&(g.insertAtCursor(a,this.$textarea[0]),this.$textarea.trigger("change"))};m.prototype.val=function(){return this.$textarea.val()}; g.extend(m.prototype,j.prototype);var l=function(a,b){var c=this;this.options=b;this.$textarea=a;this.$editor=d("
").addClass("emoji-wysiwyg-editor");this.$editor.text(a.val());this.$editor.attr({contenteditable:"true"});this.$editor.on("blur keyup paste",function(){return c.onChange.apply(c,arguments)});this.$editor.on("mousedown focus",function(){e.execCommand("enableObjectResizing",!1,!1)});this.$editor.on("blur",function(){e.execCommand("enableObjectResizing",!0,!0)});var f=this.$editor.text(), i=d.emojiarea.icons,h;for(h in i)i.hasOwnProperty(h)&&(f=f.replace(RegExp(g.escapeRegex(h),"g"),j.createIcon(h)));this.$editor.html(f);a.hide().after(this.$editor);this.setup();this.$button.on("mousedown",function(){c.hasFocus&&(c.selection=g.saveSelection())})};l.prototype.onChange=function(){this.$textarea.val(this.val()).trigger("change")};l.prototype.insert=function(a){a=d(j.createIcon(a));a[0].attachEvent&&a[0].attachEvent("onresizestart",function(a){a.returnValue=!1},!1);this.$editor.trigger("focus"); this.selection&&g.restoreSelection(this.selection);try{g.replaceSelection(a[0])}catch(b){}this.onChange()};l.prototype.val=function(){for(var a=[],b=[],c=function(){a.push(b.join(""));b=[]},f=function(a){if(3===a.nodeType)b.push(a.nodeValue);else if(1===a.nodeType){var d=a.tagName.toLowerCase(),e=-1!==p.indexOf(d);e&&b.length&&c();if("img"===d)(e=a.getAttribute("alt")||"")&&b.push(e);else{"br"===d&&c();a=a.childNodes;for(d=0;d");this.$menu.addClass("emoji-menu");this.$menu.hide();this.$items=d("
").appendTo(this.$menu);b.append(this.$menu);b.on("keydown",function(b){(27===b.keyCode||9===b.keyCode)&&a.hide()});b.on("mouseup",function(){a.hide()});c.on("resize",function(){a.visible&&a.reposition()});this.$menu.on("mouseup", "a",function(a){a.stopPropagation();return!1});this.$menu.on("click","a",function(b){var c=d(".label",d(this)).text();i.setTimeout(function(){a.onItemSelected.apply(a,[c])},0);b.stopPropagation();return!1});this.load()};h.prototype.onItemSelected=function(a){this.emojiarea.insert(a);this.hide()};h.prototype.load=function(){var a=[],b=d.emojiarea.icons,c=d.emojiarea.path;c.length&&c.charAt(c.length-1);for(var e in b)b.hasOwnProperty(e)&&a.push(''+j.createIcon(e)+''+g.htmlEntities(e)+"");this.$items.html(a.join(""))};h.prototype.reposition=function(){var a=this.emojiarea.$button,b=a.offset();b.top+=a.outerHeight();b.left+=Math.round(a.outerWidth()/2);this.$menu.css({top:b.top,left:b.left})};h.prototype.hide=function(){this.emojiarea&&(this.emojiarea.menu=null,this.emojiarea.$button.removeClass("on"),this.emojiarea=null);this.visible=!1;this.$menu.hide()};h.prototype.show=function(a){this.emojiarea&&this.emojiarea=== a||(this.emojiarea=a,this.emojiarea.menu=this,this.reposition(),this.$menu.show(),this.visible=!0)};var n=null;h.show=function(a){n=n||new h;n.show(a)}})(jQuery,window,document);