Skip to content

Commit

Permalink
MDL-55244 js: fix various lint warnings in yui
Browse files Browse the repository at this point in the history
* Incorrect brace style
* Empty functions
* Multiple var statemnts
  • Loading branch information
danpoltawski committed Jul 25, 2016
1 parent 5bb4f44 commit bc8b6dc
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 52 deletions.
14 changes: 11 additions & 3 deletions availability/yui/src/form/js/form.js
Expand Up @@ -277,6 +277,7 @@ M.core_availability.plugin = {
* @protected
*/
initInner: function() {
// Can be overriden.
},

/**
Expand Down Expand Up @@ -319,6 +320,7 @@ M.core_availability.plugin = {
* @param {Y.Node} node YUI node (same one returned from getNode)
*/
fillErrors: function() {
// Can be overriden.
},

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
};

/**
Expand Down Expand Up @@ -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);
};

/**
Expand Down
45 changes: 34 additions & 11 deletions backup/util/ui/yui/src/backupselectall/js/backupselectall.js
Expand Up @@ -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);
});
}
};

Expand Down Expand Up @@ -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);
});
}
};
4 changes: 3 additions & 1 deletion course/yui/src/dragdrop/js/section.js
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion course/yui/src/toolboxes/js/toolbox.js
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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.
Expand Down
11 changes: 8 additions & 3 deletions lib/editor/atto/plugins/image/yui/src/button/js/button.js
Expand Up @@ -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);
},

/**
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions lib/editor/atto/plugins/indent/yui/src/button/js/button.js
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/editor/atto/yui/src/editor/js/commands.js
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/form/yui/src/dateselector/js/dateselector.js
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion lib/form/yui/src/passwordunmask/js/passwordunmask.js
Expand Up @@ -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>');
Expand Down
4 changes: 3 additions & 1 deletion lib/yui/src/blocks/js/blocks.js
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/yui/src/blocks/js/manager.js
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/yui/src/dock/js/dockeditem.js
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions lib/yui/src/dragdrop/js/dragdrop.js
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down
8 changes: 6 additions & 2 deletions lib/yui/src/notification/js/ajaxexception.js
Expand Up @@ -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);
Expand All @@ -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);
}
}
}, {
Expand Down
3 changes: 2 additions & 1 deletion lib/yui/src/notification/js/alert.js
Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion lib/yui/src/notification/js/confirm.js
Expand Up @@ -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),
Expand Down
8 changes: 6 additions & 2 deletions lib/yui/src/notification/js/exception.js
Expand Up @@ -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);
Expand All @@ -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);
}
}
}, {
Expand Down
4 changes: 3 additions & 1 deletion message/output/airnotifier/yui/src/toolboxes/js/toolboxes.js
Expand Up @@ -121,7 +121,9 @@ Y.extend(TOOLBOX, Y.Base, {
} else if (responsetext.success) {
callbacksuccess();
}
} catch (e) {}
} catch (e) {
// Ignore.
}
if (statusspinner) {
statusspinner.hide();
}
Expand Down
3 changes: 2 additions & 1 deletion mod/assign/feedback/editpdf/yui/src/editor/js/comment.js
Expand Up @@ -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++) {
Expand Down
12 changes: 10 additions & 2 deletions mod/assign/feedback/editpdf/yui/src/editor/js/commentmenu.js
Expand Up @@ -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);

Expand Down

0 comments on commit bc8b6dc

Please sign in to comment.