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