diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 6e8e651d19..5e25ce5c78 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -118,7 +118,8 @@ var ajaxify = {}; } head.insertBefore(script, head.firstChild); - head.removeChild(script); + //TODO: remove from head before inserting?, doing this breaks scripts in safari so commented out for now + //head.removeChild(script); }; var scripts = [], diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js new file mode 100644 index 0000000000..7906579950 --- /dev/null +++ b/public/src/forum/admin/users.js @@ -0,0 +1,104 @@ + +(function() { + jQuery('document').ready(function() { + + var yourid = templates.get('yourid'); + + var url = window.location.href, + parts = url.split('/'), + active = parts[parts.length-1]; + + jQuery('.nav-pills li').removeClass('active'); + jQuery('.nav-pills li a').each(function() { + if (this.getAttribute('href').match(active)) { + jQuery(this.parentNode).addClass('active'); + return false; + } + }); + + jQuery('#search-user').on('keyup', function () { + console.log('derp'); + jQuery('.icon-spinner').removeClass('none'); + console.log($('#search-user').val()); + socket.emit('api:admin.user.search', $('#search-user').val()); + }); + + + + + + function isUserAdmin(element) { + var parent = $(element).parents('.users-box'); + return (parent.attr('data-admin') !== "0"); + } + + function getUID(element) { + var parent = $(element).parents('.users-box'); + return parent.attr('data-uid'); + } + + jQuery('.admin-btn').each(function(index, element) { + var adminBtn = $(element); + var isAdmin = isUserAdmin(adminBtn); + + if(isAdmin) + adminBtn.addClass('btn-success'); + else + adminBtn.removeClass('btn-success'); + + }); + + jQuery('.delete-btn').each(function(index, element) { + var deleteBtn = $(element); + var isAdmin = isUserAdmin(deleteBtn); + + if(isAdmin) + deleteBtn.addClass('disabled'); + else + deleteBtn.show(); + }); + + jQuery('.admin-btn').on('click', function() { + var adminBtn = $(this); + var isAdmin = isUserAdmin(adminBtn); + var parent = adminBtn.parents('.users-box'); + var uid = getUID(adminBtn); + + if(isAdmin) { + socket.emit('api:admin.user.removeAdmin', uid); + adminBtn.removeClass('btn-success'); + parent.find('.delete-btn').removeClass('disabled'); + parent.attr('data-admin', 0); + } + else { + bootbox.confirm('Do you really want to make "' + parent.attr('data-username') +'" an admin?', function(confirm) { + if(confirm) { + socket.emit('api:admin.user.makeAdmin', uid); + adminBtn.addClass('btn-success'); + parent.find('.delete-btn').addClass('disabled'); + parent.attr('data-admin', 1); + } + }); + } + + return false; + }); + + jQuery('.delete-btn').on('click', function() { + var deleteBtn = $(this); + var isAdmin = isUserAdmin(deleteBtn); + var parent = deleteBtn.parents('.users-box'); + var uid = getUID(deleteBtn); + + if(!isAdmin) { + bootbox.confirm('Do you really want to delete "' + parent.attr('data-username') +'"?', function(confirm) { + socket.emit('api:admin.user.deleteUser', uid); + }); + } + + return false; + }); + + }); + +}()); \ No newline at end of file diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 6403518721..f3d40432f9 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -132,6 +132,9 @@ socket.emit('api:notifications.hasFlag'); + + + require(['mobileMenu'], function(mobileMenu) { mobileMenu.init(); }); diff --git a/public/src/forum/login.js b/public/src/forum/login.js index 6e83c0b9f2..12370b0ef0 100644 --- a/public/src/forum/login.js +++ b/public/src/forum/login.js @@ -1,3 +1,5 @@ + + (function() { // Alternate Logins var altLoginEl = document.querySelector('.alt-logins'); @@ -12,7 +14,6 @@ } }); - $('#login').on('click', function() { var loginData = { @@ -32,9 +33,11 @@ error : function(data, textStatus, jqXHR) { $('#login-error-notify').show().delay(1000).fadeOut(250); }, - dataType: 'json' + dataType: 'json', + async: true, + timeout: 2000 }); - + return false; }); diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl index 065996d200..21ef16da22 100644 --- a/public/templates/admin/header.tpl +++ b/public/templates/admin/header.tpl @@ -63,7 +63,7 @@
  • Home
  • Categories
  • -
  • Users
  • +
  • Users
  • Topics
  • Themes
  • Settings
  • diff --git a/public/templates/admin/index.tpl b/public/templates/admin/index.tpl index ab022f15b7..7d1d74fce0 100644 --- a/public/templates/admin/index.tpl +++ b/public/templates/admin/index.tpl @@ -41,4 +41,9 @@ app.enter_room('admin'); socket.emit('api:get_all_rooms'); + + socket.on('api:admin.user.search', function(data) { + console.log(data); + }); + \ No newline at end of file diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl index 8251eeef48..bac6328897 100644 --- a/public/templates/admin/users.tpl +++ b/public/templates/admin/users.tpl @@ -1,7 +1,7 @@

    Users