(function(){tinymce.create('tinymce.plugins.MoodleEmoticon',{_emoticons:{},init:function(h,i){h.addCommand('mceMoodleEmoticon',function(){lang=h.getParam('language');h.windowManager.open({file:i+'/dialog.php?lang='+lang,width:250+parseInt(h.getLang('moodleemoticon.delta_width',0)),height:400+parseInt(h.getLang('moodleemoticon.delta_height',0)),inline:1},{plugin_url:i})});h.onInit.add(function(a){var b=a.getContent();this._emoticons=tinymce.util.JSON.parse(a.getParam('moodleemoticon_emoticons'));for(var c in this._emoticons){search=c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,'\\$&');search=new RegExp(search,'g');b=b.replace(search,this._emoticons[c])}a.setContent(b)});h.onPreProcess.add(function(g,o){if(o.save){tinymce.each(g.dom.select('img.emoticon',o.node),function(a){var b='';var c=/^emoticon emoticon-index-([0-9]+)$/.exec(a.className);if(c.length!=2){return true}var d=c[1];var e=new RegExp('class="emoticon emoticon-index-'.concat(d,'"'));for(var f in this._emoticons){if(e.test(this._emoticons[f])){b=f;break}}if(b){g.dom.setOuterHTML(a,b)}},this)}});h.addButton('moodleemoticon',{title:'moodleemoticon.desc',cmd:'mceMoodleEmoticon',image:i+'/img/moodleemoticon.gif'})},createControl:function(n,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)})();
