(function(){tinymce.create("tinymce.plugins.MoodleEmoticon",{_emoticons:{},init:function(a,b){a.addCommand("mceMoodleEmoticon",function(){lang=a.getParam("language");a.windowManager.open({file:b+"/dialog.php?lang="+lang,width:250+parseInt(a.getLang("moodleemoticon.delta_width",0)),height:400+parseInt(a.getLang("moodleemoticon.delta_height",0)),inline:1},{plugin_url:b})});a.onInit.add(function(d){var e=d.getContent();this._emoticons=tinymce.util.JSON.parse(d.getParam("moodleemoticon_emoticons"));for(var c in this._emoticons){search=c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");search=new RegExp(search,"g");e=e.replace(search,this._emoticons[c])}d.setContent(e)});a.onPreProcess.add(function(c,d){if(d.save){tinymce.each(c.dom.select("img.emoticon",d.node),function(j){var h="";var i=/^emoticon emoticon-index-([0-9]+)$/.exec(j.className);if(i.length!=2){return true}var f=i[1];var g=new RegExp('class="emoticon emoticon-index-'.concat(f,'"'));for(var e in this._emoticons){if(g.test(this._emoticons[e])){h=e;
break}}if(h){c.dom.setOuterHTML(j,h)}},this)}});a.addButton("moodleemoticon",{title:"moodleemoticon.desc",cmd:"mceMoodleEmoticon",image:b+"/img/moodleemoticon.gif"})},createControl:function(b,a){return null},getInfo:function(){return{longname:"Moodle Emoticon plugin",author:"David Mudrak",authorurl:"http://mudrak.name",infourl:"http://moodle.org",version:"1.0"}}});tinymce.PluginManager.add("moodleemoticon",tinymce.plugins.MoodleEmoticon)})();