//>>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,e,f,h){b.experimental("dojox.editor.plugins.Smiley");var g=b.declare("dojox.editor.plugins.Smiley",h,{iconClassPrefix:"dijitAdditionalEditorIcon",emoticonMarker:"[]",emoticonImageClass:"dojoEditorEmoticon",_initButton:function(){this.dropDown=
new f.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 e.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 d=b.hitch(this,function(){var c=this.editor;setTimeout(function(){c.editNode&&(b.style(c.editNode,"opacity","0.99"),setTimeout(function(){c.editNode&&
b.style(c.editNode,"opacity","")},0))},0);return!0});this.editor.onLoadDeferred.addCallback(b.hitch(this,function(){this.editor.addKeyHandler(b.keys.DELETE,!1,!1,d);this.editor.addKeyHandler(b.keys.BACKSPACE,!1,!1,d)}))}},_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,d){var c=f.editor.plugins.Emoticon.fromAscii(d);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(e._scopeName+".Editor.getPlugin",null,function(a){a.plugin||"smiley"!==a.args.name||(a.plugin=new g)});return g});