YUI.add("moodle-atto_mediagallery-button",function(e,t){var n="atto_mediagallery",r={INPUTGALLERY:"atto_mediagallery_inputgallery"},i={INPUTGALLERY:".atto_mediagallery_inputgallery"},s='<form class="atto_form">{{get_string "select_desc" component}}<br/><br/>{{#if galleries}}<label for="{{elementid}}_atto_mediagallery_">{{get_string "gallery" component}}</label><select class="{{CSS.INPUTGALLERY}}" id="{{elementid}}_mediagallery_inputgallery">{{#each galleries}}<option value="{{id}}">{{text}}</option>{{/each}}</select><br/><div class="mdl-align"><br/><button type="submit" class="submit">{{get_string "insertgallery" component}}</button></div>{{else}}{{get_string "nogalleries" component}}{{/if}}</form>',o='<a href="{{galleryurl}}" class="filter_mediagallery"><img src="{{imageurl}}" title="{{text}}" alt="{{id}}" data-gallery="{{id}}"/></a>';e.namespace("M.atto_mediagallery").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.addButton({icon:"icon",iconComponent:"atto_mediagallery",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1||this._currentSelection.collapsed)return;var e=this.getDialogue({headerContent:M.util.get_string("pluginname",n),focusAfterHide:!0,focusOnShowSelector:i.INPUTGALLERY});e.set("bodyContent",this._getDialogueContent()),e.show()},_getDialogueContent:function(){var t=e.Handlebars.compile(s);return this._content=e.Node.create(t({component:n,galleries:this.get("galleries"),CSS:r})),this._content.one(".submit")&&this._content.one(".submit").on("click",this._insertmediagallery,this),this._content},_insertmediagallery:function(t){var n,r,i,s=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=this._content.one(".atto_mediagallery_inputgallery"),i=n.get("text"),r=n.get("value"),s.focus(),r!==""&&(template=e.Handlebars.compile(o),imagehtml=template({id:r,text:i,imageurl:M.cfg.wwwroot+"/mod/mediagallery/pix/icon.gif",galleryurl:M.cfg.wwwroot+"/mod/mediagallery/view.php?g="+r}),s.insertContentAtFocusPoint(imagehtml),this.markUpdated()),this.getDialogue({focusAfterHide:null}).hide()}},{ATTRS:{galleries:{value:[]}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
