MDL-52127 js: check YUI modules with eslint
[moodle.git] / lib / yui / build / moodle-core-notification-ajaxexception / moodle-core-notification-ajaxexception-debug.js
CommitLineData
78686995
AN
1YUI.add('moodle-core-notification-ajaxexception', 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 appropriate error when an error
33 * thrown in the Moodle codebase was reported during an AJAX request.
34 *
35 * @module moodle-core-notification
36 * @submodule moodle-core-notification-ajaxexception
37 */
38
39var AJAXEXCEPTION_NAME = 'Moodle AJAX exception',
40 AJAXEXCEPTION;
41
42/**
43 * Extends core Dialogue to show the exception dialogue.
44 *
45 * @param {Object} config Object literal specifying the dialogue configuration properties.
46 * @constructor
47 * @class M.core.ajaxException
48 * @extends M.core.dialogue
49 */
50AJAXEXCEPTION = function(config) {
51 config.name = config.name || 'Error';
52 config.closeButton = true;
53 AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
54};
cfa770b4 55Y.extend(AJAXEXCEPTION, M.core.notification.info, {
78686995
AN
56 _keypress : null,
57 initializer : function(config) {
58 var content,
59 self = this,
60 delay = this.get('hideTimeoutDelay');
61 this.get(BASE).addClass('moodle-dialogue-exception');
62 this.setStdModContent(Y.WidgetStdMod.HEADER,
c44012e0 63 '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + Y.Escape.html(config.name) + '</h1>',
cd6e149c 64 Y.WidgetStdMod.REPLACE);
78686995 65 content = Y.Node.create('<div class="moodle-ajaxexception"></div>')
cd6e149c 66 .append(Y.Node.create('<div class="moodle-exception-message">'+Y.Escape.html(this.get('error'))+'</div>'))
78686995
AN
67 .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' +
68 this.get('reproductionlink')+'</div>'))
69 .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' +
cd6e149c 70 Y.Escape.html(this.get('debuginfo'))+'</div>'))
557f44d9
AN
71 .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace">' +
72 '<label>Stack trace:</label> <pre>' +
cd6e149c 73 Y.Escape.html(this.get('stacktrace'))+'</pre></div>'));
78686995
AN
74 if (M.cfg.developerdebug) {
75 content.all('.moodle-exception-param').removeClass('hidden');
76 }
77 this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
78
79 if (delay) {
80 this._hideTimeout = setTimeout(function(){self.hide();}, delay);
81 }
82 this.after('visibleChange', this.visibilityChanged, this);
83 this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this);
84 this.centerDialogue();
85 },
86 visibilityChanged : function(e) {
87 if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
88 var self = this;
89 this._keypress.detach();
90 setTimeout(function(){self.destroy();}, 1000);
91 }
92 }
93}, {
94 NAME : AJAXEXCEPTION_NAME,
95 CSS_PREFIX : DIALOGUE_PREFIX,
96 ATTRS : {
97
98 /**
99 * The error message given in the exception.
100 *
101 * @attribute error
102 * @type String
103 * @default 'Unknown error'
104 * @optional
105 */
106 error : {
107 validator : Y.Lang.isString,
0d1d5423 108 value: M.util.get_string('unknownerror', 'moodle')
78686995
AN
109 },
110
111 /**
112 * Any additional debug information given in the exception.
113 *
114 * @attribute stacktrace
115 * @type String|null
116 * @default null
117 * @optional
118 */
119 debuginfo : {
120 value : null
121 },
122
123 /**
124 * The complete stack trace provided in the exception.
125 *
126 * @attribute stacktrace
127 * @type String|null
128 * @default null
129 * @optional
130 */
131 stacktrace : {
132 value : null
133 },
134
135 /**
136 * A link which may be used by support staff to replicate the issue.
137 *
138 * @attribute reproductionlink
139 * @type String
140 * @default null
141 * @optional
142 */
143 reproductionlink : {
144 setter : function(link) {
145 if (link !== null) {
cd6e149c 146 link = Y.Escape.html(link);
78686995
AN
147 link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>';
148 }
149 return link;
150 },
151 value : null
152 },
153
154 /**
155 * If set, the dialogue is hidden after the specified timeout period.
156 *
157 * @attribute hideTimeoutDelay
158 * @type Number
159 * @default null
160 * @optional
161 */
162 hideTimeoutDelay : {
163 validator : Y.Lang.isNumber,
164 value : null
165 }
166 }
167});
168
169M.core.ajaxException = AJAXEXCEPTION;
170
171
172}, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]});