YUI.add("moodle-core-tooltip",function(o,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 n=".closebutton",s="tooltiptext",a={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=o.Node.create("<div />").addClass(s),i=o.Node.create("<img />").setAttribute("src",M.util.image_url(a.pix,a.component)).addClass("spinner");return 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 o.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},o.extend(t,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[o.WidgetPositionAlign.TL,o.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=[o.WidgetPositionAlign.TR,o.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new o.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(e){var t,i;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),e=this.bb.delegate("click",this.close_panel,n,this),this.listenevents.push(e),e=o.one("body").on("key",this.close_panel,"esc",this),this.listenevents.push(e),e=this.bb.on("mousedownoutside",this.close_panel,this),this.listenevents.push(e),i=o.bind(this.get("urlmodifier"),this,t.get("href"))(),(e=this.get("textcache").retrieve(i))?this._set_panel_contents(e.response):o.io(i,{method:"get",context:this,sync:!1,on:{complete:function(e,t){this._set_panel_contents(t.responseText,i)}}})},_set_panel_contents:function(e,t){var i;try{if((i=o.JSON.parse(e)).error)return this.close_panel(),o.use("moodle-core-notification-ajaxexception",function(){return new M.core.ajaxException(i).show()}),this}catch(n){return this.close_panel(),o.use("moodle-core-notification-exception",function(){return new M.core.exception(n).show()}),this}o.bind(this.get("headerhandler"),this,i)(),o.bind(this.get("bodyhandler"),this,i)(),o.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){e=o.Node.create("<div />").set("innerHTML",e.text).setAttribute("role","alert").addClass(s);this.set("bodyContent",e)},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()}}),o.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"]});