mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-40678-m' of git://github.com/andrewnicols/moodle
- Loading branch information
Showing
28 changed files
with
2,559 additions
and
1,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
...ld/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
YUI.add('moodle-core-notification-ajaxexception', function (Y, NAME) { | ||
|
||
var DIALOGUE_PREFIX, | ||
BASE, | ||
COUNT, | ||
CONFIRMYES, | ||
CONFIRMNO, | ||
TITLE, | ||
QUESTION, | ||
CSS; | ||
|
||
DIALOGUE_PREFIX = 'moodle-dialogue', | ||
BASE = 'notificationBase', | ||
COUNT = 0, | ||
CONFIRMYES = 'yesLabel', | ||
CONFIRMNO = 'noLabel', | ||
TITLE = 'title', | ||
QUESTION = 'question', | ||
CSS = { | ||
BASE : 'moodle-dialogue-base', | ||
WRAP : 'moodle-dialogue-wrap', | ||
HEADER : 'moodle-dialogue-hd', | ||
BODY : 'moodle-dialogue-bd', | ||
CONTENT : 'moodle-dialogue-content', | ||
FOOTER : 'moodle-dialogue-ft', | ||
HIDDEN : 'hidden', | ||
LIGHTBOX : 'moodle-dialogue-lightbox' | ||
}; | ||
|
||
// Set up the namespace once. | ||
M.core = M.core || {}; | ||
/** | ||
* A dialogue type designed to display an appropriate error when an error | ||
* thrown in the Moodle codebase was reported during an AJAX request. | ||
* | ||
* @module moodle-core-notification | ||
* @submodule moodle-core-notification-ajaxexception | ||
*/ | ||
|
||
var AJAXEXCEPTION_NAME = 'Moodle AJAX exception', | ||
AJAXEXCEPTION; | ||
|
||
/** | ||
* Extends core Dialogue to show the exception dialogue. | ||
* | ||
* @param {Object} config Object literal specifying the dialogue configuration properties. | ||
* @constructor | ||
* @class M.core.ajaxException | ||
* @extends M.core.dialogue | ||
*/ | ||
AJAXEXCEPTION = function(config) { | ||
config.name = config.name || 'Error'; | ||
config.closeButton = true; | ||
AJAXEXCEPTION.superclass.constructor.apply(this, [config]); | ||
}; | ||
Y.extend(AJAXEXCEPTION, M.core.dialogue, { | ||
_keypress : null, | ||
initializer : function(config) { | ||
var content, | ||
self = this, | ||
delay = this.get('hideTimeoutDelay'); | ||
this.get(BASE).addClass('moodle-dialogue-exception'); | ||
this.setStdModContent(Y.WidgetStdMod.HEADER, | ||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE); | ||
content = Y.Node.create('<div class="moodle-ajaxexception"></div>') | ||
.append(Y.Node.create('<div class="moodle-exception-message">'+this.get('error')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' + | ||
this.get('reproductionlink')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' + | ||
this.get('debuginfo')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' + | ||
this.get('stacktrace')+'</pre></div>')); | ||
if (M.cfg.developerdebug) { | ||
content.all('.moodle-exception-param').removeClass('hidden'); | ||
} | ||
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE); | ||
|
||
if (delay) { | ||
this._hideTimeout = setTimeout(function(){self.hide();}, delay); | ||
} | ||
this.after('visibleChange', this.visibilityChanged, this); | ||
this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this); | ||
this.centerDialogue(); | ||
}, | ||
visibilityChanged : function(e) { | ||
if (e.attrName === 'visible' && e.prevVal && !e.newVal) { | ||
var self = this; | ||
this._keypress.detach(); | ||
setTimeout(function(){self.destroy();}, 1000); | ||
} | ||
} | ||
}, { | ||
NAME : AJAXEXCEPTION_NAME, | ||
CSS_PREFIX : DIALOGUE_PREFIX, | ||
ATTRS : { | ||
|
||
/** | ||
* The error message given in the exception. | ||
* | ||
* @attribute error | ||
* @type String | ||
* @default 'Unknown error' | ||
* @optional | ||
*/ | ||
error : { | ||
validator : Y.Lang.isString, | ||
value : 'Unknown error' | ||
}, | ||
|
||
/** | ||
* Any additional debug information given in the exception. | ||
* | ||
* @attribute stacktrace | ||
* @type String|null | ||
* @default null | ||
* @optional | ||
*/ | ||
debuginfo : { | ||
value : null | ||
}, | ||
|
||
/** | ||
* The complete stack trace provided in the exception. | ||
* | ||
* @attribute stacktrace | ||
* @type String|null | ||
* @default null | ||
* @optional | ||
*/ | ||
stacktrace : { | ||
value : null | ||
}, | ||
|
||
/** | ||
* A link which may be used by support staff to replicate the issue. | ||
* | ||
* @attribute reproductionlink | ||
* @type String | ||
* @default null | ||
* @optional | ||
*/ | ||
reproductionlink : { | ||
setter : function(link) { | ||
if (link !== null) { | ||
link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>'; | ||
} | ||
return link; | ||
}, | ||
value : null | ||
}, | ||
|
||
/** | ||
* If set, the dialogue is hidden after the specified timeout period. | ||
* | ||
* @attribute hideTimeoutDelay | ||
* @type Number | ||
* @default null | ||
* @optional | ||
*/ | ||
hideTimeoutDelay : { | ||
validator : Y.Lang.isNumber, | ||
value : null | ||
} | ||
} | ||
}); | ||
|
||
M.core.ajaxException = AJAXEXCEPTION; | ||
|
||
|
||
}, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]}); |
1 change: 1 addition & 0 deletions
1
...uild/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
170 changes: 170 additions & 0 deletions
170
...ui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
YUI.add('moodle-core-notification-ajaxexception', function (Y, NAME) { | ||
|
||
var DIALOGUE_PREFIX, | ||
BASE, | ||
COUNT, | ||
CONFIRMYES, | ||
CONFIRMNO, | ||
TITLE, | ||
QUESTION, | ||
CSS; | ||
|
||
DIALOGUE_PREFIX = 'moodle-dialogue', | ||
BASE = 'notificationBase', | ||
COUNT = 0, | ||
CONFIRMYES = 'yesLabel', | ||
CONFIRMNO = 'noLabel', | ||
TITLE = 'title', | ||
QUESTION = 'question', | ||
CSS = { | ||
BASE : 'moodle-dialogue-base', | ||
WRAP : 'moodle-dialogue-wrap', | ||
HEADER : 'moodle-dialogue-hd', | ||
BODY : 'moodle-dialogue-bd', | ||
CONTENT : 'moodle-dialogue-content', | ||
FOOTER : 'moodle-dialogue-ft', | ||
HIDDEN : 'hidden', | ||
LIGHTBOX : 'moodle-dialogue-lightbox' | ||
}; | ||
|
||
// Set up the namespace once. | ||
M.core = M.core || {}; | ||
/** | ||
* A dialogue type designed to display an appropriate error when an error | ||
* thrown in the Moodle codebase was reported during an AJAX request. | ||
* | ||
* @module moodle-core-notification | ||
* @submodule moodle-core-notification-ajaxexception | ||
*/ | ||
|
||
var AJAXEXCEPTION_NAME = 'Moodle AJAX exception', | ||
AJAXEXCEPTION; | ||
|
||
/** | ||
* Extends core Dialogue to show the exception dialogue. | ||
* | ||
* @param {Object} config Object literal specifying the dialogue configuration properties. | ||
* @constructor | ||
* @class M.core.ajaxException | ||
* @extends M.core.dialogue | ||
*/ | ||
AJAXEXCEPTION = function(config) { | ||
config.name = config.name || 'Error'; | ||
config.closeButton = true; | ||
AJAXEXCEPTION.superclass.constructor.apply(this, [config]); | ||
}; | ||
Y.extend(AJAXEXCEPTION, M.core.dialogue, { | ||
_keypress : null, | ||
initializer : function(config) { | ||
var content, | ||
self = this, | ||
delay = this.get('hideTimeoutDelay'); | ||
this.get(BASE).addClass('moodle-dialogue-exception'); | ||
this.setStdModContent(Y.WidgetStdMod.HEADER, | ||
'<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE); | ||
content = Y.Node.create('<div class="moodle-ajaxexception"></div>') | ||
.append(Y.Node.create('<div class="moodle-exception-message">'+this.get('error')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' + | ||
this.get('reproductionlink')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' + | ||
this.get('debuginfo')+'</div>')) | ||
.append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' + | ||
this.get('stacktrace')+'</pre></div>')); | ||
if (M.cfg.developerdebug) { | ||
content.all('.moodle-exception-param').removeClass('hidden'); | ||
} | ||
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE); | ||
|
||
if (delay) { | ||
this._hideTimeout = setTimeout(function(){self.hide();}, delay); | ||
} | ||
this.after('visibleChange', this.visibilityChanged, this); | ||
this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this); | ||
this.centerDialogue(); | ||
}, | ||
visibilityChanged : function(e) { | ||
if (e.attrName === 'visible' && e.prevVal && !e.newVal) { | ||
var self = this; | ||
this._keypress.detach(); | ||
setTimeout(function(){self.destroy();}, 1000); | ||
} | ||
} | ||
}, { | ||
NAME : AJAXEXCEPTION_NAME, | ||
CSS_PREFIX : DIALOGUE_PREFIX, | ||
ATTRS : { | ||
|
||
/** | ||
* The error message given in the exception. | ||
* | ||
* @attribute error | ||
* @type String | ||
* @default 'Unknown error' | ||
* @optional | ||
*/ | ||
error : { | ||
validator : Y.Lang.isString, | ||
value : 'Unknown error' | ||
}, | ||
|
||
/** | ||
* Any additional debug information given in the exception. | ||
* | ||
* @attribute stacktrace | ||
* @type String|null | ||
* @default null | ||
* @optional | ||
*/ | ||
debuginfo : { | ||
value : null | ||
}, | ||
|
||
/** | ||
* The complete stack trace provided in the exception. | ||
* | ||
* @attribute stacktrace | ||
* @type String|null | ||
* @default null | ||
* @optional | ||
*/ | ||
stacktrace : { | ||
value : null | ||
}, | ||
|
||
/** | ||
* A link which may be used by support staff to replicate the issue. | ||
* | ||
* @attribute reproductionlink | ||
* @type String | ||
* @default null | ||
* @optional | ||
*/ | ||
reproductionlink : { | ||
setter : function(link) { | ||
if (link !== null) { | ||
link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>'; | ||
} | ||
return link; | ||
}, | ||
value : null | ||
}, | ||
|
||
/** | ||
* If set, the dialogue is hidden after the specified timeout period. | ||
* | ||
* @attribute hideTimeoutDelay | ||
* @type Number | ||
* @default null | ||
* @optional | ||
*/ | ||
hideTimeoutDelay : { | ||
validator : Y.Lang.isNumber, | ||
value : null | ||
} | ||
} | ||
}); | ||
|
||
M.core.ajaxException = AJAXEXCEPTION; | ||
|
||
|
||
}, '@VERSION@', {"requires": ["moodle-core-notification-dialogue"]}); |
Oops, something went wrong.