From f857b668f9ba13c8fa3c06dd4a699908f2b03e9e 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-alert-debug.js | 46 ++++++++++------- .../moodle-core-notification-alert-min.js | 2 +- .../moodle-core-notification-alert.js | 46 ++++++++++------- .../moodle-core-notification-confirm-debug.js | 50 +++++++++++-------- .../moodle-core-notification-confirm-min.js | 2 +- .../moodle-core-notification-confirm.js | 50 +++++++++++-------- lib/yui/src/notification/js/alert.js | 46 ++++++++++------- lib/yui/src/notification/js/confirm.js | 50 +++++++++++-------- 8 files changed, 170 insertions(+), 122 deletions(-) diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js index 63429cbbc91..083319b7b90 100644 --- a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js +++ b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js @@ -50,8 +50,16 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -63,7 +71,7 @@ Y.extend(ALERT, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -71,21 +79,21 @@ Y.extend(ALERT, M.core.notification.info, { 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(); + submit: function() { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); } }, { - NAME : ALERT_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: ALERT_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The title of the alert. @@ -94,9 +102,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Alert' */ - title : { - validator : Y.Lang.isString, - value : 'Alert' + title: { + validator: Y.Lang.isString, + value: 'Alert' }, /** @@ -106,9 +114,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Confirm' */ - message : { - validator : Y.Lang.isString, - value : 'Confirm' + message: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -118,15 +126,15 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Ok' */ - yesLabel : { - validator : Y.Lang.isString, - setter : function(txt) { + yesLabel: { + validator: Y.Lang.isString, + setter: function(txt) { if (!txt) { txt = 'Ok'; } return txt; }, - value : 'Ok' + value: 'Ok' } } }); diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js index 9d72aea1471..da8228045ec 100644 --- a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js +++ b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js @@ -1 +1 @@ -YUI.add("moodle-core-notification-alert",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={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 f="Moodle alert",l;l=function(e){e.closeButton=!1,l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{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(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(o)+"

",e.WidgetStdMod.REPLACE),this.closeEvents.push(e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this));var s=this.get("boundingBox").one(".closebutton");s&&this.closeEvents.push(s.on("click",this.submit,this))},submit:function(){(new e.EventHandle(this.closeEvents)).detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:f,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=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]}); +YUI.add("moodle-core-notification-alert",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={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 f="Moodle alert",l;l=function(e){e.closeButton=!1,l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_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(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(o)+"

",e.WidgetStdMod.REPLACE),this._closeEvents.push(e.on("key",this.submit,window,"down:13",this),t.on("click",this.submit,this));var s=this.get("boundingBox").one(".closebutton");s&&this._closeEvents.push(s.on("click",this.submit,this))},submit:function(){(new e.EventHandle(this._closeEvents)).detach(),this.fire("complete"),this.hide(),this.destroy()}},{NAME:f,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=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]}); diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js index 63429cbbc91..083319b7b90 100644 --- a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js +++ b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js @@ -50,8 +50,16 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -63,7 +71,7 @@ Y.extend(ALERT, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -71,21 +79,21 @@ Y.extend(ALERT, M.core.notification.info, { 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(); + submit: function() { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); } }, { - NAME : ALERT_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: ALERT_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The title of the alert. @@ -94,9 +102,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Alert' */ - title : { - validator : Y.Lang.isString, - value : 'Alert' + title: { + validator: Y.Lang.isString, + value: 'Alert' }, /** @@ -106,9 +114,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Confirm' */ - message : { - validator : Y.Lang.isString, - value : 'Confirm' + message: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -118,15 +126,15 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Ok' */ - yesLabel : { - validator : Y.Lang.isString, - setter : function(txt) { + yesLabel: { + validator: Y.Lang.isString, + setter: function(txt) { if (!txt) { txt = 'Ok'; } return txt; }, - value : 'Ok' + value: 'Ok' } } }); diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js index aa02af35f71..d3da1762333 100644 --- a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js +++ b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js @@ -49,8 +49,16 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -66,7 +74,7 @@ Y.extend(CONFIRM, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - 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) @@ -75,13 +83,13 @@ Y.extend(CONFIRM, M.core.notification.info, { 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(); + submit: function(e, outcome) { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes'); @@ -92,9 +100,9 @@ Y.extend(CONFIRM, M.core.notification.info, { this.destroy(); } }, { - NAME : CONFIRM_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: CONFIRM_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The button text to use to accept the confirmation. @@ -103,9 +111,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Yes' */ - yesLabel : { - validator : Y.Lang.isString, - value : 'Yes' + yesLabel: { + validator: Y.Lang.isString, + value: 'Yes' }, /** @@ -115,9 +123,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'No' */ - noLabel : { - validator : Y.Lang.isString, - value : 'No' + noLabel: { + validator: Y.Lang.isString, + value: 'No' }, /** @@ -127,9 +135,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Confirm' */ - title : { - validator : Y.Lang.isString, - value : 'Confirm' + title: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -139,9 +147,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Are you sure?' */ - question : { - validator : Y.Lang.isString, - value : 'Are you sure?' + question: { + validator: Y.Lang.isString, + value: 'Are you sure?' } } }); diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js index e2ebeef329a..13d960ea1c7 100644 --- a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js +++ b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js @@ -1 +1 @@ -YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={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 f="Moodle confirmation dialogue",l;l=function(e){l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{closeEvents:[],initializer:function(){this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create(''),n=e.Node.create(''),a=e.Node.create('
').append(e.Node.create('
'+this.get(u)+"
")).append(e.Node.create('
').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,a,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(o)+"

",e.WidgetStdMod.REPLACE),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 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:f,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(l,e.EventTarget),M.core.confirm=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]}); +YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={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 f="Moodle confirmation dialogue",l;l=function(e){l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_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(''),a=e.Node.create('
').append(e.Node.create('
'+this.get(u)+"
")).append(e.Node.create('
').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,a,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'

'+this.get(o)+"

",e.WidgetStdMod.REPLACE),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 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:f,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(l,e.EventTarget),M.core.confirm=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]}); diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js index aa02af35f71..d3da1762333 100644 --- a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js +++ b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js @@ -49,8 +49,16 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -66,7 +74,7 @@ Y.extend(CONFIRM, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - 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) @@ -75,13 +83,13 @@ Y.extend(CONFIRM, M.core.notification.info, { 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(); + submit: function(e, outcome) { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes'); @@ -92,9 +100,9 @@ Y.extend(CONFIRM, M.core.notification.info, { this.destroy(); } }, { - NAME : CONFIRM_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: CONFIRM_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The button text to use to accept the confirmation. @@ -103,9 +111,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Yes' */ - yesLabel : { - validator : Y.Lang.isString, - value : 'Yes' + yesLabel: { + validator: Y.Lang.isString, + value: 'Yes' }, /** @@ -115,9 +123,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'No' */ - noLabel : { - validator : Y.Lang.isString, - value : 'No' + noLabel: { + validator: Y.Lang.isString, + value: 'No' }, /** @@ -127,9 +135,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Confirm' */ - title : { - validator : Y.Lang.isString, - value : 'Confirm' + title: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -139,9 +147,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Are you sure?' */ - question : { - validator : Y.Lang.isString, - value : 'Are you sure?' + question: { + validator: Y.Lang.isString, + value: 'Are you sure?' } } }); diff --git a/lib/yui/src/notification/js/alert.js b/lib/yui/src/notification/js/alert.js index e80096a0ae1..29c1aaa185b 100644 --- a/lib/yui/src/notification/js/alert.js +++ b/lib/yui/src/notification/js/alert.js @@ -21,8 +21,16 @@ ALERT = function(config) { ALERT.superclass.constructor.apply(this, [config]); }; Y.extend(ALERT, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); var yes = Y.Node.create(''), content = Y.Node.create('
') @@ -34,7 +42,7 @@ Y.extend(ALERT, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - this.closeEvents.push( + this._closeEvents.push( Y.on('key', this.submit, window, 'down:13', this), yes.on('click', this.submit, this) ); @@ -42,21 +50,21 @@ Y.extend(ALERT, M.core.notification.info, { 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(); + submit: function() { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete'); this.hide(); this.destroy(); } }, { - NAME : ALERT_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: ALERT_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The title of the alert. @@ -65,9 +73,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Alert' */ - title : { - validator : Y.Lang.isString, - value : 'Alert' + title: { + validator: Y.Lang.isString, + value: 'Alert' }, /** @@ -77,9 +85,9 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Confirm' */ - message : { - validator : Y.Lang.isString, - value : 'Confirm' + message: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -89,15 +97,15 @@ Y.extend(ALERT, M.core.notification.info, { * @type String * @default 'Ok' */ - yesLabel : { - validator : Y.Lang.isString, - setter : function(txt) { + yesLabel: { + validator: Y.Lang.isString, + setter: function(txt) { if (!txt) { txt = 'Ok'; } return txt; }, - value : 'Ok' + value: 'Ok' } } }); diff --git a/lib/yui/src/notification/js/confirm.js b/lib/yui/src/notification/js/confirm.js index 9b51d50743a..6cc6f948155 100644 --- a/lib/yui/src/notification/js/confirm.js +++ b/lib/yui/src/notification/js/confirm.js @@ -20,8 +20,16 @@ CONFIRM = function(config) { CONFIRM.superclass.constructor.apply(this, [config]); }; Y.extend(CONFIRM, M.core.notification.info, { - closeEvents: [], - initializer : function() { + /** + * The list of events to detach when destroying this dialogue. + * + * @property _closeEvents + * @type EventHandle[] + * @private + */ + _closeEvents: null, + initializer: function() { + this._closeEvents = []; this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); @@ -37,7 +45,7 @@ Y.extend(CONFIRM, M.core.notification.info, { this.setStdModContent(Y.WidgetStdMod.HEADER, '

' + this.get(TITLE) + '

', Y.WidgetStdMod.REPLACE); - 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) @@ -46,13 +54,13 @@ Y.extend(CONFIRM, M.core.notification.info, { 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(); + submit: function(e, outcome) { + new Y.EventHandle(this._closeEvents).detach(); this.fire('complete', outcome); if (outcome) { this.fire('complete-yes'); @@ -63,9 +71,9 @@ Y.extend(CONFIRM, M.core.notification.info, { this.destroy(); } }, { - NAME : CONFIRM_NAME, - CSS_PREFIX : DIALOGUE_PREFIX, - ATTRS : { + NAME: CONFIRM_NAME, + CSS_PREFIX: DIALOGUE_PREFIX, + ATTRS: { /** * The button text to use to accept the confirmation. @@ -74,9 +82,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Yes' */ - yesLabel : { - validator : Y.Lang.isString, - value : 'Yes' + yesLabel: { + validator: Y.Lang.isString, + value: 'Yes' }, /** @@ -86,9 +94,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'No' */ - noLabel : { - validator : Y.Lang.isString, - value : 'No' + noLabel: { + validator: Y.Lang.isString, + value: 'No' }, /** @@ -98,9 +106,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Confirm' */ - title : { - validator : Y.Lang.isString, - value : 'Confirm' + title: { + validator: Y.Lang.isString, + value: 'Confirm' }, /** @@ -110,9 +118,9 @@ Y.extend(CONFIRM, M.core.notification.info, { * @type String * @default 'Are you sure?' */ - question : { - validator : Y.Lang.isString, - value : 'Are you sure?' + question: { + validator: Y.Lang.isString, + value: 'Are you sure?' } } });