//>>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,d,c,e){b.experimental("dojox.editor.plugins.Smiley");b.declare("dojox.editor.plugins.Smiley",e,{iconClassPrefix:"dijitAdditionalEditorIcon",emoticonMarker:"[]",emoticonImageClass:"dojoEditorEmoticon",_initButton:function(){this.dropDown=
new c.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 d.form.DropDownButton({label:this.i18n.smiley,showLabel:!1,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"Smiley",tabIndex:"-1",dropDown:this.dropDown});this.emoticonImageRegexp=
RegExp("class=(\"|')"+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 c=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,c);this.editor.addKeyHandler(b.keys.BACKSPACE,!1,!1,c)}))}},_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 d=c.editor.plugins.Emoticon.fromAscii(b);return d?d.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(d._scopeName+".Editor.getPlugin",null,function(a){if(!a.plugin&&"smiley"===a.args.name)a.plugin=new c.editor.plugins.Smiley});return c.editor.plugins.Smiley});