From dc7be481212f1ba3e7e286f310c9b400a8bd4e31 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 3 Nov 2015 17:27:11 -0500 Subject: [PATCH] account/follow, account/unfollow, account/chat components --- public/src/client/account/header.js | 27 +++++++++++++++++++++++++++ public/src/client/account/profile.js | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js index 6b3ec29377..eed177b1d7 100644 --- a/public/src/client/account/header.js +++ b/public/src/client/account/header.js @@ -20,6 +20,18 @@ define('forum/account/header', [ if (parseInt(yourid, 10) === parseInt(theirid, 10)) { setupCoverPhoto(); } + + components.get('account/follow').on('click', function() { + return toggleFollow('follow'); + }); + + components.get('account/unfollow').on('click', function() { + return toggleFollow('unfollow'); + }); + + components.get('account/chat').on('click', function() { + app.openChat($('.account-username').html(), theirid); + }); }; function hidePrivateLinks() { @@ -56,5 +68,20 @@ define('forum/account/header', [ ); } + function toggleFollow(type) { + socket.emit('user.' + type, { + uid: theirid + }, function(err) { + if (err) { + return app.alertError(err.message); + } + + $('#follow-btn').toggleClass('hide', type === 'follow'); + $('#unfollow-btn').toggleClass('hide', type === 'unfollow'); + app.alertSuccess('[[global:alert.' + type + ', ' + $('.account-username').html() + ']]'); + }); + return false; + } + return AccountHeader; }); diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index 8301cff314..080e1b0d56 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -23,21 +23,8 @@ define('forum/account/profile', [ app.enterRoom('user/' + theirid); processPage(); - updateButtons(); - $('#follow-btn').on('click', function() { - return toggleFollow('follow'); - }); - - $('#unfollow-btn').on('click', function() { - return toggleFollow('unfollow'); - }); - - $('#chat-btn').on('click', function() { - app.openChat($('.account-username').html(), theirid); - }); - $('#banAccountBtn').on('click', banAccount); $('#unbanAccountBtn').on('click', unbanAccount); $('#deleteAccountBtn').on('click', deleteAccount); @@ -59,21 +46,6 @@ define('forum/account/profile', [ $('#chat-btn').toggleClass('hide', isSelfOrNotLoggedIn); } - function toggleFollow(type) { - socket.emit('user.' + type, { - uid: theirid - }, function(err) { - if (err) { - return app.alertError(err.message); - } - - $('#follow-btn').toggleClass('hide', type === 'follow'); - $('#unfollow-btn').toggleClass('hide', type === 'unfollow'); - app.alertSuccess('[[global:alert.' + type + ', ' + $('.account-username').html() + ']]'); - }); - return false; - } - function onUserStatusChange(data) { if (parseInt(ajaxify.data.theirid, 10) !== parseInt(data.uid, 10)) { return;