From 25483e376f370795ef45552b91feb74c036e839c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 31 Jul 2014 20:25:52 -0400 Subject: [PATCH] fix online users page insert users before the anon box if there is one --- public/src/forum/users.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/public/src/forum/users.js b/public/src/forum/users.js index 35c68f18cb..e30ab1ae33 100644 --- a/public/src/forum/users.js +++ b/public/src/forum/users.js @@ -163,21 +163,29 @@ define('forum/users', function() { } function updateUser(data) { - var userEl = $('#users-container li[data-uid="' + data.uid +'"]'); + var usersContainer = $('#users-container'); + var userEl = usersContainer.find('li[data-uid="' + data.uid +'"]'); if (!data.online) { userEl.remove(); - } else { - ajaxify.loadTemplate('users', function(usersTemplate) { - var html = templates.parse(templates.getBlock(usersTemplate, 'users'), {users: [data]}); - translator.translate(html, function(translated) { - if (!userEl.length) { - $('#users-container').append(translated); - } else { - userEl.replaceWith(translated); - } - }); - }); + return; } + + ajaxify.loadTemplate('users', function(usersTemplate) { + var html = templates.parse(templates.getBlock(usersTemplate, 'users'), {users: [data]}); + translator.translate(html, function(translated) { + if (userEl.length) { + userEl.replaceWith(translated); + return; + } + + var anonBox = usersContainer.find('li.anon-user'); + if (anonBox.length) { + $(translated).insertBefore(anonBox); + } else { + usersContainer.append(translated); + } + }); + }); } function updateAnonCount() {