[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 /** 2 * A dialogue type designed to display an appropriate error when an error 3 * thrown in the Moodle codebase was reported during an AJAX request. 4 * 5 * @module moodle-core-notification 6 * @submodule moodle-core-notification-ajaxexception 7 */ 8 9 var AJAXEXCEPTION_NAME = 'Moodle AJAX exception', 10 AJAXEXCEPTION; 11 12 /** 13 * Extends core Dialogue to show the exception dialogue. 14 * 15 * @param {Object} config Object literal specifying the dialogue configuration properties. 16 * @constructor 17 * @class M.core.ajaxException 18 * @extends M.core.dialogue 19 */ 20 AJAXEXCEPTION = function(config) { 21 config.name = config.name || 'Error'; 22 config.closeButton = true; 23 AJAXEXCEPTION.superclass.constructor.apply(this, [config]); 24 }; 25 Y.extend(AJAXEXCEPTION, M.core.notification.info, { 26 _keypress : null, 27 initializer : function(config) { 28 var content, 29 self = this, 30 delay = this.get('hideTimeoutDelay'); 31 this.get(BASE).addClass('moodle-dialogue-exception'); 32 this.setStdModContent(Y.WidgetStdMod.HEADER, 33 '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + Y.Escape.html(config.name) + '</h1>', 34 Y.WidgetStdMod.REPLACE); 35 content = Y.Node.create('<div class="moodle-ajaxexception"></div>') 36 .append(Y.Node.create('<div class="moodle-exception-message">'+Y.Escape.html(this.get('error'))+'</div>')) 37 .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' + 38 this.get('reproductionlink')+'</div>')) 39 .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' + 40 Y.Escape.html(this.get('debuginfo'))+'</div>')) 41 .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' + 42 Y.Escape.html(this.get('stacktrace'))+'</pre></div>')); 43 if (M.cfg.developerdebug) { 44 content.all('.moodle-exception-param').removeClass('hidden'); 45 } 46 this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE); 47 48 if (delay) { 49 this._hideTimeout = setTimeout(function(){self.hide();}, delay); 50 } 51 this.after('visibleChange', this.visibilityChanged, this); 52 this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this); 53 this.centerDialogue(); 54 }, 55 visibilityChanged : function(e) { 56 if (e.attrName === 'visible' && e.prevVal && !e.newVal) { 57 var self = this; 58 this._keypress.detach(); 59 setTimeout(function(){self.destroy();}, 1000); 60 } 61 } 62 }, { 63 NAME : AJAXEXCEPTION_NAME, 64 CSS_PREFIX : DIALOGUE_PREFIX, 65 ATTRS : { 66 67 /** 68 * The error message given in the exception. 69 * 70 * @attribute error 71 * @type String 72 * @default 'Unknown error' 73 * @optional 74 */ 75 error : { 76 validator : Y.Lang.isString, 77 value: M.util.get_string('unknownerror', 'moodle') 78 }, 79 80 /** 81 * Any additional debug information given in the exception. 82 * 83 * @attribute stacktrace 84 * @type String|null 85 * @default null 86 * @optional 87 */ 88 debuginfo : { 89 value : null 90 }, 91 92 /** 93 * The complete stack trace provided in the exception. 94 * 95 * @attribute stacktrace 96 * @type String|null 97 * @default null 98 * @optional 99 */ 100 stacktrace : { 101 value : null 102 }, 103 104 /** 105 * A link which may be used by support staff to replicate the issue. 106 * 107 * @attribute reproductionlink 108 * @type String 109 * @default null 110 * @optional 111 */ 112 reproductionlink : { 113 setter : function(link) { 114 if (link !== null) { 115 link = Y.Escape.html(link); 116 link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>'; 117 } 118 return link; 119 }, 120 value : null 121 }, 122 123 /** 124 * If set, the dialogue is hidden after the specified timeout period. 125 * 126 * @attribute hideTimeoutDelay 127 * @type Number 128 * @default null 129 * @optional 130 */ 131 hideTimeoutDelay : { 132 validator : Y.Lang.isNumber, 133 value : null 134 } 135 } 136 }); 137 138 M.core.ajaxException = AJAXEXCEPTION;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |