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.",
|
||||
"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) {
|
||||
var Account = {};
|
||||
|
||||
@@ -8,7 +12,6 @@ define(['forum/accountheader'], function(header) {
|
||||
theirid = ajaxify.variables.get('theirid'),
|
||||
isFollowing = ajaxify.variables.get('isFollowing');
|
||||
|
||||
$(document).ready(function() {
|
||||
var username = $('.account-username').html();
|
||||
app.enterRoom('user/' + theirid);
|
||||
|
||||
@@ -16,67 +19,45 @@ define(['forum/accountheader'], function(header) {
|
||||
utils.makeNumbersHumanReadable($('.account .human-readable-number'));
|
||||
$('.user-recent-posts img').addClass('img-responsive');
|
||||
|
||||
var followBtn = $('#follow-btn');
|
||||
var unfollowBtn = $('#unfollow-btn');
|
||||
var chatBtn = $('#chat-btn');
|
||||
|
||||
if (yourid !== theirid && yourid !== "0") {
|
||||
if (isFollowing) {
|
||||
followBtn.addClass('hide');
|
||||
unfollowBtn.removeClass('hide');
|
||||
} else {
|
||||
followBtn.removeClass('hide');
|
||||
unfollowBtn.addClass('hide');
|
||||
}
|
||||
chatBtn.removeClass('hide');
|
||||
} else {
|
||||
followBtn.addClass('hide');
|
||||
unfollowBtn.addClass('hide');
|
||||
chatBtn.addClass('hide');
|
||||
}
|
||||
var isSelfOrNotLoggedIn = yourid === theirid || yourid === '0';
|
||||
$('#follow-btn').toggleClass('hide', isFollowing || isSelfOrNotLoggedIn);
|
||||
$('#unfollow-btn').toggleClass('hide', !isFollowing || isSelfOrNotLoggedIn);
|
||||
$('#chat-btn').toggleClass('hide', isSelfOrNotLoggedIn);
|
||||
|
||||
followBtn.on('click', function() {
|
||||
socket.emit('user.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;
|
||||
$('#follow-btn').on('click', function() {
|
||||
return toggleFollow('follow');
|
||||
});
|
||||
|
||||
unfollowBtn.on('click', function() {
|
||||
socket.emit('user.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;
|
||||
$('#unfollow-btn').on('click', function() {
|
||||
return toggleFollow('unfollow');
|
||||
});
|
||||
|
||||
chatBtn.on('click', function() {
|
||||
$('#chat-btn').on('click', function() {
|
||||
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');
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return Account;
|
||||
});
|
||||
|
||||
@@ -23,9 +23,9 @@ define(['forum/accountheader'], function(header) {
|
||||
|
||||
socket.emit('user.saveSettings', settings, function(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;
|
||||
|
||||
Reference in New Issue
Block a user