YUI.add("moodle-core-tooltip",function(a,e){function t(e){"undefined"==typeof(e=e||{}).draggable&&(e.draggable=!0),"undefined"==typeof e.constrain&&(e.constrain=!0),t.superclass.constructor.apply(this,[e])}var l=".closebutton",n="tooltiptext",o={pix:"i/loading_small",component:"moodle"},i={};t.NAME="moodle-core-tooltip",t.CSS_PREFIX="moodle-dialogue",(t.ATTRS=i).initialheadertext={value:""},i.initialbodytext={value:"",setter:function(e){var t,i;return t=a.Node.create("<div />").addClass(n),i=a.Node.create("<img />").setAttribute("src",M.util.image_url(o.pix,o.component)).addClass("spinner"),e?(t.set("text",e),i.addClass("iconsmall")):t.addClass("content-lightbox"),t.append(i),t}},i.initialfootertext={value:null,setter:function(e){if(e)return a.Node.create("<div />").set("text",e)}},i.headerhandler={value:"set_header_content"},i.bodyhandler={value:"set_body_content"},i.footerhandler={value:null},i.urlmodifier={value:null},i.textcache={value:null},i.textcachesize={value:10},a.extend(t,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[a.WidgetPositionAlign.TL,a.WidgetPositionAlign.RC],initializer:function(){return this.get("headerhandler")||this.set("headerhandler",this.set_header_content),this.get("bodyhandler")||this.set("bodyhandler",this.set_body_content),this.get("footerhandler")||this.set("footerhandler",function(){}),this.get("urlmodifier")||this.set("urlmodifier",this.modify_url),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.hide(),this.render(),this.bb=this.get("boundingBox"),this.bb.addClass("moodle-dialogue-tooltip"),window.right_to_left()&&(this.alignpoints=[a.WidgetPositionAlign.TR,a.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new a.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(e){var t,i,n,o,s;e.preventDefault(),this.cancel_events(),t=e.target.ancestor("a",!0),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.show(e),this.align(t,this.alignpoints),i=this.bb.delegate("click",this.close_panel,l,this),this.listenevents.push(i),i=a.one("body").on("key",this.close_panel,"esc",this),this.listenevents.push(i),i=this.bb.on("mousedownoutside",this.close_panel,this),this.listenevents.push(i),n=a.bind(this.get("urlmodifier"),this,t.get("href"))(),(s=this.get("textcache").retrieve(n))?this._set_panel_contents(s.response):(o={method:"get",context:this,sync:!1,on:{complete:function(e,t){this._set_panel_contents(t.responseText,n)}}},a.io(n,o))},_set_panel_contents:function(e,t){var i;try{if((i=a.JSON.parse(e)).error)return this.close_panel(),a.use("moodle-core-notification-ajaxexception",function(){return new M.core.ajaxException(i).show()}),this}catch(n){return this.close_panel(),a.use("moodle-core-notification-exception",function(){return new M.core.exception(n).show()}),this}a.bind(this.get("headerhandler"),this,i)(),a.bind(this.get("bodyhandler"),this,i)(),a.bind(this.get("footerhandler"),this,i)(),t&&this.get("textcache").add(t,e),this.get("buttons").header[0].focus()},set_header_content:function(e){this.set("headerContent",e.heading)},set_body_content:function(e){var t=a.Node.create("<div />").set("innerHTML",e.text).setAttribute("role","alert").addClass(n);this.set("bodyContent",t)},modify_url:function(e){return e.replace(/\.php\?/,"_ajax.php?")},close_panel:function(e){this.hide(e),this.cancel_events(),e&&e.preventDefault()},cancel_events:function(){for(;this.listenevents.length;)this.listenevents.shift().detach()}}),a.Base.modifyAttrs(t,{modal:{value:!1},focusOnPreviousTargetAfterHide:{value:!0}}),M.core=M.core||{},M.core.tooltip=M.core.tooltip=t},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification-dialogue","json-parse","widget-position","widget-position-align","event-outside","cache-base"]});