YUI.add("moodle-atto_emoticon-button",function(e,t){var i={EMOTE:"atto_emoticon_emote",MAP:"atto_emoticon_map"},o=".atto_emoticon_emote";e.namespace("M.atto_emoticon").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,initializer:function(){this.addButton({icon:"e/emoticons",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection(),!1!==this._currentSelection&&this.getDialogue({headerContent:M.util.get_string("insertemoticon","atto_emoticon"),focusAfterHide:!0},!0).set("bodyContent",this._getDialogueContent()).show()},_insertEmote:function(t){var e=t.target.ancestor(o,!0),i=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),t=" "+e.getData("text")+" ",i.setSelection(this._currentSelection),i.insertContentAtFocusPoint(t),this.markUpdated()},_getDialogueContent:function(){var t=e.Handlebars.compile('<div class="{{CSS.MAP}}"><ul>{{#each emoticons}}<li><div><a href="#" class="{{../CSS.EMOTE}}" data-text="{{text}}"><img src="{{image_url imagename imagecomponent}}" alt="{{get_string altidentifier altcomponent}}"/></a></div><div>{{text}}</div><div>{{get_string altidentifier altcomponent}}</div></li>{{/each}}</ul></div>'),t=e.Node.create(t({emoticons:this.get("emoticons"),CSS:i}));return t.delegate("click",this._insertEmote,o,this),t.delegate("key",this._insertEmote,"32",o,this),t}},{ATTRS:{emoticons:{value:{}}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});