1
YUI.add('moodle-core-notification-alert', function (Y, NAME) {
11
DIALOGUE_PREFIX = 'moodle-dialogue',
12
BASE = 'notificationBase',
13
CONFIRMYES = 'yesLabel',
14
CONFIRMNO = 'noLabel',
16
QUESTION = 'question',
18
BASE : 'moodle-dialogue-base',
19
WRAP : 'moodle-dialogue-wrap',
20
HEADER : 'moodle-dialogue-hd',
21
BODY : 'moodle-dialogue-bd',
22
CONTENT : 'moodle-dialogue-content',
23
FOOTER : 'moodle-dialogue-ft',
25
LIGHTBOX : 'moodle-dialogue-lightbox'
28
// Set up the namespace once.
29
M.core = M.core || {};
31
* A dialogue type designed to display an alert to the user.
33
* @module moodle-core-notification
34
* @submodule moodle-core-notification-alert
37
var ALERT_NAME = 'Moodle alert',
41
* Extends core Dialogue to show the alert dialogue.
43
* @param {Object} config Object literal specifying the dialogue configuration properties.
46
* @extends M.core.dialogue
48
ALERT = function(config) {
49
config.closeButton = false;
50
ALERT.superclass.constructor.apply(this, [config]);
52
Y.extend(ALERT, M.core.dialogue, {
54
* The list of events to detach when destroying this dialogue.
56
* @property _closeEvents
61
initializer : function() {
62
this._closeEvents = [];
63
this.publish('complete');
64
var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
65
content = Y.Node.create('<div class="confirmation-dialogue"></div>')
66
.append(Y.Node.create('<div class="confirmation-message">'+this.get('message')+'</div>'))
67
.append(Y.Node.create('<div class="confirmation-buttons"></div>')
69
this.get(BASE).addClass('moodle-dialogue-confirm');
70
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
71
this.setStdModContent(Y.WidgetStdMod.HEADER,
72
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
73
this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
74
this._closeEvents.push(
75
Y.on('key', this.submit, window, 'down:13', this),
76
yes.on('click', this.submit, this)
79
var closeButton = this.get('boundingBox').one('.closebutton');
81
// The close button should act exactly like the 'No' button.
82
this._closeEvents.push(
83
closeButton.on('click', this.submit, this)
88
new Y.EventHandle(this._closeEvents).detach();
89
this.fire('complete');
95
CSS_PREFIX : DIALOGUE_PREFIX,
99
* The title of the alert.
106
validator : Y.Lang.isString,
111
* The message of the alert.
118
validator : Y.Lang.isString,
123
* The button text to use to accept the alert.
125
* @attribute yesLabel
130
validator : Y.Lang.isString,
131
setter : function(txt) {
142
M.core.alert = ALERT;
145
}, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]});