diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json index 0bf297ce54..eef538f4bd 100644 --- a/public/language/en_GB/user.json +++ b/public/language/en_GB/user.json @@ -9,6 +9,7 @@ "age": "Age", "joined": "Joined", "lastonline": "Last Online", + "profile": "Profile", "profile_views": "Profile views", "reputation": "Reputation", "posts": "Posts", diff --git a/public/src/forum/account.js b/public/src/forum/account.js index 51f43d5ffb..f02cb17f29 100644 --- a/public/src/forum/account.js +++ b/public/src/forum/account.js @@ -88,11 +88,7 @@ define(['forum/accountheader'], function(header) { return; } - translator.get('global:' + data.status, function(translated) { - onlineStatus.find('span span').text(translated); - onlineStatus.find('i').attr('class', 'fa fa-circle status ' + data.status); - }); - + onlineStatus.attr('class', 'account-online-status fa fa-circle status ' + data.status); }; return Account; diff --git a/public/src/forum/accountedit.js b/public/src/forum/accountedit.js index bffa7660c0..b33d8f2d4a 100644 --- a/public/src/forum/accountedit.js +++ b/public/src/forum/accountedit.js @@ -42,7 +42,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) { $('.account-username-box a').each(function(index) { $(this).attr('href', $(this).attr('href').replace(oldslug, data.userslug)); }); - $('.account-username a:first-child').html(userData.username); + $('.account-username-box').attr('data-userslug', data.userslug); $('#user-profile-link').attr('href', config.relative_path + '/user/' + data.userslug); diff --git a/public/src/forum/accountheader.js b/public/src/forum/accountheader.js index 1f5c552783..291d25e050 100644 --- a/public/src/forum/accountheader.js +++ b/public/src/forum/accountheader.js @@ -2,45 +2,60 @@ define(function() { var AccountHeader = {}; AccountHeader.init = function() { - var yourid = templates.get('yourid'), - theirid = templates.get('theirid'); + AccountHeader.createMenu(); + hideLinks(); + + selectActivePill(); + } + + AccountHeader.createMenu = function() { + var userslug = $('.account-username-box').attr('data-userslug'); + + var html =''; + + + translator.translate(html, function(translatedHtml) { + $('.account-username-box').append(translatedHtml); + selectActivePill(); + hideLinks(); + }); + } + + function hideLinks() { + var yourid = templates.get('yourid'), + theirid = templates.get('theirid'); + var editLink = $('#editLink'); var settingsLink = $('#settingsLink'); var favouritesLink = $('#favouritesLink'); - if (yourid === "0" || yourid !== theirid) { + if (parseInt(yourid, 10) === 0 || parseInt(yourid, 10) !== parseInt(theirid, 10)) { editLink.hide(); settingsLink.hide(); favouritesLink.hide(); } + } - jQuery('.account-sub-links span a').removeClass('bold').each(function() { - var href = this.getAttribute('href'); + function selectActivePill() { + $('.account-sub-links li').removeClass('active').each(function() { + var href = $(this).find('a').attr('href'); if (window.location.href.indexOf(href) !== -1) { - jQuery(this).addClass('bold'); + $(this).addClass('active'); return false; } }); } - AccountHeader.createMenu = function() { - var userslug = $('.account-username-box').attr('data-userslug'); - - var html = '' - - translator.translate(html, function(translatedHtml) { - $('.account-username-box').append(translatedHtml); - }); - } - return AccountHeader; }); \ No newline at end of file diff --git a/public/src/forum/accountposts.js b/public/src/forum/accountposts.js new file mode 100644 index 0000000000..76b2991b88 --- /dev/null +++ b/public/src/forum/accountposts.js @@ -0,0 +1,52 @@ +define(['forum/accountheader'], function(header) { + var AccountPosts = {}, + loadingMore = false; + + AccountPosts.init = function() { + header.init(); + + app.enableInfiniteLoading(function() { + if(!loadingMore) { + loadMore(); + } + }); + }; + + function loadMore() { + loadingMore = true; + socket.emit('posts.loadMoreUserPosts', { + uid: $('.account-username-box').attr('data-uid'), + after: $('.user-favourite-posts').attr('data-nextstart') + }, function(err, data) { + if(err) { + return app.alertError(err.message); + } + + if (data.posts && data.posts.length) { + onTopicsLoaded(data.posts); + $('.user-favourite-posts').attr('data-nextstart', data.nextStart); + } + + loadingMore = false; + }); + } + + function onTopicsLoaded(posts) { + var html = templates.prepare(templates['accountposts'].blocks['posts']).parse({ + posts: posts + }); + + translator.translate(html, function(translatedHTML) { + + $('#category-no-topics').remove(); + + html = $(translatedHTML); + $('.user-favourite-posts').append(html); + $('span.timeago').timeago(); + app.createUserTooltips(); + app.makeNumbersHumanReadable(html.find('.human-readable-number')); + }); + } + + return AccountPosts; +}); \ No newline at end of file diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 4bcb96b7df..f2b05763bc 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -2,112 +2,119 @@
- +
-