MDL-37526 Fix lint issues in moodle-core-notification

This commit is contained in:
Andrew Robert Nicols 2012-12-09 20:41:00 +00:00 committed by Andrew Robert Nicols
parent b3778a0dec
commit c6dcce6ad3

View File

@ -22,17 +22,22 @@ var DIALOGUE_NAME = 'Moodle dialogue',
FOOTER : 'moodle-dialogue-ft',
HIDDEN : 'hidden',
LIGHTBOX : 'moodle-dialogue-lightbox'
};
},
EXCEPTION,
ALERT,
CONFIRM,
AJAXEXCEPTION,
DIALOGUE;
var DIALOGUE = function(config) {
DIALOGUE = function(config) {
COUNT++;
var id = 'moodle-dialogue-'+COUNT;
config.notificationBase =
C('<div class="'+CSS.BASE+'">')
.append(C('<div id="'+id+'" role="dialog" aria-labelledby="'+id+'-header-text" class="'+CSS.WRAP+'"></div>')
.append(C('<div class="'+CSS.HEADER+' yui3-widget-hd"></div>'))
.append(C('<div class="'+CSS.BODY+' yui3-widget-bd"></div>'))
.append(C('<div class="'+CSS.FOOTER+' yui3-widget-ft"></div>')));
new C('<div class="'+CSS.BASE+'">')
.append(new C('<div id="'+id+'" role="dialog" aria-labelledby="'+id+'-header-text" class="'+CSS.WRAP+'"></div>')
.append(new C('<div class="'+CSS.HEADER+' yui3-widget-hd"></div>'))
.append(new C('<div class="'+CSS.BODY+' yui3-widget-bd"></div>'))
.append(new C('<div class="'+CSS.FOOTER+' yui3-widget-ft"></div>')));
Y.one(document.body).append(config.notificationBase);
config.srcNode = '#'+id;
config.width = config.width || '400px';
@ -74,27 +79,28 @@ Y.extend(DIALOGUE, Y.Panel, {
this.show();
},
visibilityChanged : function(e) {
switch (e.attrName) {
case 'visible':
this.get('maskNode').addClass(CSS.LIGHTBOX);
if (this.get('center') && !e.prevVal && e.newVal) {
this.centerDialogue();
}
if (this.get('draggable')) {
var titlebar = '#' + this.get('id') + ' .' + CSS.HEADER;
this.plug(Y.Plugin.Drag, {handles : [titlebar]});
Y.one(titlebar).setStyle('cursor', 'move');
}
break;
var titlebar;
if (e.attrName === 'visible') {
this.get('maskNode').addClass(CSS.LIGHTBOX);
if (this.get('center') && !e.prevVal && e.newVal) {
this.centerDialogue();
}
if (this.get('draggable')) {
titlebar = '#' + this.get('id') + ' .' + CSS.HEADER;
this.plug(Y.Plugin.Drag, {handles : [titlebar]});
Y.one(titlebar).setStyle('cursor', 'move');
}
}
},
centerDialogue : function() {
var bb = this.get('boundingBox'), hidden = bb.hasClass(DIALOGUE_PREFIX+'-hidden');
var bb = this.get('boundingBox'),
hidden = bb.hasClass(DIALOGUE_PREFIX+'-hidden'),
x, y;
if (hidden) {
bb.setStyle('top', '-1000px').removeClass(DIALOGUE_PREFIX+'-hidden');
}
var x = Math.max(Math.round((bb.get('winWidth') - bb.get('offsetWidth'))/2), 15);
var y = Math.max(Math.round((bb.get('winHeight') - bb.get('offsetHeight'))/2), 15) + Y.one(window).get('scrollTop');
x = Math.max(Math.round((bb.get('winWidth') - bb.get('offsetWidth'))/2), 15);
y = Math.max(Math.round((bb.get('winHeight') - bb.get('offsetHeight'))/2), 15) + Y.one(window).get('scrollTop');
if (hidden) {
bb.addClass(DIALOGUE_PREFIX+'-hidden');
@ -131,13 +137,13 @@ Y.extend(DIALOGUE, Y.Panel, {
}
});
var ALERT = function(config) {
ALERT = function(config) {
config.closeButton = false;
ALERT.superclass.constructor.apply(this, [config]);
};
Y.extend(ALERT, DIALOGUE, {
_enterKeypress : null,
initializer : function(config) {
initializer : function() {
this.publish('complete');
var yes = C('<input type="button" id="id_yuialertconfirm-' + this.COUNT + '" value="'+this.get(CONFIRMYES)+'" />'),
content = C('<div class="confirmation-dialogue"></div>')
@ -151,7 +157,7 @@ Y.extend(ALERT, DIALOGUE, {
this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
yes.on('click', this.submit, this);
},
submit : function(e, outcome) {
submit : function() {
this._enterKeypress.detach();
this.fire('complete');
this.hide();
@ -182,13 +188,13 @@ Y.extend(ALERT, DIALOGUE, {
}
});
var CONFIRM = function(config) {
CONFIRM = function(config) {
CONFIRM.superclass.constructor.apply(this, [config]);
};
Y.extend(CONFIRM, DIALOGUE, {
_enterKeypress : null,
_escKeypress : null,
initializer : function(config) {
initializer : function() {
this.publish('complete');
this.publish('complete-yes');
this.publish('complete-no');
@ -244,7 +250,7 @@ Y.extend(CONFIRM, DIALOGUE, {
});
Y.augment(CONFIRM, Y.EventTarget);
var EXCEPTION = function(config) {
EXCEPTION = function(config) {
config.width = config.width || (M.cfg.developerdebug)?Math.floor(Y.one(document.body).get('winWidth')/3)+'px':null;
config.closeButton = true;
EXCEPTION.superclass.constructor.apply(this, [config]);
@ -253,20 +259,21 @@ Y.extend(EXCEPTION, DIALOGUE, {
_hideTimeout : null,
_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-'+COUNT+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
var content = C('<div class="moodle-exception"></div>')
.append(C('<div class="moodle-exception-message">'+this.get('message')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-filename"><label>File:</label> '+this.get('fileName')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-linenumber"><label>Line:</label> '+this.get('lineNumber')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stack')+'</pre></div>'));
content = C('<div class="moodle-exception"></div>')
.append(C('<div class="moodle-exception-message">'+this.get('message')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-filename"><label>File:</label> '+this.get('fileName')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-linenumber"><label>Line:</label> '+this.get('lineNumber')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stack')+'</pre></div>'));
if (M.cfg.developerdebug) {
content.all('.moodle-exception-param').removeClass('hidden');
}
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
var self = this;
var delay = this.get('hideTimeoutDelay');
if (delay) {
this._hideTimeout = setTimeout(function(){self.hide();}, delay);
}
@ -276,8 +283,10 @@ Y.extend(EXCEPTION, DIALOGUE, {
this.centerDialogue();
},
visibilityChanged : function(e) {
if (e.attrName == 'visible' && e.prevVal && !e.newVal) {
if (this._keypress) this._keypress.detach();
if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
if (this._keypress) {
this._keypress.detach();
}
var self = this;
setTimeout(function(){self.destroy();}, 1000);
}
@ -300,10 +309,12 @@ Y.extend(EXCEPTION, DIALOGUE, {
},
stack : {
setter : function(str) {
var lines = str.split("\n");
var pattern = new RegExp('^(.+)@('+M.cfg.wwwroot+')?(.{0,75}).*:(\\d+)$');
for (var i in lines) {
lines[i] = lines[i].replace(pattern, "<div class='stacktrace-line'>ln: $4</div><div class='stacktrace-file'>$3</div><div class='stacktrace-call'>$1</div>");
var lines = str.split("\n"),
pattern = new RegExp('^(.+)@('+M.cfg.wwwroot+')?(.{0,75}).*:(\\d+)$'),
i;
for (i in lines) {
lines[i] = lines[i].replace(pattern,
"<div class='stacktrace-line'>ln: $4</div><div class='stacktrace-file'>$3</div><div class='stacktrace-call'>$1</div>");
}
return lines.join('');
},
@ -316,7 +327,7 @@ Y.extend(EXCEPTION, DIALOGUE, {
}
});
var AJAXEXCEPTION = function(config) {
AJAXEXCEPTION = function(config) {
config.name = config.name || 'Error';
config.closeButton = true;
AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
@ -324,20 +335,21 @@ var AJAXEXCEPTION = function(config) {
Y.extend(AJAXEXCEPTION, 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-'+COUNT+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
var content = C('<div class="moodle-ajaxexception"></div>')
.append(C('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get('reproductionlink')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get('debuginfo')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stacktrace')+'</pre></div>'));
content = C('<div class="moodle-ajaxexception"></div>')
.append(C('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get('reproductionlink')+'</div>'))
.append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get('debuginfo')+'</div>'))
.append(C('<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);
var self = this;
var delay = this.get('hideTimeoutDelay');
if (delay) {
this._hideTimeout = setTimeout(function(){self.hide();}, delay);
}
@ -346,7 +358,7 @@ Y.extend(AJAXEXCEPTION, DIALOGUE, {
this.centerDialogue();
},
visibilityChanged : function(e) {
if (e.attrName == 'visible' && e.prevVal && !e.newVal) {
if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
var self = this;
this._keypress.detach();
setTimeout(function(){self.destroy();}, 1000);