From dadbda98b703454b2524a07e4c5c6bbc1c6bee59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 7 Apr 2015 13:45:46 -0400 Subject: [PATCH] closes https://github.com/NodeBB/nodebb-theme-persona/issues/52 --- public/src/app.js | 13 +++++++++++++ public/src/client/account/profile.js | 11 ++--------- public/src/client/chats.js | 11 +---------- public/src/client/topic/browsing.js | 13 ++----------- public/src/client/users.js | 13 ++----------- public/src/modules/chat.js | 12 ++---------- 6 files changed, 22 insertions(+), 51 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index 4f2c848c0b..0460e440d7 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -473,6 +473,19 @@ app.cacheBuster = null; }); } + app.updateUserStatus = function(el, status) { + if (!el.length) { + return; + } + + translator.translate('[[global:' + status + ']]', function(translated) { + el.removeClass('online offline dnd away') + .addClass(status) + .attr('title', translated) + .attr('data-original-title', translated); + }); + }; + function handleNewTopic() { $('#content').on('click', '#new_topic', function() { require(['composer'], function(composer) { diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index b65b998d60..263b1ae873 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -69,18 +69,11 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll', } function onUserStatusChange(data) { - var onlineStatus = $('.account-online-status'); - - if(parseInt(ajaxify.variables.get('theirid'), 10) !== parseInt(data.uid, 10)) { + if (parseInt(ajaxify.variables.get('theirid'), 10) !== parseInt(data.uid, 10)) { return; } - translator.translate('[[global:' + data.status + ']]', function(translated) { - onlineStatus.attr('class', 'account-online-status fa fa-circle status ' + data.status) - .attr('title', translated) - .attr('data-original-title', translated); - }); - + app.updateUserStatus($('.account [component="user/status"]'), data.status); } function loadMorePosts(direction) { diff --git a/public/src/client/chats.js b/public/src/client/chats.js index d506d81654..2e9221023f 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -163,16 +163,7 @@ define('forum/chats', ['string', 'sounds', 'forum/infinitescroll', 'translator'] }); socket.on('event:user_status_change', function(data) { - var userEl = $('.chats-list li[data-uid="' + data.uid +'"]'); - - if (userEl.length) { - var statusEl = userEl.find('.status'); - translator.translate('[[global:' + data.status + ']]', function(translated) { - statusEl.attr('class', 'fa fa-circle status ' + data.status) - .attr('title', translated) - .attr('data-original-title', translated); - }); - } + app.updateUserStatus($('.chats-list [data-uid="' + data.uid + '"] [component="user/status"]'), data.status); }); }; diff --git a/public/src/client/topic/browsing.js b/public/src/client/topic/browsing.js index 2a0eb1eac5..2c125ba4ec 100644 --- a/public/src/client/topic/browsing.js +++ b/public/src/client/topic/browsing.js @@ -12,7 +12,7 @@ define('forum/topic/browsing', ['translator'], function(translator) { if (data && data.room.indexOf('topic_' + ajaxify.variables.get('topic_id')) !== -1) { $('[component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length); for(var i=0; i