mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
some more language strings and account.js refactor
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"topic-post": "You have successfully posted.",
|
"topic-post": "You have successfully posted.",
|
||||||
"authentication-successful": "Authentication Successful"
|
"authentication-successful": "Authentication Successful",
|
||||||
|
"settings-saved": "Settings saved!"
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* globals define, ajaxify, app, utils, socket, translator*/
|
||||||
|
|
||||||
define(['forum/accountheader'], function(header) {
|
define(['forum/accountheader'], function(header) {
|
||||||
var Account = {};
|
var Account = {};
|
||||||
|
|
||||||
@@ -8,7 +12,6 @@ define(['forum/accountheader'], function(header) {
|
|||||||
theirid = ajaxify.variables.get('theirid'),
|
theirid = ajaxify.variables.get('theirid'),
|
||||||
isFollowing = ajaxify.variables.get('isFollowing');
|
isFollowing = ajaxify.variables.get('isFollowing');
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var username = $('.account-username').html();
|
var username = $('.account-username').html();
|
||||||
app.enterRoom('user/' + theirid);
|
app.enterRoom('user/' + theirid);
|
||||||
|
|
||||||
@@ -16,67 +19,45 @@ define(['forum/accountheader'], function(header) {
|
|||||||
utils.makeNumbersHumanReadable($('.account .human-readable-number'));
|
utils.makeNumbersHumanReadable($('.account .human-readable-number'));
|
||||||
$('.user-recent-posts img').addClass('img-responsive');
|
$('.user-recent-posts img').addClass('img-responsive');
|
||||||
|
|
||||||
var followBtn = $('#follow-btn');
|
|
||||||
var unfollowBtn = $('#unfollow-btn');
|
|
||||||
var chatBtn = $('#chat-btn');
|
|
||||||
|
|
||||||
if (yourid !== theirid && yourid !== "0") {
|
var isSelfOrNotLoggedIn = yourid === theirid || yourid === '0';
|
||||||
if (isFollowing) {
|
$('#follow-btn').toggleClass('hide', isFollowing || isSelfOrNotLoggedIn);
|
||||||
followBtn.addClass('hide');
|
$('#unfollow-btn').toggleClass('hide', !isFollowing || isSelfOrNotLoggedIn);
|
||||||
unfollowBtn.removeClass('hide');
|
$('#chat-btn').toggleClass('hide', isSelfOrNotLoggedIn);
|
||||||
} else {
|
|
||||||
followBtn.removeClass('hide');
|
|
||||||
unfollowBtn.addClass('hide');
|
|
||||||
}
|
|
||||||
chatBtn.removeClass('hide');
|
|
||||||
} else {
|
|
||||||
followBtn.addClass('hide');
|
|
||||||
unfollowBtn.addClass('hide');
|
|
||||||
chatBtn.addClass('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
followBtn.on('click', function() {
|
$('#follow-btn').on('click', function() {
|
||||||
socket.emit('user.follow', {
|
return toggleFollow('follow');
|
||||||
uid: theirid
|
|
||||||
}, function(err) {
|
|
||||||
if(err) {
|
|
||||||
return app.alertError('There was an error following' + username + '!');
|
|
||||||
}
|
|
||||||
|
|
||||||
followBtn.addClass('hide');
|
|
||||||
unfollowBtn.removeClass('hide');
|
|
||||||
app.alertSuccess('[[global:alert.follow, ' + username + ']]');
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
unfollowBtn.on('click', function() {
|
$('#unfollow-btn').on('click', function() {
|
||||||
socket.emit('user.unfollow', {
|
return toggleFollow('unfollow');
|
||||||
uid: theirid
|
|
||||||
}, function(err) {
|
|
||||||
if(err) {
|
|
||||||
return app.alertError('There was an error unfollowing ' + username + '!');
|
|
||||||
}
|
|
||||||
|
|
||||||
followBtn.removeClass('hide');
|
|
||||||
unfollowBtn.addClass('hide');
|
|
||||||
app.alertSuccess('[[global:alert.unfollow, ' + username + ']]');
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
chatBtn.on('click', function() {
|
$('#chat-btn').on('click', function() {
|
||||||
app.openChat(username, theirid);
|
app.openChat(username, theirid);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('user.isOnline', Account.handleUserOnline);
|
socket.on('user.isOnline', handleUserOnline);
|
||||||
|
|
||||||
socket.emit('user.isOnline', theirid, Account.handleUserOnline);
|
socket.emit('user.isOnline', theirid, handleUserOnline);
|
||||||
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Account.handleUserOnline = function(err, data) {
|
function toggleFollow(type) {
|
||||||
|
socket.emit('user.' + type, {
|
||||||
|
uid: ajaxify.variables.get('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 handleUserOnline(err, data) {
|
||||||
var onlineStatus = $('.account-online-status');
|
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)) {
|
||||||
@@ -89,7 +70,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
.attr('data-original-title', translated);
|
.attr('data-original-title', translated);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
return Account;
|
return Account;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ define(['forum/accountheader'], function(header) {
|
|||||||
|
|
||||||
socket.emit('user.saveSettings', settings, function(err) {
|
socket.emit('user.saveSettings', settings, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError('There was an error saving settings!');
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
app.alertSuccess('Settings saved!');
|
app.alertSuccess('[[success:settings-saved]]');
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user