Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/user-edit.js

57 lines
2.2 KiB
JavaScript
Raw Normal View History

$('.group-all').change(function () {
const v = $(this).is(':checked');
const items = $(this).parent().next('ul').children();
items.each(function () {
$(this).find('input[type=checkbox]').prop('checked', v);
});
});
$('input[type=checkbox]:not(.group-all)').change(function () {
const groupAll = $(this).parent().parent().prev('h4').find('.group-all');
if (!$(this).is(':checked')) {
groupAll.prop('checked', false);
} else {
const siblings = $(this).parent().siblings().find('input[type=checkbox]:not(:checked)');
if (siblings.length === 0) {
groupAll.prop('checked', true);
}
}
});
function checkSiblings() {
}
$(function () {
});
const ranks = [1, 2, 3, 6, 7, 8, 9, 10];
const rankPresets = {
1: [],
2: ['user.disableAds'],
3: [],
6: ['blog.view', 'blog.create', 'blog.editOwn', 'dashboard.view'],
7: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf'],
8: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf', 'user.view', 'user.deletePost', 'user.warn', 'reports.receive', 'feedback.receive', 'feedback.reply', 'contact.view', 'contact.answer'],
9: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf', 'blog.deleteOwnFinally', 'blog.deleteFinally', 'projects.view', 'user.changeRank', 'user.editPermissions'],
10: ['projects.create', 'projects.editOwn', 'projects.edit', 'projects.deleteOwn', 'projects.delete', 'projects.deleteCategory', 'file.view', 'file.upload', 'file.uploadManually', 'file.delete', 'redirect.view', 'redirect.create', 'redirect.edit', 'redirect.delete', 'user.ban', 'user.viewDetails', 'dashboard.detailView'],
};
$('input[name=rank]').change(function () {
const activeRank = parseInt($(this).val());
$('.perm-box').prop('checked', false);
for (let rank of ranks) {
if (rank > activeRank)
break;
rankPresets[rank].forEach(perm => {
const el = $('#' + perm.replace('.', ''));
const value = !el.is(':checked');
el.prop('checked', value);
});
}
});