Merge branch 'MDL-43885-master' of git://github.com/andrewnicols/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 3 Feb 2014 23:41:00 +0000 (12:41 +1300)
committerSam Hemelryk <sam@moodle.com>
Mon, 3 Feb 2014 23:41:00 +0000 (12:41 +1300)
1  2 
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js
lib/yui/src/notification/js/alert.js
lib/yui/src/notification/js/confirm.js

@@@ -33,11 -33,22 +33,22 @@@ Y.extend(ALERT, M.core.dialogue, 
          this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
          this.setStdModContent(Y.WidgetStdMod.HEADER,
                  '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
-         this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
-         yes.on('click', this.submit, this);
 -        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
++
+         this.closeEvents.push(
+             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() {
-         this._enterKeypress.detach();
+         new Y.EventHandle(this.closeEvents).detach();
          this.fire('complete');
          this.hide();
          this.destroy();
@@@ -37,14 -36,25 +36,24 @@@ Y.extend(CONFIRM, M.core.dialogue, 
          this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
          this.setStdModContent(Y.WidgetStdMod.HEADER,
                  '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
-         this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
-         this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
-         yes.on('click', this.submit, this, true);
-         no.on('click', this.submit, this, false);
 -        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
+         this.closeEvents.push(
+             Y.on('key', this.submit, window, 'down:13', this, true),
+             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) {
-         this._enterKeypress.detach();
-         this._escKeypress.detach();
+         new Y.EventHandle(this.closeEvents).detach();
          this.fire('complete', outcome);
          if (outcome) {
              this.fire('complete-yes');