MDL-55244 js: fix various lint warnings in yui

* Incorrect brace style
* Empty functions
* Multiple var statemnts
This commit is contained in:
Dan Poltawski 2016-07-15 16:38:21 +01:00
parent 5bb4f444de
commit bc8b6dc652
28 changed files with 141 additions and 52 deletions

View File

@ -277,6 +277,7 @@ M.core_availability.plugin = {
* @protected
*/
initInner: function() {
// Can be overriden.
},
/**
@ -319,6 +320,7 @@ M.core_availability.plugin = {
* @param {Y.Node} node YUI node (same one returned from getNode)
*/
fillErrors: function() {
// Can be overriden.
},
/**
@ -409,7 +411,9 @@ M.core_availability.List = function(json, root, parentRoot) {
// Create the button and add it.
var button = Y.Node.create('<button type="button" class="btn btn-default">' +
M.util.get_string('addrestriction', 'availability') + '</button>');
button.on("click", function() { this.clickAdd(); }, this);
button.on("click", function() {
this.clickAdd();
}, this);
this.node.one('div.availability-button').appendChild(button);
if (json) {
@ -1080,7 +1084,9 @@ M.core_availability.EyeIcon = function(individual, shown) {
};
this.span.on('click', click, this);
this.span.on('key', click, 'up:32', this);
this.span.on('key', function(e) { e.preventDefault(); }, 'down:32', this);
this.span.on('key', function(e) {
e.preventDefault();
}, 'down:32', this);
};
/**
@ -1132,7 +1138,9 @@ M.core_availability.DeleteIcon = function(toDelete) {
};
this.span.on('click', click, this);
this.span.on('key', click, 'up:32', this);
this.span.on('key', function(e) { e.preventDefault(); }, 'down:32', this);
this.span.on('key', function(e) {
e.preventDefault();
}, 'down:32', this);
};
/**

View File

@ -91,11 +91,19 @@ M.core_backup.backupselectall = function(modnames) {
// Add select all/none for each module type.
var initlinks = function(links, mod) {
Y.one('#backup-all-mod_' + mod).on('click', function(e) { helper(e, true, '_included', mod); });
Y.one('#backup-none-mod_' + mod).on('click', function(e) { helper(e, false, '_included', mod); });
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
helper(e, true, '_included', mod);
});
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
helper(e, false, '_included', mod);
});
if (withuserdata) {
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) { helper(e, true, withuserdata, mod); });
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) { helper(e, false, withuserdata, mod); });
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
helper(e, true, withuserdata, mod);
});
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
helper(e, false, withuserdata, mod);
});
}
};
@ -141,24 +149,39 @@ M.core_backup.backupselectall = function(modnames) {
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
modlist.setStyle('maxHeight', '0px');
anim = new Y.Anim(animcfg);
anim.on('end', function() { modlist.setStyle('maxHeight', 'none'); });
anim.on('end', function() {
modlist.setStyle('maxHeight', 'none');
});
anim.run();
} else {
// Animate hide of the module links.
animcfg.to = {maxHeight: '0px'};
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
anim = new Y.Anim(animcfg);
anim.on('end', function() { modlist.hide(); modlist.setStyle('maxHeight', 'none'); });
anim.on('end', function() {
modlist.hide();
modlist.setStyle('maxHeight', 'none');
});
anim.run();
}
};
Y.one('#backup-bytype').on('click', function() { toggletypes(); });
Y.one('#backup-bytype').on('click', function() {
toggletypes();
});
Y.one('#backup-all-included').on('click', function(e) { helper(e, true, '_included'); });
Y.one('#backup-none-included').on('click', function(e) { helper(e, false, '_included'); });
Y.one('#backup-all-included').on('click', function(e) {
helper(e, true, '_included');
});
Y.one('#backup-none-included').on('click', function(e) {
helper(e, false, '_included');
});
if (withuserdata) {
Y.one('#backup-all-userdata').on('click', function(e) { helper(e, true, withuserdata); });
Y.one('#backup-none-userdata').on('click', function(e) { helper(e, false, withuserdata); });
Y.one('#backup-all-userdata').on('click', function(e) {
helper(e, true, withuserdata);
});
Y.one('#backup-none-userdata').on('click', function(e) {
helper(e, false, withuserdata);
});
}
};

View File

@ -214,7 +214,9 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
new M.core.ajaxException(responsetext);
}
M.course.format.process_sections(Y, sectionlist, responsetext, loopstart, loopend);
} catch (e) {}
} catch (e) {
// Ignore.
}
// Update all of the section IDs - first unset them, then set them
// to avoid duplicates in the DOM.

View File

@ -112,7 +112,9 @@ Y.extend(TOOLBOX, Y.Base, {
if (responsetext.error) {
new M.core.ajaxException(responsetext);
}
} catch (e) {}
} catch (e) {
// Ignore.
}
// Run the callback if we have one.
if (success_callback) {

View File

@ -147,7 +147,8 @@ Y.namespace('M.atto_accessibilitychecker').Button = Y.Base.create('button', Y.M.
' Luminance 2: ' + lum2);
// We only want the highest node with dodgy contrast reported.
var i = 0, found = false;
var i = 0;
var found = false;
for (i = 0; i < problemNodes.length; i++) {
if (node.ancestors('*').indexOf(problemNodes[i]) !== -1) {
// Do not add node - it already has a parent in the list.

View File

@ -219,8 +219,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this.editor.on('drop', this._handleDragDrop, this);
// e.preventDefault needed to stop the default event from clobbering the desired behaviour in some browsers.
this.editor.on('dragover', function(e) { e.preventDefault(); }, this);
this.editor.on('dragenter', function(e) { e.preventDefault(); }, this);
this.editor.on('dragover', function(e) {
e.preventDefault();
}, this);
this.editor.on('dragenter', function(e) {
e.preventDefault();
}, this);
},
/**
@ -393,7 +397,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
* @private
*/
_loadPreviewImage: function(url) {
var image = new Image(), self = this;
var image = new Image();
var self = this;
image.onerror = function() {
var preview = self._form.one('.' + CSS.IMAGEPREVIEW);

View File

@ -156,7 +156,8 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed
.setStyle(margindir, '30px')
.addClass('editor-indent');
// We use childNodes here because we are interested in both type 1 and 3 child nodes.
var children = blockquote.getDOMNode().childNodes, child;
var children = blockquote.getDOMNode().childNodes;
var child;
child = children[0];
while (typeof child !== "undefined") {
clone.append(child);
@ -182,7 +183,8 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed
.getAttrs())
.removeClass('editor-indent');
// We use childNodes here because we are interested in both type 1 and 3 child nodes.
var children = indent.getDOMNode().childNodes, child;
var children = indent.getDOMNode().childNodes;
var child;
child = children[0];
while (typeof child !== "undefined") {
clone.append(child);

View File

@ -111,7 +111,8 @@ EditorCommand.prototype = {
clone.setAttribute('class', node.getAttribute('class'));
}
// We use childNodes here because we are interested in both type 1 and 3 child nodes.
var children = node.getDOMNode().childNodes, child;
var children = node.getDOMNode().childNodes;
var child;
child = children[0];
while (typeof child !== "undefined") {
clone.append(child);

View File

@ -76,7 +76,9 @@ M.form.dateselector = {
Y.one('#dateselector-calendar-panel').setStyle('zIndex', null);
this.panel.on('heightChange', this.fix_position, this);
Y.one('#dateselector-calendar-panel').on('click', function(e) { e.halt(); });
Y.one('#dateselector-calendar-panel').on('click', function(e) {
e.halt();
});
Y.one(document.body).on('click', this.document_click, this);
this.calendar = new MOODLECALENDAR({

View File

@ -22,7 +22,9 @@ Y.extend(PASSWORDUNMASK, Y.Base, {
checkboxname + 'unmask">');
unmaskdiv.appendChild(unmaskchb);
// Attach event using static javascript function for unmasking password.
unmaskchb.on('click', function() { window.unmaskPassword(elementid); });
unmaskchb.on('click', function() {
window.unmaskPassword(elementid);
});
// Add label for checkbox to unmaskdiv.
var unmasklabel = Y.Node.create('<label for="' + elementid + 'unmask">' + checkboxlabel + '</label>');

View File

@ -293,7 +293,9 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
if (responsetext.error) {
new M.core.ajaxException(responsetext);
}
} catch (e) {}
} catch (e) {
// Ignore.
}
},
failure: function(tid, response) {
this.ajax_failure(response);

View File

@ -315,7 +315,9 @@ MANAGER.prototype = {
if (responsetext.error) {
new M.core.ajaxException(responsetext);
}
} catch (e) {}
} catch (e) {
// Ignore.
}
},
failure: function(tid, response) {
this.ajax_failure(response);

View File

@ -98,7 +98,8 @@ DOCKEDITEM.prototype = {
this.fire('dockeditem:drawstart');
docktitle = create('<div id="dock_item_' + id + '_title" role="menu" aria-haspopup="true" class="' + CSS.dockedtitle + '"></div>');
docktitle = create('<div id="dock_item_' + id + '_title" role="menu" aria-haspopup="true" class="'
+ CSS.dockedtitle + '"></div>');
docktitle.append(this.get('title'));
dockitem = create('<div id="dock_item_' + id + '" class="' + CSS.dockeditem + '" tabindex="0" rel="' + id + '"></div>');
if (count === 1) {

View File

@ -1,3 +1,4 @@
/* eslint-disable no-empty-function */
/**
* The core drag and drop module for Moodle which extends the YUI drag and
* drop functionality with additional features.
@ -395,15 +396,14 @@ Y.extend(DRAGDROP, Y.Base, {
// Build the list of drop targets.
var droplist = Y.Node.create('<ul></ul>');
droplist.addClass('dragdrop-keyboard-drag');
var listitem,
listlink,
listitemtext;
var listitem, listlink, listitemtext;
// Search for possible drop targets.
var droptargets = Y.all('.' + this.samenodeclass + ', .' + this.parentnodeclass);
droptargets.each(function(node) {
var validdrop = false, labelroot = node;
var validdrop = false;
var labelroot = node;
if (node.drop && node.drop.inGroup(this.groups) && node.drop.get('node') !== dragcontainer) {
// This is a drag and drop target with the same class as the grabbed node.
validdrop = true;
@ -620,7 +620,8 @@ Y.extend(DRAGDROP, Y.Base, {
// Check the drag groups to see if we are the handler for this node.
draggroups = draghandle.getAttribute('data-draggroups').split(' ');
var i, j, validgroup = false;
var i, j;
var validgroup = false;
for (i = 0; i < draggroups.length; i++) {
for (j = 0; j < this.groups.length; j++) {

View File

@ -49,7 +49,9 @@ Y.extend(AJAXEXCEPTION, M.core.notification.info, {
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
if (delay) {
this._hideTimeout = setTimeout(function() { self.hide(); }, 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);
@ -59,7 +61,9 @@ Y.extend(AJAXEXCEPTION, M.core.notification.info, {
if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
var self = this;
this._keypress.detach();
setTimeout(function() { self.destroy(); }, 1000);
setTimeout(function() {
self.destroy();
}, 1000);
}
}
}, {

View File

@ -43,7 +43,8 @@ Y.extend(ALERT, M.core.notification.info, {
this.get(BASE).addClass('moodle-dialogue-confirm');
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
this.setStdModContent(Y.WidgetStdMod.HEADER,
'<h1 id="moodle-dialogue-' + this.get('COUNT') + '-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
'<h1 id="moodle-dialogue-' + this.get('COUNT') + '-header-text">' + this.get(TITLE) + '</h1>',
Y.WidgetStdMod.REPLACE);
this._closeEvents.push(
Y.on('key', this.submit, window, 'down:13', this),

View File

@ -76,7 +76,8 @@ Y.extend(CONFIRM, M.core.notification.info, {
this.get(BASE).addClass('moodle-dialogue-confirm');
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
this.setStdModContent(Y.WidgetStdMod.HEADER,
'<h1 id="moodle-dialogue-' + this.get('COUNT') + '-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
'<h1 id="moodle-dialogue-' + this.get('COUNT') + '-header-text">' + this.get(TITLE) + '</h1>',
Y.WidgetStdMod.REPLACE);
this._closeEvents.push(
Y.on('key', this.submit, window, 'down:27', this, false),

View File

@ -65,7 +65,9 @@ Y.extend(EXCEPTION, M.core.notification.info, {
this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
if (delay) {
this._hideTimeout = setTimeout(function() { self.hide(); }, 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);
@ -77,7 +79,9 @@ Y.extend(EXCEPTION, M.core.notification.info, {
this._keypress.detach();
}
var self = this;
setTimeout(function() { self.destroy(); }, 1000);
setTimeout(function() {
self.destroy();
}, 1000);
}
}
}, {

View File

@ -121,7 +121,9 @@ Y.extend(TOOLBOX, Y.Base, {
} else if (responsetext.success) {
callbacksuccess();
}
} catch (e) {}
} catch (e) {
// Ignore.
}
if (statusspinner) {
statusspinner.hide();
}

View File

@ -316,7 +316,8 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method remove
*/
this.remove = function() {
var i = 0, comments;
var i = 0;
var comments;
comments = this.editor.pages[this.editor.currentpage].comments;
for (i = 0; i < comments.length; i++) {

View File

@ -49,8 +49,16 @@ Y.extend(COMMENTMENU, M.assignfeedback_editpdf.dropdown, {
link = Y.Node.create('<li><a tabindex="-1" href="#">' +
M.util.get_string('deletecomment', 'assignfeedback_editpdf') +
'</a></li>');
link.on('click', function(e) { e.preventDefault(); this.menu.hide(); this.remove(); }, comment);
link.on('key', function() { comment.menu.hide(); comment.remove(); }, 'enter,space', comment);
link.on('click', function(e) {
e.preventDefault();
this.menu.hide();
this.remove();
}, comment);
link.on('key', function() {
comment.menu.hide();
comment.remove();
}, 'enter,space', comment);
commentlinks.append(link);

View File

@ -59,7 +59,9 @@ Y.extend(DROPDOWN, M.core.dialogue, {
}
}, this);
button.on('click', function(e) { e.preventDefault(); this.show(); }, this);
button.on('click', function(e) {
e.preventDefault(); this.show();
}, this);
button.on('key', this.show, 'enter,space', this);
},

View File

@ -347,7 +347,8 @@ EDITOR.prototype = {
* @method link_handler
*/
link_handler: function(e) {
var drawingcanvas, drawingregion, resize = true;
var drawingcanvas, drawingregion;
var resize = true;
e.preventDefault();
if (!this.dialogue) {

View File

@ -192,7 +192,9 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
new M.core.ajaxException(responsetext);
}
M.mod_quiz.edit.process_sections(Y, sectionlist, responsetext, loopstart, loopend);
} catch (e) {}
} catch (e) {
// Ignore.
}
// Update all of the section IDs - first unset them, then set them
// to avoid duplicates in the DOM.

View File

@ -65,7 +65,9 @@ Y.extend(POPUP, Y.Base, {
this.loadingDiv = this.dialogue.bodyNode.getHTML();
Y.later(100, this, function() { this.load_content(window.location.search); });
Y.later(100, this, function() {
this.load_content(window.location.search);
});
},
initializer: function() {
@ -127,7 +129,9 @@ Y.extend(POPUP, Y.Base, {
Y.log('Load completed.', 'debug', 'moodle-mod_quiz-quizquestionbank');
this.dialogue.bodyNode.setHTML(result.contents);
Y.use('moodle-question-chooser', function() { M.question.init_chooser({}); });
Y.use('moodle-question-chooser', function() {
M.question.init_chooser({});
});
this.dialogue.bodyNode.one('form').delegate('change', this.options_changed, '.searchoptions', this);
if (this.dialogue.visible) {

View File

@ -126,7 +126,9 @@ Y.extend(TOOLBOX, Y.Base, {
if (responsetext.error) {
new M.core.ajaxException(responsetext);
}
} catch (e) {}
} catch (e) {
// Ignore.
}
// Run the callback if we have one.
if (responsetext.hasOwnProperty('newsummarks')) {

View File

@ -234,7 +234,8 @@ Y.Moodle.mod_quiz.util.page = {
*/
reorderPages: function() {
// Get list of page nodes.
var pages = this.getPages(), currentpagenumber = 0;
var pages = this.getPages();
var currentpagenumber = 0;
// Loop through pages incrementing the number each time.
pages.each(function(page) {
// Is the page empty?

View File

@ -305,7 +305,8 @@ Y.Moodle.mod_quiz.util.slot = {
*/
reorderPageBreaks: function() {
// Get list of slot nodes.
var slots = this.getSlots(), slotnumber = 0;
var slots = this.getSlots();
var slotnumber = 0;
// Loop through slots incrementing the number each time.
slots.each(function(slot, key) {
slotnumber++;
@ -330,7 +331,8 @@ Y.Moodle.mod_quiz.util.slot = {
var pagebreaklink = pagebreak.get('childNodes').item(0);
// Get the correct title.
var action = '', iconname = '';
var action = '';
var iconname = '';
if (Y.Moodle.mod_quiz.util.page.isPage(nextitem)) {
action = 'removepagebreak';
iconname = 'e/remove_page_break';