mirror of
https://github.com/moodle/moodle.git
synced 2025-03-09 18:30:03 +01:00
MDL-43323 JavaScript: Lazily load exception dependencies for tooltip
Only load the exception-related dependencies for tooltip when required. In normal situations they should not be required at all.
This commit is contained in:
parent
edd9bb451c
commit
ce4da4612e
@ -379,11 +379,17 @@ Y.extend(TOOLTIP, M.core.dialogue, {
|
||||
responseobject = Y.JSON.parse(response);
|
||||
if (responseobject.error) {
|
||||
this.close_panel();
|
||||
return new M.core.ajaxException(responseobject);
|
||||
Y.use('moodle-core-notification-ajaxexception', function() {
|
||||
return new M.core.ajaxException(responseobject).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
} catch (error) {
|
||||
this.close_panel();
|
||||
return new M.core.exception(error);
|
||||
Y.use('moodle-core-notification-exception', function() {
|
||||
return new M.core.exception(error).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
// Set the contents using various handlers.
|
||||
@ -463,7 +469,7 @@ M.core.tooltip = M.core.tooltip = TOOLTIP;
|
||||
"base",
|
||||
"node",
|
||||
"io-base",
|
||||
"moodle-core-notification",
|
||||
"moodle-core-notification-dialogue",
|
||||
"json-parse",
|
||||
"widget-position",
|
||||
"widget-position-align",
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-core-tooltip",function(e,t){function n(e){e||(e={}),typeof e.draggable=="undefined"&&(e.draggable=!0),typeof e.constrain=="undefined"&&(e.constrain=!0),n.superclass.constructor.apply(this,[e])}var r={CLOSEBUTTON:".closebutton"},i={PANELTEXT:"tooltiptext"},s={WAITICON:{pix:"i/loading_small",component:"moodle"}},o={};n.NAME="moodle-core-tooltip",n.CSS_PREFIX="moodle-dialogue",n.ATTRS=o,o.initialheadertext={value:""},o.initialbodytext={value:"",setter:function(t){var n,r;return n=e.Node.create("<div />").addClass(i.PANELTEXT),r=e.Node.create("<img />").setAttribute("src",M.util.image_url(s.WAITICON.pix,s.WAITICON.component)).addClass("spinner"),t?(n.set("text",t),r.addClass("iconsmall")):n.addClass("content-lightbox"),n.append(r),n}},o.initialfootertext={value:null,setter:function(t){if(t)return e.Node.create("<div />").set("text",t)}},o.headerhandler={value:"set_header_content"},o.bodyhandler={value:"set_body_content"},o.footerhandler={value:null},o.urlmodifier={value:null},o.textcache={value:null},o.textcachesize={value:10},e.extend(n,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[e.WidgetPositionAlign.TL,e.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"),right_to_left()&&(this.alignpoints=[e.WidgetPositionAlign.TR,e.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new e.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(t){var n,i,s,o,u;t.preventDefault(),t.stopPropagation(),this.cancel_events(),n=t.target.ancestor("a",!0),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.show(),this.align(n,this.alignpoints),i=this.bb.delegate("click",this.close_panel,r.CLOSEBUTTON,this),this.listenevents.push(i),i=e.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),s=e.bind(this.get("urlmodifier"),this,n.get("href"))(),u=this.get("textcache").retrieve(s),u?this._set_panel_contents(u.response):(o={method:"get",context:this,sync:!1,on:{complete:function(e,t){this._set_panel_contents(t.responseText,s)}}},e.io(s,o))},_set_panel_contents:function(t,n){var r;try{r=e.JSON.parse(t);if(r.error)return this.close_panel(),new M.core.ajaxException(r)}catch(i){return this.close_panel(),new M.core.exception(i)}e.bind(this.get("headerhandler"),this,r)(),e.bind(this.get("bodyhandler"),this,r)(),e.bind(this.get("footerhandler"),this,r)(),n&&this.get("textcache").add(n,t),this.get("buttons").header[0].focus()},set_header_content:function(e){this.set("headerContent",e.heading)},set_body_content:function(t){var n=e.Node.create("<div />").set("innerHTML",t.text).setAttribute("role","alert").addClass(i.PANELTEXT);this.set("bodyContent",n)},modify_url:function(e){return e.replace(/\.php\?/,"_ajax.php?")},close_panel:function(e){this.hide(),this.cancel_events(),e&&e.preventDefault()},cancel_events:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()}}),e.Base.modifyAttrs(n,{modal:{value:!1}}),M.core=M.core||{},M.core.tooltip=M.core.tooltip=n},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification","json-parse","widget-position","widget-position-align","event-outside","cache-base"]});
|
||||
YUI.add("moodle-core-tooltip",function(e,t){function n(e){e||(e={}),typeof e.draggable=="undefined"&&(e.draggable=!0),typeof e.constrain=="undefined"&&(e.constrain=!0),n.superclass.constructor.apply(this,[e])}var r={CLOSEBUTTON:".closebutton"},i={PANELTEXT:"tooltiptext"},s={WAITICON:{pix:"i/loading_small",component:"moodle"}},o={};n.NAME="moodle-core-tooltip",n.CSS_PREFIX="moodle-dialogue",n.ATTRS=o,o.initialheadertext={value:""},o.initialbodytext={value:"",setter:function(t){var n,r;return n=e.Node.create("<div />").addClass(i.PANELTEXT),r=e.Node.create("<img />").setAttribute("src",M.util.image_url(s.WAITICON.pix,s.WAITICON.component)).addClass("spinner"),t?(n.set("text",t),r.addClass("iconsmall")):n.addClass("content-lightbox"),n.append(r),n}},o.initialfootertext={value:null,setter:function(t){if(t)return e.Node.create("<div />").set("text",t)}},o.headerhandler={value:"set_header_content"},o.bodyhandler={value:"set_body_content"},o.footerhandler={value:null},o.urlmodifier={value:null},o.textcache={value:null},o.textcachesize={value:10},e.extend(n,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[e.WidgetPositionAlign.TL,e.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"),right_to_left()&&(this.alignpoints=[e.WidgetPositionAlign.TR,e.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new e.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(t){var n,i,s,o,u;t.preventDefault(),t.stopPropagation(),this.cancel_events(),n=t.target.ancestor("a",!0),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.show(),this.align(n,this.alignpoints),i=this.bb.delegate("click",this.close_panel,r.CLOSEBUTTON,this),this.listenevents.push(i),i=e.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),s=e.bind(this.get("urlmodifier"),this,n.get("href"))(),u=this.get("textcache").retrieve(s),u?this._set_panel_contents(u.response):(o={method:"get",context:this,sync:!1,on:{complete:function(e,t){this._set_panel_contents(t.responseText,s)}}},e.io(s,o))},_set_panel_contents:function(t,n){var r;try{r=e.JSON.parse(t);if(r.error)return this.close_panel(),e.use("moodle-core-notification-ajaxexception",function(){return(new M.core.ajaxException(r)).show()}),this}catch(i){return this.close_panel(),e.use("moodle-core-notification-exception",function(){return(new M.core.exception(i)).show()}),this}e.bind(this.get("headerhandler"),this,r)(),e.bind(this.get("bodyhandler"),this,r)(),e.bind(this.get("footerhandler"),this,r)(),n&&this.get("textcache").add(n,t),this.get("buttons").header[0].focus()},set_header_content:function(e){this.set("headerContent",e.heading)},set_body_content:function(t){var n=e.Node.create("<div />").set("innerHTML",t.text).setAttribute("role","alert").addClass(i.PANELTEXT);this.set("bodyContent",n)},modify_url:function(e){return e.replace(/\.php\?/,"_ajax.php?")},close_panel:function(e){this.hide(),this.cancel_events(),e&&e.preventDefault()},cancel_events:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()}}),e.Base.modifyAttrs(n,{modal:{value:!1}}),M.core=M.core||{},M.core.tooltip=M.core.tooltip=n},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification-dialogue","json-parse","widget-position","widget-position-align","event-outside","cache-base"]});
|
||||
|
@ -379,11 +379,17 @@ Y.extend(TOOLTIP, M.core.dialogue, {
|
||||
responseobject = Y.JSON.parse(response);
|
||||
if (responseobject.error) {
|
||||
this.close_panel();
|
||||
return new M.core.ajaxException(responseobject);
|
||||
Y.use('moodle-core-notification-ajaxexception', function() {
|
||||
return new M.core.ajaxException(responseobject).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
} catch (error) {
|
||||
this.close_panel();
|
||||
return new M.core.exception(error);
|
||||
Y.use('moodle-core-notification-exception', function() {
|
||||
return new M.core.exception(error).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
// Set the contents using various handlers.
|
||||
@ -463,7 +469,7 @@ M.core.tooltip = M.core.tooltip = TOOLTIP;
|
||||
"base",
|
||||
"node",
|
||||
"io-base",
|
||||
"moodle-core-notification",
|
||||
"moodle-core-notification-dialogue",
|
||||
"json-parse",
|
||||
"widget-position",
|
||||
"widget-position-align",
|
||||
|
10
lib/yui/src/tooltip/js/tooltip.js
vendored
10
lib/yui/src/tooltip/js/tooltip.js
vendored
@ -377,11 +377,17 @@ Y.extend(TOOLTIP, M.core.dialogue, {
|
||||
responseobject = Y.JSON.parse(response);
|
||||
if (responseobject.error) {
|
||||
this.close_panel();
|
||||
return new M.core.ajaxException(responseobject);
|
||||
Y.use('moodle-core-notification-ajaxexception', function() {
|
||||
return new M.core.ajaxException(responseobject).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
} catch (error) {
|
||||
this.close_panel();
|
||||
return new M.core.exception(error);
|
||||
Y.use('moodle-core-notification-exception', function() {
|
||||
return new M.core.exception(error).show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
// Set the contents using various handlers.
|
||||
|
@ -4,7 +4,7 @@
|
||||
"base",
|
||||
"node",
|
||||
"io-base",
|
||||
"moodle-core-notification",
|
||||
"moodle-core-notification-dialogue",
|
||||
"json-parse",
|
||||
"widget-position",
|
||||
"widget-position-align",
|
||||
|
Loading…
x
Reference in New Issue
Block a user