From 1450d17fb44324e3637f1598ec36c09e17598510 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 22 Apr 2014 16:48:02 +0800 Subject: [PATCH] MDL-44855 AJAX: Arrays and Objects should be defined in the initializer JavaScript is a prototypal language and complex types should be defined as null in the prototype, and set up in the initializer instead. --- .../moodle-core-notification-debug.js | 18 ++++++++++-------- .../moodle-core-notification-min.js | 4 ++-- .../moodle-core-notification.js | 18 ++++++++++-------- lib/yui/src/notification/js/notification.js | 18 ++++++++++-------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js b/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js index 929df2e7a3e..eb6dbef2744 100644 --- a/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js +++ b/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js @@ -158,8 +158,9 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -171,7 +172,7 @@ Y.extend(ALERT, DIALOGUE, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -179,13 +180,13 @@ Y.extend(ALERT, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function() { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); @@ -219,8 +220,9 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -237,7 +239,7 @@ Y.extend(CONFIRM, DIALOGUE, { + this.get(TITLE) + '', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:27', this, false), yes.on('click', this.submit, this, true), no.on('click', this.submit, this, false) @@ -246,13 +248,13 @@ Y.extend(CONFIRM, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function(e, outcome) { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes'); diff --git a/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js b/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js index 25aae951a96..447093cdbcd 100644 --- a/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js +++ b/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-core-notification",function(e,t){var n="Moodle dialogue",r="moodle-dialogue",i="Moodle confirmation dialogue",s="Moodle exception",o="Moodle AJAX exception",u="Moodle alert",a="notificationBase",f="yesLabel",l="noLabel",c="title",h="question",p={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"},d,v,m,g,y;y=function(t){t.count=e.stamp(this);var n="moodle-dialogue-"+t.count;t.notificationBase=e.Node.create('
').append(e.Node.create('').append(e.Node.create('
')).append(e.Node.create('
')).append(e.Node.create('
'))),e.one(document.body).append(t.notificationBase),t.srcNode="#"+n,t.width=t.width||"400px",t.visible=t.visible||!1,t.center=t.centered||!0,t.centered=!1,t.lightbox!==!1&&(t.modal=!0),delete t.lightbox,t.closeButton===!1?t.buttons=null:t.buttons=[{section:e.WidgetStdMod.HEADER,classNames:"closebutton",action:function(){this.hide()}}],y.superclass.constructor.apply(this,[t]),t.closeButton!==!1&&this.get("buttons").header[0].setAttribute("title",this.get("closeButtonTitle"))},e.extend(y,e.Panel,{initializer:function(){this.after("visibleChange",this.visibilityChanged,this),this.render(),this.show(),this.get("boundingBox").setStyle("zIndex",null)},visibilityChanged:function(t){var n;t.attrName==="visible"&&(this.get("maskNode").addClass(p.LIGHTBOX),this.get("center")&&!t.prevVal&&t.newVal&&this.centerDialogue(),this.get("draggable")&&(n="#"+this.get("id")+" ."+p.HEADER,this.plug(e.Plugin.Drag,{handles:[n]}),e.one(n).setStyle("cursor","move")))},hide:function(e){if(e&&e.type==="key"&&e.keyCode===27&&!this.get("focused"))return;return y.superclass.hide.call(this,arguments)},centerDialogue:function(){var t=this.get("boundingBox"),n=t.hasClass(r+"-hidden"),i,s;n&&t.setStyle("top","-1000px").removeClass(r+"-hidden"),i=Math.max(Math.round((t.get("winWidth")-t.get("offsetWidth"))/2),15),s=Math.max(Math.round((t.get("winHeight")-t.get("offsetHeight"))/2),15)+e.one(window).get("scrollTop"),n&&t.addClass(r+"-hidden"),t.setStyle("left",i).setStyle("top",s)}},{NAME:n,CSS_PREFIX:r,ATTRS:{notificationBase:{},lightbox:{validator:e.Lang.isBoolean,value:!0},closeButton:{validator:e.Lang.isBoolean,value:!0},closeButtonTitle:{validator:e.Lang.isString,value:"Close"},center:{validator:e.Lang.isBoolean,value:!0},draggable:{validator:e.Lang.isBoolean,value:!1},COUNT:{value:null}}}),v=function(e){e.closeButton=!1,v.superclass.constructor.apply(this,[e])},e.extend(v,y,{closeEvents:[],initializer:function(){this.publish("complete");var t=e.Node.create(''),n=e.Node.create('
').append(e.Node.create('
'+this.get("message")+"
")).append(e.Node.create('
').append(t));this.get(a).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(c)+"

",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(a).remove()},this),this.closeEvents.push(e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this));var r=this.get("boundingBox").one(".closebutton");r&&this.closeEvents.push(r.on("click",this.submit,this))},submit:function(){(new e.EventHandle(this.closeEvents)).detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:u,CSS_PREFIX:r,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=function(e){m.superclass.constructor.apply(this,[e])},e.extend(m,y,{closeEvents:[],initializer:function(){this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create(''),n=e.Node.create(''),r=e.Node.create('
').append(e.Node.create('
'+this.get(h)+"
")).append(e.Node.create('
').append(t).append(n));this.get(a).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,r,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(c)+"

",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(a).remove()},this),this.closeEvents.push(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 i=this.get("boundingBox").one(".closebutton");i&&this.closeEvents.push(i.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:i,CSS_PREFIX:r,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(m,e.EventTarget),d=function(t){t.width=t.width||M.cfg.developerdebug?Math.floor(e.one(document.body).get("winWidth")/3)+"px":null,t.closeButton=!0,d.superclass.constructor.apply(this,[t])},e.extend(d,y,{_hideTimeout: -null,_keypress:null,initializer:function(t){var n,r=this,i=this.get("hideTimeoutDelay");this.get(a).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+t.name+"

",e.WidgetStdMod.REPLACE),n=e.Node.create('
').append(e.Node.create('
'+this.get("message")+"
")).append(e.Node.create('")).append(e.Node.create('")).append(e.Node.create('")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),i&&(this._hideTimeout=setTimeout(function(){r.hide()},i)),this.after("visibleChange",this.visibilityChanged,this),this.after("destroyedChange",function(){this.get(a).remove()},this),this._keypress=e.on("key",this.hide,window,"down:13,27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){this._keypress&&this._keypress.detach();var t=this;setTimeout(function(){t.destroy()},1e3)}}},{NAME:s,CSS_PREFIX:r,ATTRS:{message:{value:""},name:{value:""},fileName:{value:""},lineNumber:{value:""},stack:{setter:function(e){var t=e.split("\n"),n=new RegExp("^(.+)@("+M.cfg.wwwroot+")?(.{0,75}).*:(\\d+)$"),r;for(r in t)t[r]=t[r].replace(n,"
ln: $4
$3
$1
");return t.join("")},value:""},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),g=function(e){e.name=e.name||"Error",e.closeButton=!0,g.superclass.constructor.apply(this,[e])},e.extend(g,y,{_keypress:null,initializer:function(t){var n,r=this,i=this.get("hideTimeoutDelay");this.get(a).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+t.name+"

",e.WidgetStdMod.REPLACE),n=e.Node.create('
').append(e.Node.create('
'+this.get("error")+"
")).append(e.Node.create('")).append(e.Node.create('")).append(e.Node.create('")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),i&&(this._hideTimeout=setTimeout(function(){r.hide()},i)),this.after("visibleChange",this.visibilityChanged,this),this._keypress=e.on("key",this.hide,window,"down:13, 27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){var t=this;this._keypress.detach(),setTimeout(function(){t.destroy()},1e3)}}},{NAME:o,CSS_PREFIX:r,ATTRS:{error:{validator:e.Lang.isString,value:"Unknown error"},debuginfo:{value:null},stacktrace:{value:null},reproductionlink:{setter:function(e){return e!==null&&(e=''+e.replace(M.cfg.wwwroot,"")+""),e},value:null},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),M.core=M.core||{},M.core.dialogue=y,M.core.alert=v,M.core.confirm=m,M.core.exception=d,M.core.ajaxException=g},"@VERSION@",{requires:["base","node","panel","event-key","dd-plugin"]}); +YUI.add("moodle-core-notification",function(e,t){var n="Moodle dialogue",r="moodle-dialogue",i="Moodle confirmation dialogue",s="Moodle exception",o="Moodle AJAX exception",u="Moodle alert",a="notificationBase",f="yesLabel",l="noLabel",c="title",h="question",p={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"},d,v,m,g,y;y=function(t){t.count=e.stamp(this);var n="moodle-dialogue-"+t.count;t.notificationBase=e.Node.create('
').append(e.Node.create('').append(e.Node.create('
')).append(e.Node.create('
')).append(e.Node.create('
'))),e.one(document.body).append(t.notificationBase),t.srcNode="#"+n,t.width=t.width||"400px",t.visible=t.visible||!1,t.center=t.centered||!0,t.centered=!1,t.lightbox!==!1&&(t.modal=!0),delete t.lightbox,t.closeButton===!1?t.buttons=null:t.buttons=[{section:e.WidgetStdMod.HEADER,classNames:"closebutton",action:function(){this.hide()}}],y.superclass.constructor.apply(this,[t]),t.closeButton!==!1&&this.get("buttons").header[0].setAttribute("title",this.get("closeButtonTitle"))},e.extend(y,e.Panel,{initializer:function(){this.after("visibleChange",this.visibilityChanged,this),this.render(),this.show(),this.get("boundingBox").setStyle("zIndex",null)},visibilityChanged:function(t){var n;t.attrName==="visible"&&(this.get("maskNode").addClass(p.LIGHTBOX),this.get("center")&&!t.prevVal&&t.newVal&&this.centerDialogue(),this.get("draggable")&&(n="#"+this.get("id")+" ."+p.HEADER,this.plug(e.Plugin.Drag,{handles:[n]}),e.one(n).setStyle("cursor","move")))},hide:function(e){if(e&&e.type==="key"&&e.keyCode===27&&!this.get("focused"))return;return y.superclass.hide.call(this,arguments)},centerDialogue:function(){var t=this.get("boundingBox"),n=t.hasClass(r+"-hidden"),i,s;n&&t.setStyle("top","-1000px").removeClass(r+"-hidden"),i=Math.max(Math.round((t.get("winWidth")-t.get("offsetWidth"))/2),15),s=Math.max(Math.round((t.get("winHeight")-t.get("offsetHeight"))/2),15)+e.one(window).get("scrollTop"),n&&t.addClass(r+"-hidden"),t.setStyle("left",i).setStyle("top",s)}},{NAME:n,CSS_PREFIX:r,ATTRS:{notificationBase:{},lightbox:{validator:e.Lang.isBoolean,value:!0},closeButton:{validator:e.Lang.isBoolean,value:!0},closeButtonTitle:{validator:e.Lang.isString,value:"Close"},center:{validator:e.Lang.isBoolean,value:!0},draggable:{validator:e.Lang.isBoolean,value:!1},COUNT:{value:null}}}),v=function(e){e.closeButton=!1,v.superclass.constructor.apply(this,[e])},e.extend(v,y,{_closeEvents:null,initializer:function(){this._closeEvents=[],this.publish("complete");var t=e.Node.create(''),n=e.Node.create('
').append(e.Node.create('
'+this.get("message")+"
")).append(e.Node.create('
').append(t));this.get(a).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(c)+"

",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(a).remove()},this),this._closeEvents.push(e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this));var r=this.get("boundingBox").one(".closebutton");r&&this._closeEvents.push(r.on("click",this.submit,this))},submit:function(){(new e.EventHandle(this._closeEvents)).detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:u,CSS_PREFIX:r,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=function(e){m.superclass.constructor.apply(this,[e])},e.extend(m,y,{_closeEvents:null,initializer:function(){this._closeEvents=[],this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create(''),n=e.Node.create(''),r=e.Node.create('
').append(e.Node.create('
'+this.get(h)+"
")).append(e.Node.create('
').append(t).append(n));this.get(a).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,r,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(c)+"

",e.WidgetStdMod.REPLACE),this.after("destroyedChange",function(){this.get(a).remove()},this),this._closeEvents.push(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 i=this.get("boundingBox").one(".closebutton");i&&this._closeEvents.push(i.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:i,CSS_PREFIX:r,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(m,e.EventTarget),d=function(t){t.width=t.width||M.cfg.developerdebug?Math.floor(e.one(document.body).get("winWidth")/3)+"px":null,t.closeButton=!0,d.superclass.constructor +.apply(this,[t])},e.extend(d,y,{_hideTimeout:null,_keypress:null,initializer:function(t){var n,r=this,i=this.get("hideTimeoutDelay");this.get(a).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+t.name+"

",e.WidgetStdMod.REPLACE),n=e.Node.create('
').append(e.Node.create('
'+this.get("message")+"
")).append(e.Node.create('")).append(e.Node.create('")).append(e.Node.create('")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),i&&(this._hideTimeout=setTimeout(function(){r.hide()},i)),this.after("visibleChange",this.visibilityChanged,this),this.after("destroyedChange",function(){this.get(a).remove()},this),this._keypress=e.on("key",this.hide,window,"down:13,27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){this._keypress&&this._keypress.detach();var t=this;setTimeout(function(){t.destroy()},1e3)}}},{NAME:s,CSS_PREFIX:r,ATTRS:{message:{value:""},name:{value:""},fileName:{value:""},lineNumber:{value:""},stack:{setter:function(e){var t=e.split("\n"),n=new RegExp("^(.+)@("+M.cfg.wwwroot+")?(.{0,75}).*:(\\d+)$"),r;for(r in t)t[r]=t[r].replace(n,"
ln: $4
$3
$1
");return t.join("")},value:""},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),g=function(e){e.name=e.name||"Error",e.closeButton=!0,g.superclass.constructor.apply(this,[e])},e.extend(g,y,{_keypress:null,initializer:function(t){var n,r=this,i=this.get("hideTimeoutDelay");this.get(a).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+t.name+"

",e.WidgetStdMod.REPLACE),n=e.Node.create('
').append(e.Node.create('
'+this.get("error")+"
")).append(e.Node.create('")).append(e.Node.create('")).append(e.Node.create('")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),i&&(this._hideTimeout=setTimeout(function(){r.hide()},i)),this.after("visibleChange",this.visibilityChanged,this),this._keypress=e.on("key",this.hide,window,"down:13, 27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){var t=this;this._keypress.detach(),setTimeout(function(){t.destroy()},1e3)}}},{NAME:o,CSS_PREFIX:r,ATTRS:{error:{validator:e.Lang.isString,value:"Unknown error"},debuginfo:{value:null},stacktrace:{value:null},reproductionlink:{setter:function(e){return e!==null&&(e=''+e.replace(M.cfg.wwwroot,"")+""),e},value:null},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),M.core=M.core||{},M.core.dialogue=y,M.core.alert=v,M.core.confirm=m,M.core.exception=d,M.core.ajaxException=g},"@VERSION@",{requires:["base","node","panel","event-key","dd-plugin"]}); diff --git a/lib/yui/build/moodle-core-notification/moodle-core-notification.js b/lib/yui/build/moodle-core-notification/moodle-core-notification.js index 929df2e7a3e..eb6dbef2744 100644 --- a/lib/yui/build/moodle-core-notification/moodle-core-notification.js +++ b/lib/yui/build/moodle-core-notification/moodle-core-notification.js @@ -158,8 +158,9 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -171,7 +172,7 @@ Y.extend(ALERT, DIALOGUE, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -179,13 +180,13 @@ Y.extend(ALERT, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function() { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); @@ -219,8 +220,9 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -237,7 +239,7 @@ Y.extend(CONFIRM, DIALOGUE, { + this.get(TITLE) + '', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:27', this, false), yes.on('click', this.submit, this, true), no.on('click', this.submit, this, false) @@ -246,13 +248,13 @@ Y.extend(CONFIRM, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function(e, outcome) { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes'); diff --git a/lib/yui/src/notification/js/notification.js b/lib/yui/src/notification/js/notification.js index 26506271238..16c6708b2ae 100644 --- a/lib/yui/src/notification/js/notification.js +++ b/lib/yui/src/notification/js/notification.js @@ -156,8 +156,9 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -169,7 +170,7 @@ Y.extend(ALERT, DIALOGUE, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -177,13 +178,13 @@ Y.extend(ALERT, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function() { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); @@ -217,8 +218,9 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, DIALOGUE, { - closeEvents: [], + _closeEvents: null, initializer : function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -235,7 +237,7 @@ Y.extend(CONFIRM, DIALOGUE, { + this.get(TITLE) + '', Y.WidgetStdMod.REPLACE); this.after('destroyedChange', function(){this.get(BASE).remove();}, this); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:27', this, false), yes.on('click', this.submit, this, true), no.on('click', this.submit, this, false) @@ -244,13 +246,13 @@ Y.extend(CONFIRM, DIALOGUE, { var closeButton = this.get('boundingBox').one('.closebutton'); if (closeButton) { // The close button should act exactly like the 'No' button. - this.closeEvents.push( + this._closeEvents.push( closeButton.on('click', this.submit, this) ); } }, submit : function(e, outcome) { - new Y.EventHandle(this.closeEvents).detach(); + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes');