changes to admin/users

v1.18.x
Baris Soner Usakli 12 years ago
parent 4103e1db55
commit 419e5ab528

@ -329,7 +329,7 @@ footer.footer {
margin-top: 20px; margin-top: 20px;
text-align: center; text-align: center;
vertical-align: top; vertical-align: top;
max-width: 103px; max-width: 84px;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;

@ -30,11 +30,9 @@
<i class='icon-pencil'></i> <i class='icon-pencil'></i>
</div> </div>
<div> <div>
<a href="#" class="btn make-admin-btn" data-admin="{users.administrator}">Make Admin</a> <a href="#" class="btn admin-btn" data-admin="{users.administrator}" data-username="{users.username}">Admin</a>
</div>
<div>
<a href="#" class="btn remove-admin-btn" data-admin="{users.administrator}">Remove Admin</a>
</div> </div>
</div> </div>
<!-- END users --> <!-- END users -->
@ -60,56 +58,42 @@
} }
}); });
jQuery('.make-admin-btn').each(function(index, element) { jQuery('.admin-btn').each(function(index, element) {
var adminBtn = $(element); var adminBtn = $(element);
var isAdmin = adminBtn.attr('data-admin') !== "0"; var isAdmin = adminBtn.attr('data-admin') !== "0";
if(isAdmin) if(isAdmin)
adminBtn.hide(); adminBtn.addClass('btn-success');
else else
adminBtn.show(); adminBtn.removeClass('btn-success');
}); });
jQuery('.remove-admin-btn').each(function(index, element) { jQuery('.admin-btn').on('click', function() {
var adminBtn = $(element); var adminBtn = $(this);
var isAdmin = adminBtn.attr('data-admin') !== "0"; var isAdmin = adminBtn.attr('data-admin') !== "0";
var parent = adminBtn.parents('.users-box'); var parent = adminBtn.parents('.users-box');
var uid = parent.attr('data-uid');
if(isAdmin && uid != yourid)
adminBtn.show();
else
adminBtn.hide();
});
jQuery('.make-admin-btn').on('click', function() {
var makeBtn = $(this);
var parent = makeBtn.parents('.users-box');
var removeBtn = parent.find('.remove-admin-btn');
var uid = parent.attr('data-uid'); var uid = parent.attr('data-uid');
socket.emit('api:admin.user.makeAdmin', uid); if(isAdmin) {
makeBtn.hide(); socket.emit('api:admin.user.removeAdmin', uid);
removeBtn.show(); adminBtn.removeClass('btn-success');
return false; adminBtn.attr('data-admin', 0);
}); }
else {
jQuery('.remove-admin-btn').on('click', function() { bootbox.confirm('Do you really want to make "' + adminBtn.attr('data-username') +'" an admin?', function(confirm) {
if(confirm) {
socket.emit('api:admin.user.makeAdmin', uid);
adminBtn.addClass('btn-success');
adminBtn.attr('data-admin', 1);
}
});
}
var removeBtn = $(this);
var parent = removeBtn.parents('.users-box');
var makeBtn = parent.find('.make-admin-btn');
var uid = parent.attr('data-uid');
socket.emit('api:admin.user.removeAdmin', uid);
makeBtn.show();
removeBtn.hide();
return false; return false;
}); });
}); });
}()); }());

Loading…
Cancel
Save