MDL-52127 js: check YUI modules with eslint
[moodle.git] / lib / yui / build / moodle-core-notification-alert / moodle-core-notification-alert-debug.js
CommitLineData
78686995
AN
1YUI.add('moodle-core-notification-alert', function (Y, NAME) {
2
a1587268 3/* eslint-disable */
78686995
AN
4var DIALOGUE_PREFIX,
5 BASE,
78686995
AN
6 CONFIRMYES,
7 CONFIRMNO,
8 TITLE,
9 QUESTION,
10 CSS;
11
12DIALOGUE_PREFIX = 'moodle-dialogue',
13BASE = 'notificationBase',
78686995
AN
14CONFIRMYES = 'yesLabel',
15CONFIRMNO = 'noLabel',
16TITLE = 'title',
17QUESTION = 'question',
18CSS = {
19 BASE : 'moodle-dialogue-base',
20 WRAP : 'moodle-dialogue-wrap',
21 HEADER : 'moodle-dialogue-hd',
22 BODY : 'moodle-dialogue-bd',
23 CONTENT : 'moodle-dialogue-content',
24 FOOTER : 'moodle-dialogue-ft',
25 HIDDEN : 'hidden',
26 LIGHTBOX : 'moodle-dialogue-lightbox'
27};
28
29// Set up the namespace once.
30M.core = M.core || {};
31/**
32 * A dialogue type designed to display an alert to the user.
33 *
34 * @module moodle-core-notification
35 * @submodule moodle-core-notification-alert
36 */
37
38var ALERT_NAME = 'Moodle alert',
39 ALERT;
40
41/**
42 * Extends core Dialogue to show the alert dialogue.
43 *
44 * @param {Object} config Object literal specifying the dialogue configuration properties.
45 * @constructor
46 * @class M.core.alert
47 * @extends M.core.dialogue
48 */
49ALERT = function(config) {
50 config.closeButton = false;
51 ALERT.superclass.constructor.apply(this, [config]);
52};
cfa770b4 53Y.extend(ALERT, M.core.notification.info, {
f857b668
AN
54 /**
55 * The list of events to detach when destroying this dialogue.
56 *
57 * @property _closeEvents
58 * @type EventHandle[]
59 * @private
60 */
61 _closeEvents: null,
62 initializer: function() {
63 this._closeEvents = [];
78686995 64 this.publish('complete');
557f44d9
AN
65 var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '"' +
66 'value="'+this.get(CONFIRMYES)+'" />'),
78686995
AN
67 content = Y.Node.create('<div class="confirmation-dialogue"></div>')
68 .append(Y.Node.create('<div class="confirmation-message">'+this.get('message')+'</div>'))
69 .append(Y.Node.create('<div class="confirmation-buttons"></div>')
70 .append(yes));
71 this.get(BASE).addClass('moodle-dialogue-confirm');
72 this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
73 this.setStdModContent(Y.WidgetStdMod.HEADER,
c44012e0 74 '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
2f166b32 75
f857b668 76 this._closeEvents.push(
649c80e6
AN
77 Y.on('key', this.submit, window, 'down:13', this),
78 yes.on('click', this.submit, this)
79 );
80
81 var closeButton = this.get('boundingBox').one('.closebutton');
82 if (closeButton) {
83 // The close button should act exactly like the 'No' button.
f857b668 84 this._closeEvents.push(
649c80e6
AN
85 closeButton.on('click', this.submit, this)
86 );
87 }
78686995 88 },
f857b668
AN
89 submit: function() {
90 new Y.EventHandle(this._closeEvents).detach();
78686995
AN
91 this.fire('complete');
92 this.hide();
93 this.destroy();
94 }
95}, {
f857b668
AN
96 NAME: ALERT_NAME,
97 CSS_PREFIX: DIALOGUE_PREFIX,
98 ATTRS: {
78686995
AN
99
100 /**
101 * The title of the alert.
102 *
103 * @attribute title
104 * @type String
105 * @default 'Alert'
106 */
f857b668
AN
107 title: {
108 validator: Y.Lang.isString,
109 value: 'Alert'
78686995
AN
110 },
111
112 /**
113 * The message of the alert.
114 *
115 * @attribute message
116 * @type String
117 * @default 'Confirm'
118 */
f857b668
AN
119 message: {
120 validator: Y.Lang.isString,
121 value: 'Confirm'
78686995
AN
122 },
123
124 /**
125 * The button text to use to accept the alert.
126 *
127 * @attribute yesLabel
128 * @type String
129 * @default 'Ok'
130 */
f857b668
AN
131 yesLabel: {
132 validator: Y.Lang.isString,
133 setter: function(txt) {
78686995
AN
134 if (!txt) {
135 txt = 'Ok';
136 }
137 return txt;
138 },
f857b668 139 value: 'Ok'
78686995
AN
140 }
141 }
142});
143
144M.core.alert = ALERT;
145
146
147}, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]});