mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -6,10 +6,10 @@ define('admin/manage/category', [
|
||||
'iconSelect',
|
||||
'admin/modules/colorpicker',
|
||||
'autocomplete'
|
||||
], function(uploader, iconSelect, colorpicker, autocomplete) {
|
||||
], function (uploader, iconSelect, colorpicker, autocomplete) {
|
||||
var Category = {};
|
||||
|
||||
Category.init = function() {
|
||||
Category.init = function () {
|
||||
var modified_categories = {};
|
||||
|
||||
function modified(el) {
|
||||
@@ -28,7 +28,7 @@ define('admin/manage/category', [
|
||||
e.preventDefault();
|
||||
|
||||
if(Object.keys(modified_categories).length) {
|
||||
socket.emit('admin.categories.update', modified_categories, function(err, result) {
|
||||
socket.emit('admin.categories.update', modified_categories, function (err, result) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ define('admin/manage/category', [
|
||||
}
|
||||
}
|
||||
|
||||
$('.blockclass, form.category select').each(function() {
|
||||
$('.blockclass, form.category select').each(function () {
|
||||
var $this = $(this);
|
||||
$this.val($this.attr('data-value'));
|
||||
});
|
||||
@@ -56,7 +56,7 @@ define('admin/manage/category', [
|
||||
var $inputEl = $(inputEl),
|
||||
previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
||||
|
||||
colorpicker.enable($inputEl, function(hsb, hex) {
|
||||
colorpicker.enable($inputEl, function (hsb, hex) {
|
||||
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||
previewEl.css('background-color', '#' + hex);
|
||||
} else if ($inputEl.attr('data-name') === 'color') {
|
||||
@@ -69,31 +69,31 @@ define('admin/manage/category', [
|
||||
|
||||
|
||||
$('form.category input, form.category select')
|
||||
.on('change', function(ev) {
|
||||
.on('change', function (ev) {
|
||||
modified(ev.target);
|
||||
})
|
||||
.on('keydown', function(ev) {
|
||||
.on('keydown', function (ev) {
|
||||
if (ev.which === 13) {
|
||||
ev.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-name="imageClass"]').on('change', function() {
|
||||
$('[data-name="imageClass"]').on('change', function () {
|
||||
$('.category-preview').css('background-size', $(this).val());
|
||||
});
|
||||
|
||||
$('[data-name="bgColor"], [data-name="color"]').each(enableColorPicker);
|
||||
|
||||
$('#save').on('click', save);
|
||||
$('.purge').on('click', function(e) {
|
||||
$('.purge').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
bootbox.confirm('<p class="lead">Do you really want to purge this category "' + $('form.category').find('input[data-name="name"]').val() + '"?</p><h5><strong class="text-danger">Warning!</strong> All topics and posts in this category will be purged!</h5> <p class="help-block">Purging a category will remove all topics and posts, and delete the category from the database. If you want to remove a category <em>temporarily</em>, you\'ll want to "disable" the category instead.</p>', function(confirm) {
|
||||
bootbox.confirm('<p class="lead">Do you really want to purge this category "' + $('form.category').find('input[data-name="name"]').val() + '"?</p><h5><strong class="text-danger">Warning!</strong> All topics and posts in this category will be purged!</h5> <p class="help-block">Purging a category will remove all topics and posts, and delete the category from the database. If you want to remove a category <em>temporarily</em>, you\'ll want to "disable" the category instead.</p>', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function(err) {
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -103,9 +103,9 @@ define('admin/manage/category', [
|
||||
});
|
||||
});
|
||||
|
||||
$('.copy-settings').on('click', function() {
|
||||
selectCategoryModal(function(cid) {
|
||||
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function(err) {
|
||||
$('.copy-settings').on('click', function () {
|
||||
selectCategoryModal(function (cid) {
|
||||
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ define('admin/manage/category', [
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.upload-button').on('click', function() {
|
||||
$('.upload-button').on('click', function () {
|
||||
var inputEl = $(this);
|
||||
var cid = inputEl.attr('data-cid');
|
||||
|
||||
@@ -124,7 +124,7 @@ define('admin/manage/category', [
|
||||
title: 'Upload category image',
|
||||
route: config.relative_path + '/api/admin/category/uploadpicture',
|
||||
params: {cid: cid}
|
||||
}, function(imageUrlOnServer) {
|
||||
}, function (imageUrlOnServer) {
|
||||
$('#category-image').val(imageUrlOnServer);
|
||||
var previewBox = inputEl.parent().parent().siblings('.category-preview');
|
||||
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
|
||||
@@ -133,11 +133,11 @@ define('admin/manage/category', [
|
||||
});
|
||||
});
|
||||
|
||||
$('#category-image').on('change', function() {
|
||||
$('#category-image').on('change', function () {
|
||||
$('.category-preview').css('background-image', $(this).val() ? ('url("' + $(this).val() + '")') : '');
|
||||
});
|
||||
|
||||
$('.delete-image').on('click', function(e) {
|
||||
$('.delete-image').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var inputEl = $('#category-image');
|
||||
@@ -149,18 +149,18 @@ define('admin/manage/category', [
|
||||
$(this).parent().addClass('hide').hide();
|
||||
});
|
||||
|
||||
$('.category-preview').on('click', function() {
|
||||
$('.category-preview').on('click', function () {
|
||||
iconSelect.init($(this).find('i'), modified);
|
||||
});
|
||||
|
||||
$('button[data-action="setParent"], button[data-action="changeParent"]').on('click', Category.launchParentSelector);
|
||||
$('button[data-action="removeParent"]').on('click', function() {
|
||||
$('button[data-action="removeParent"]').on('click', function () {
|
||||
var payload = {};
|
||||
payload[ajaxify.data.category.cid] = {
|
||||
parentCid: 0
|
||||
};
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
socket.emit('admin.categories.update', payload, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -173,8 +173,8 @@ define('admin/manage/category', [
|
||||
Category.setupPrivilegeTable();
|
||||
};
|
||||
|
||||
Category.setupPrivilegeTable = function() {
|
||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
||||
Category.setupPrivilegeTable = function () {
|
||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function () {
|
||||
var checkboxEl = $(this),
|
||||
privilege = checkboxEl.parent().attr('data-privilege'),
|
||||
state = checkboxEl.prop('checked'),
|
||||
@@ -185,7 +185,7 @@ define('admin/manage/category', [
|
||||
|
||||
if (member) {
|
||||
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
||||
bootbox.confirm('<strong>Are you sure you wish to grant the moderation privilege to this user group?</strong> This group is public, and any users can join at will.', function(confirm) {
|
||||
bootbox.confirm('<strong>Are you sure you wish to grant the moderation privilege to this user group?</strong> This group is public, and any users can join at will.', function (confirm) {
|
||||
if (confirm) {
|
||||
Category.setPrivilege(member, privilege, state, checkboxEl);
|
||||
} else {
|
||||
@@ -208,36 +208,36 @@ define('admin/manage/category', [
|
||||
Category.exposeAssumedPrivileges();
|
||||
};
|
||||
|
||||
Category.refreshPrivilegeTable = function() {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.data.category.cid, function(err, privileges) {
|
||||
Category.refreshPrivilegeTable = function () {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.data.category.cid, function (err, privileges) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/privileges', {
|
||||
privileges: privileges
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
$('.privilege-table-container').html(html);
|
||||
Category.exposeAssumedPrivileges();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Category.exposeAssumedPrivileges = function() {
|
||||
Category.exposeAssumedPrivileges = function () {
|
||||
/*
|
||||
If registered-users has a privilege enabled, then all users and groups of that privilege
|
||||
should be assumed to have that privilege as well, even if not set in the db, so reflect
|
||||
this arrangement in the table
|
||||
*/
|
||||
var privs = [];
|
||||
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function(idx, el) {
|
||||
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function (idx, el) {
|
||||
if ($(el).find('input').prop('checked')) {
|
||||
privs.push(el.getAttribute('data-privilege'));
|
||||
}
|
||||
});
|
||||
for(var x = 0,numPrivs = privs.length;x < numPrivs;x++) {
|
||||
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
|
||||
inputs.each(function(idx, el) {
|
||||
inputs.each(function (idx, el) {
|
||||
if (!el.checked) {
|
||||
el.indeterminate = true;
|
||||
}
|
||||
@@ -245,13 +245,13 @@ define('admin/manage/category', [
|
||||
}
|
||||
};
|
||||
|
||||
Category.setPrivilege = function(member, privilege, state, checkboxEl) {
|
||||
Category.setPrivilege = function (member, privilege, state, checkboxEl) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: privilege,
|
||||
set: state,
|
||||
member: member
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -261,25 +261,25 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.launchParentSelector = function() {
|
||||
socket.emit('categories.get', function(err, categories) {
|
||||
Category.launchParentSelector = function () {
|
||||
socket.emit('categories.get', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
categories = categories.filter(function(category) {
|
||||
categories = categories.filter(function (category) {
|
||||
return category && !category.disabled && parseInt(category.cid, 10) !== parseInt(ajaxify.data.category.cid, 10);
|
||||
});
|
||||
|
||||
templates.parse('partials/category_list', {
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
message: html,
|
||||
title: 'Set Parent Category'
|
||||
});
|
||||
|
||||
modal.find('li[data-cid]').on('click', function() {
|
||||
modal.find('li[data-cid]').on('click', function () {
|
||||
var parentCid = $(this).attr('data-cid'),
|
||||
payload = {};
|
||||
|
||||
@@ -287,11 +287,11 @@ define('admin/manage/category', [
|
||||
parentCid: parentCid
|
||||
};
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
socket.emit('admin.categories.update', payload, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
var parent = categories.filter(function(category) {
|
||||
var parent = categories.filter(function (category) {
|
||||
return category && parseInt(category.cid, 10) === parseInt(parentCid, 10);
|
||||
});
|
||||
parent = parent[0];
|
||||
@@ -307,23 +307,23 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.addUserToPrivilegeTable = function() {
|
||||
Category.addUserToPrivilegeTable = function () {
|
||||
var modal = bootbox.dialog({
|
||||
title: 'Find a User',
|
||||
message: '<input class="form-control input-lg" placeholder="Search for a user here..." />',
|
||||
show: true
|
||||
});
|
||||
|
||||
modal.on('shown.bs.modal', function() {
|
||||
modal.on('shown.bs.modal', function () {
|
||||
var inputEl = modal.find('input');
|
||||
|
||||
autocomplete.user(inputEl, function(ev, ui) {
|
||||
autocomplete.user(inputEl, function (ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['find', 'read', 'topics:read'],
|
||||
set: true,
|
||||
member: ui.item.user.uid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -335,23 +335,23 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.addGroupToPrivilegeTable = function() {
|
||||
Category.addGroupToPrivilegeTable = function () {
|
||||
var modal = bootbox.dialog({
|
||||
title: 'Find a Group',
|
||||
message: '<input class="form-control input-lg" placeholder="Search for a group here..." />',
|
||||
show: true
|
||||
});
|
||||
|
||||
modal.on('shown.bs.modal', function() {
|
||||
modal.on('shown.bs.modal', function () {
|
||||
var inputEl = modal.find('input');
|
||||
|
||||
autocomplete.group(inputEl, function(ev, ui) {
|
||||
autocomplete.group(inputEl, function (ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['groups:find', 'groups:read', 'groups:topics:read'],
|
||||
set: true,
|
||||
member: ui.item.group.name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -363,8 +363,8 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.copyPrivilegesToChildren = function() {
|
||||
socket.emit('admin.categories.copyPrivilegesToChildren', ajaxify.data.category.cid, function(err) {
|
||||
Category.copyPrivilegesToChildren = function () {
|
||||
socket.emit('admin.categories.copyPrivilegesToChildren', ajaxify.data.category.cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -372,9 +372,9 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.copyPrivilegesFromCategory = function() {
|
||||
selectCategoryModal(function(cid) {
|
||||
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function(err) {
|
||||
Category.copyPrivilegesFromCategory = function () {
|
||||
selectCategoryModal(function (cid) {
|
||||
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -384,14 +384,14 @@ define('admin/manage/category', [
|
||||
};
|
||||
|
||||
function selectCategoryModal(callback) {
|
||||
socket.emit('admin.categories.getNames', function(err, categories) {
|
||||
socket.emit('admin.categories.getNames', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/select-category', {
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
function submit() {
|
||||
var formData = modal.find('form').serializeObject();
|
||||
callback(formData['select-cid']);
|
||||
|
||||
Reference in New Issue
Block a user