2 * A dialogue type designed to display an alert to the user.
4 * @module moodle-core-notification
5 * @submodule moodle-core-notification-alert
8 var ALERT_NAME = 'Moodle alert',
12 * Extends core Dialogue to show the alert dialogue.
14 * @param {Object} config Object literal specifying the dialogue configuration properties.
17 * @extends M.core.dialogue
19 ALERT = function(config) {
20 config.closeButton = false;
21 ALERT.superclass.constructor.apply(this, [config]);
23 Y.extend(ALERT, M.core.dialogue, {
25 initializer : function() {
26 this.publish('complete');
27 var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
28 content = Y.Node.create('<div class="confirmation-dialogue"></div>')
29 .append(Y.Node.create('<div class="confirmation-message">'+this.get('message')+'</div>'))
30 .append(Y.Node.create('<div class="confirmation-buttons"></div>')
32 this.get(BASE).addClass('moodle-dialogue-confirm');
33 this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
34 this.setStdModContent(Y.WidgetStdMod.HEADER,
35 '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
37 this.closeEvents.push(
38 Y.on('key', this.submit, window, 'down:13', this),
39 yes.on('click', this.submit, this)
42 var closeButton = this.get('boundingBox').one('.closebutton');
44 // The close button should act exactly like the 'No' button.
45 this.closeEvents.push(
46 closeButton.on('click', this.submit, this)
51 new Y.EventHandle(this.closeEvents).detach();
52 this.fire('complete');
58 CSS_PREFIX : DIALOGUE_PREFIX,
62 * The title of the alert.
69 validator : Y.Lang.isString,
74 * The message of the alert.
81 validator : Y.Lang.isString,
86 * The button text to use to accept the alert.
93 validator : Y.Lang.isString,
94 setter : function(txt) {
105 M.core.alert = ALERT;