//>>built
define("dojox/editor/plugins/Smiley","dojo dijit dojox dijit/_editor/_Plugin dijit/form/DropDownButton dojo/_base/connect dojo/_base/declare dojo/i18n dojox/editor/plugins/_SmileyPalette dojox/html/format dojo/i18n!dojox/editor/plugins/nls/Smiley".split(" "),function(b,c,d,g){b.experimental("dojox.editor.plugins.Smiley");var f=b.declare("dojox.editor.plugins.Smiley",g,{iconClassPrefix:"dijitAdditionalEditorIcon",emoticonMarker:"[]",emoticonImageClass:"dojoEditorEmoticon",_initButton:function(){this.dropDown=
new d.editor.plugins._SmileyPalette;this.connect(this.dropDown,"onChange",function(a){this.button.closeDropDown();this.editor.focus();a=this.emoticonMarker.charAt(0)+a+this.emoticonMarker.charAt(1);this.editor.execCommand("inserthtml",a)});this.i18n=b.i18n.getLocalization("dojox.editor.plugins","Smiley");this.button=new c.form.DropDownButton({label:this.i18n.smiley,showLabel:!1,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Smiley",tabIndex:"-1",dropDown:this.dropDown});this.emoticonImageRegexp=
new RegExp("class\x3d(\"|')"+this.emoticonImageClass+"(\"|')")},updateState:function(){this.button.set("disabled",this.get("disabled"))},setEditor:function(a){this.editor=a;this._initButton();this.editor.contentPreFilters.push(b.hitch(this,this._preFilterEntities));this.editor.contentPostFilters.push(b.hitch(this,this._postFilterEntities));if(b.isFF){var e=b.hitch(this,function(){var a=this.editor;setTimeout(function(){a.editNode&&(b.style(a.editNode,"opacity","0.99"),setTimeout(function(){a.editNode&&
b.style(a.editNode,"opacity","")},0))},0);return!0});this.editor.onLoadDeferred.addCallback(b.hitch(this,function(){this.editor.addKeyHandler(b.keys.DELETE,!1,!1,e);this.editor.addKeyHandler(b.keys.BACKSPACE,!1,!1,e)}))}},_preFilterEntities:function(a){return a.replace(/\[([^\]]*)\]/g,b.hitch(this,this._decode))},_postFilterEntities:function(a){return a.replace(/<img [^>]*>/gi,b.hitch(this,this._encode))},_decode:function(a,b){var c=d.editor.plugins.Emoticon.fromAscii(b);return c?c.imgHtml(this.emoticonImageClass):
a},_encode:function(a){return-1<a.search(this.emoticonImageRegexp)?this.emoticonMarker.charAt(0)+a.replace(/(<img [^>]*)alt="([^"]*)"([^>]*>)/,"$2")+this.emoticonMarker.charAt(1):a}});b.subscribe(c._scopeName+".Editor.getPlugin",null,function(a){a.plugin||"smiley"!==a.args.name||(a.plugin=new f)});return f});