ACMS.Dispatch.emoditor=function(elm){var callback=function(toolbar,config){config.toolbar=toolbar;$.each({extraPlugins:"emoji",on:{toHtml:function(evt){evt.data.dataValue.forEach(function(node){if(typeof node.value!="undefined"){node.value=node.value.replace(/@acms_lt@acms_/g,"<");node.value=node.value.replace(/@acms_gt@acms_/g,">")}})},setData:function(evt){var Emoditor=CKEDITOR.plugins.registered.emoji;var emojiDir=ACMS.Config.emojiDir;var aryAlt=Emoditor.aryAlt;var aryEntity=Emoditor.aryEntity;
var aryUndefinedEntity=Emoditor.aryUndefinedEntity;var ptn=/&#x[a-f0-9]+;/i;if(evt.data.dataValue.match(ptn)){var result="";var alt="";var i=-1;var emoji,current;do{result+=RegExp.leftContext;emoji=RegExp.lastMatch;current=RegExp.rightContext;i=$.inArray(emoji,aryEntity);if(0<=i){alt=aryAlt[i];emoji=['@acms_lt@acms_img alt="',alt,'" src="',emojiDir,alt,'.gif"',' class="emoji"'," @acms_gt@acms_"].join("")}else{i=$.inArray(emoji,aryUndefinedEntity);if(0<=i){alt=emoji.replace("&","&amp;");emoji=['@acms_lt@acms_img alt="',
alt,'" src="',emojiDir,"-",'.gif"',' class="emoji undefined"'," @acms_gt@acms_"].join("")}}result+=emoji}while(current.match(/(&#x[a-f0-9]+;)/i));result+=current;evt.data.dataValue=result}},getData:function(evt){var Emoditor=CKEDITOR.plugins.registered.emoji;var emojiDir=ACMS.Config.emojiDir;var aryAlt=Emoditor.aryAlt;var aryEntity=Emoditor.aryEntity;var aryUndefinedEntity=Emoditor.aryUndefinedEntity;if("undefined"==typeof this._.data){var ptn=/&#x[a-f0-9]+;/i;if(evt.data.dataValue.match(ptn)){var result=
"";var alt="";var i=-1;var emoji,current;do{result+=RegExp.leftContext;emoji=RegExp.lastMatch;current=RegExp.rightContext;i=$.inArray(emoji,aryEntity);if(0<=i){alt=aryAlt[i];emoji=['<img alt="',alt,'" src="',emojiDir,alt,'.gif"',' class="emoji"'," />"].join("")}else{i=$.inArray(emoji,aryUndefinedEntity);if(0<=i){alt=emoji.replace("&","&amp;");emoji=['<img alt="',alt,'" src="',emojiDir,"-",'.gif"',' class="emoji undefined"'," />"].join("")}}result+=emoji}while(current.match(/(&#x[a-f0-9]+;)/i));result+=
current;evt.data.dataValue=result}}else{var $html=$($.parseHTML("<div>"+evt.data.dataValue.replace(/&/g,"&amp;")+"</div>"));$("img.emoji",$html).each(function(){if(0<=this.className.indexOf("undefined"))$(this).replaceWith(this.alt);else{var i=$.inArray(this.alt,aryAlt);if(0<=i)$(this).replaceWith(aryEntity[i].replace(/&/g,"&amp;"))}});evt.data.dataValue=$html.html().replace(/&amp;/g,"&")}}}},function(key){config[key]=this});if(0||"undefined"==typeof window["CKEDITOR"]||"undefined"==typeof CKEDITOR["instances"]||
"undefined"==typeof CKEDITOR.instances[elm.name]){var name=$(elm).attr("name"),editor=CKEDITOR.instances[name];if(editor){CKEDITOR.remove(editor);return null}$(elm).data("emoditor",CKEDITOR.replace($(elm).get(0),config));CKEDITOR.on("dialogDefinition",function(ev){var dialogName=ev.data.name;var dialogDefinition=ev.data.definition;if(dialogName=="table"){var infoTab=dialogDefinition.getContents("info");txtWidth=infoTab.get("txtWidth");txtWidth["default"]=""}});return $(elm).data("emoditor")}else return null};
var self=arguments.callee;if(typeof window["CKEDITOR"]!=="undefined"||self.loaded)callback(ACMS.Config.emoToolbar,ACMS.Config.emoConfig);else if(self.stack)self.stack.push(callback);else{ACMS.Dispatch._ckeditorPre();self.stack=[callback];(new ACMS.SyncLoader).next(ACMS.Config.jsRoot+"library/ckeditor/ckeditor.js").load(function(){ACMS.Dispatch._ckeditorPost();self.loaded=true;while(self.stack.length)self.stack.shift()(ACMS.Config.emoToolbar,ACMS.Config.emoConfig)})}};
