mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-43885 Javascript: Make the [X] button work like 'No' in relevant dialogues
The [X] button on the dialogue is another form of the 'No' button and should behave as such. In some dialogues this matters more than others because the dialogue is destroyed.
This commit is contained in:
parent
9788e26805
commit
649c80e6a4
8 changed files with 95 additions and 38 deletions
|
@ -52,7 +52,7 @@ ALERT = function(config) {
|
||||||
ALERT.superclass.constructor.apply(this, [config]);
|
ALERT.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(ALERT, M.core.dialogue, {
|
Y.extend(ALERT, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
||||||
|
@ -65,11 +65,21 @@ Y.extend(ALERT, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this);
|
Y.on('key', this.submit, window, 'down:13', this),
|
||||||
|
yes.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function() {
|
submit : function() {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this.fire('complete');
|
this.fire('complete');
|
||||||
this.hide();
|
this.hide();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
YUI.add("moodle-core-notification-alert",function(e,t){var n,r,i,s,o,u,a,f;n="moodle-dialogue",r="notificationBase",i=0,s="yesLabel",o="noLabel",u="title",a="question",f={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var l="Moodle alert",c;c=function(e){e.closeButton=!1,c.superclass.constructor.apply(this,[e])},e.extend(c,M.core.dialogue,{_enterKeypress:null,initializer:function(){this.publish("complete");var t=e.Node.create('<input type="button" id="id_yuialertconfirm-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),n=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get("message")+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(u)+"</h1>",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(r).remove()},this),this._enterKeypress=e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this)},submit:function(){this._enterKeypress.detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:l,CSS_PREFIX:n,ATTRS:{title:{validator:e.Lang.isString,value:"Alert"},message:{validator:e.Lang.isString,value:"Confirm"},yesLabel:{validator:e.Lang.isString,setter:function(e){return e||(e="Ok"),e},value:"Ok"}}}),M.core.alert=c},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
|
YUI.add("moodle-core-notification-alert",function(e,t){var n,r,i,s,o,u,a,f;n="moodle-dialogue",r="notificationBase",i=0,s="yesLabel",o="noLabel",u="title",a="question",f={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var l="Moodle alert",c;c=function(e){e.closeButton=!1,c.superclass.constructor.apply(this,[e])},e.extend(c,M.core.dialogue,{closeEvents:[],initializer:function(){this.publish("complete");var t=e.Node.create('<input type="button" id="id_yuialertconfirm-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),n=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get("message")+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(u)+"</h1>",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(r).remove()},this),this.closeEvents.push(e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this));var i=this.get("boundingBox").one(".closebutton");i&&this.closeEvents.push(i.on("click",this.submit,this))},submit:function(){(new e.EventHandle(this.closeEvents)).detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:l,CSS_PREFIX:n,ATTRS:{title:{validator:e.Lang.isString,value:"Alert"},message:{validator:e.Lang.isString,value:"Confirm"},yesLabel:{validator:e.Lang.isString,setter:function(e){return e||(e="Ok"),e},value:"Ok"}}}),M.core.alert=c},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
|
||||||
|
|
|
@ -52,7 +52,7 @@ ALERT = function(config) {
|
||||||
ALERT.superclass.constructor.apply(this, [config]);
|
ALERT.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(ALERT, M.core.dialogue, {
|
Y.extend(ALERT, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
||||||
|
@ -65,11 +65,21 @@ Y.extend(ALERT, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this);
|
Y.on('key', this.submit, window, 'down:13', this),
|
||||||
|
yes.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function() {
|
submit : function() {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this.fire('complete');
|
this.fire('complete');
|
||||||
this.hide();
|
this.hide();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
|
@ -51,8 +51,7 @@ CONFIRM = function(config) {
|
||||||
CONFIRM.superclass.constructor.apply(this, [config]);
|
CONFIRM.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(CONFIRM, M.core.dialogue, {
|
Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
_escKeypress : null,
|
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
this.publish('complete-yes');
|
this.publish('complete-yes');
|
||||||
|
@ -69,14 +68,24 @@ Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
|
|
||||||
this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this, true);
|
Y.on('key', this.submit, window, 'down:13', this, true),
|
||||||
no.on('click', this.submit, this, false);
|
Y.on('key', this.submit, window, 'down:27', this, false),
|
||||||
|
yes.on('click', this.submit, this, true),
|
||||||
|
no.on('click', this.submit, this, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function(e, outcome) {
|
submit : function(e, outcome) {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this._escKeypress.detach();
|
|
||||||
this.fire('complete', outcome);
|
this.fire('complete', outcome);
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
this.fire('complete-yes');
|
this.fire('complete-yes');
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a,f;n="moodle-dialogue",r="notificationBase",i=0,s="yesLabel",o="noLabel",u="title",a="question",f={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var l="Moodle confirmation dialogue",c;c=function(e){c.superclass.constructor.apply(this,[e])},e.extend(c,M.core.dialogue,{_enterKeypress:null,_escKeypress:null,initializer:function(){this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create('<input type="button" id="id_yuiconfirmyes-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),n=e.Node.create('<input type="button" id="id_yuiconfirmno-'+this.get("COUNT")+'" value="'+this.get(o)+'" />'),i=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get(a)+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,i,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(u)+"</h1>",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(r).remove()},this),this._enterKeypress=e.on("key",this.submit,window,"down:13",this,!0),this._escKeypress=e.on("key",this.submit,window,"down:27",this,!1),t.on("click",this.submit,this,!0),n.on("click",this.submit,this,!1)},submit:function(e,t){this._enterKeypress.detach(),this._escKeypress.detach(),this.fire("complete",t),t?this.fire("complete-yes"):this.fire("complete-no"),this.hide(),this.destroy()}},{NAME:l,CSS_PREFIX:n,ATTRS:{yesLabel:{validator:e.Lang.isString,value:"Yes"},noLabel:{validator:e.Lang.isString,value:"No"},title:{validator:e.Lang.isString,value:"Confirm"},question:{validator:e.Lang.isString,value:"Are you sure?"}}}),e.augment(c,e.EventTarget),M.core.confirm=c},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
|
YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a,f;n="moodle-dialogue",r="notificationBase",i=0,s="yesLabel",o="noLabel",u="title",a="question",f={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var l="Moodle confirmation dialogue",c;c=function(e){c.superclass.constructor.apply(this,[e])},e.extend(c,M.core.dialogue,{closeEvents:[],initializer:function(){this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create('<input type="button" id="id_yuiconfirmyes-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),n=e.Node.create('<input type="button" id="id_yuiconfirmno-'+this.get("COUNT")+'" value="'+this.get(o)+'" />'),i=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get(a)+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,i,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(u)+"</h1>",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(r).remove()},this),this.closeEvents.push(e.on("key",this.submit,window,"down:13",this,!0),e.on("key",this.submit,window,"down:27",this,!1),t.on("click",this.submit,this,!0),n.on("click",this.submit,this,!1));var f=this.get("boundingBox").one(".closebutton");f&&this.closeEvents.push(f.on("click",this.submit,this))},submit:function(t,n){(new e.EventHandle(this.closeEvents)).detach(),this.fire("complete",n),n?this.fire("complete-yes"):this.fire("complete-no"),this.hide(),this.destroy()}},{NAME:l,CSS_PREFIX:n,ATTRS:{yesLabel:{validator:e.Lang.isString,value:"Yes"},noLabel:{validator:e.Lang.isString,value:"No"},title:{validator:e.Lang.isString,value:"Confirm"},question:{validator:e.Lang.isString,value:"Are you sure?"}}}),e.augment(c,e.EventTarget),M.core.confirm=c},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
|
||||||
|
|
|
@ -51,8 +51,7 @@ CONFIRM = function(config) {
|
||||||
CONFIRM.superclass.constructor.apply(this, [config]);
|
CONFIRM.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(CONFIRM, M.core.dialogue, {
|
Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
_escKeypress : null,
|
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
this.publish('complete-yes');
|
this.publish('complete-yes');
|
||||||
|
@ -69,14 +68,24 @@ Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
|
|
||||||
this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this, true);
|
Y.on('key', this.submit, window, 'down:13', this, true),
|
||||||
no.on('click', this.submit, this, false);
|
Y.on('key', this.submit, window, 'down:27', this, false),
|
||||||
|
yes.on('click', this.submit, this, true),
|
||||||
|
no.on('click', this.submit, this, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function(e, outcome) {
|
submit : function(e, outcome) {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this._escKeypress.detach();
|
|
||||||
this.fire('complete', outcome);
|
this.fire('complete', outcome);
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
this.fire('complete-yes');
|
this.fire('complete-yes');
|
||||||
|
|
18
lib/yui/src/notification/js/alert.js
vendored
18
lib/yui/src/notification/js/alert.js
vendored
|
@ -21,7 +21,7 @@ ALERT = function(config) {
|
||||||
ALERT.superclass.constructor.apply(this, [config]);
|
ALERT.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(ALERT, M.core.dialogue, {
|
Y.extend(ALERT, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
|
||||||
|
@ -34,11 +34,21 @@ Y.extend(ALERT, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this);
|
Y.on('key', this.submit, window, 'down:13', this),
|
||||||
|
yes.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function() {
|
submit : function() {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this.fire('complete');
|
this.fire('complete');
|
||||||
this.hide();
|
this.hide();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
25
lib/yui/src/notification/js/confirm.js
vendored
25
lib/yui/src/notification/js/confirm.js
vendored
|
@ -20,8 +20,7 @@ CONFIRM = function(config) {
|
||||||
CONFIRM.superclass.constructor.apply(this, [config]);
|
CONFIRM.superclass.constructor.apply(this, [config]);
|
||||||
};
|
};
|
||||||
Y.extend(CONFIRM, M.core.dialogue, {
|
Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
_enterKeypress : null,
|
closeEvents: [],
|
||||||
_escKeypress : null,
|
|
||||||
initializer : function() {
|
initializer : function() {
|
||||||
this.publish('complete');
|
this.publish('complete');
|
||||||
this.publish('complete-yes');
|
this.publish('complete-yes');
|
||||||
|
@ -38,14 +37,24 @@ Y.extend(CONFIRM, M.core.dialogue, {
|
||||||
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
this.setStdModContent(Y.WidgetStdMod.HEADER,
|
||||||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
|
||||||
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
|
||||||
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
|
|
||||||
this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
|
this.closeEvents.push(
|
||||||
yes.on('click', this.submit, this, true);
|
Y.on('key', this.submit, window, 'down:13', this, true),
|
||||||
no.on('click', this.submit, this, false);
|
Y.on('key', this.submit, window, 'down:27', this, false),
|
||||||
|
yes.on('click', this.submit, this, true),
|
||||||
|
no.on('click', this.submit, this, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
var closeButton = this.get('boundingBox').one('.closebutton');
|
||||||
|
if (closeButton) {
|
||||||
|
// The close button should act exactly like the 'No' button.
|
||||||
|
this.closeEvents.push(
|
||||||
|
closeButton.on('click', this.submit, this)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit : function(e, outcome) {
|
submit : function(e, outcome) {
|
||||||
this._enterKeypress.detach();
|
new Y.EventHandle(this.closeEvents).detach();
|
||||||
this._escKeypress.detach();
|
|
||||||
this.fire('complete', outcome);
|
this.fire('complete', outcome);
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
this.fire('complete-yes');
|
this.fire('complete-yes');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue