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..efb200c896 100644 --- a/public/src/forum/account.js +++ b/public/src/forum/account.js @@ -13,6 +13,7 @@ define(['forum/accountheader'], function(header) { app.enterRoom('user/' + theirid); app.addCommasToNumbers(); + app.makeNumbersHumanReadable($('.account .human-readable-number')); $('.user-recent-posts img').addClass('img-responsive'); var followBtn = $('#follow-btn'); @@ -88,11 +89,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,43 +2,58 @@ define(function() { var AccountHeader = {}; AccountHeader.init = function() { - var yourid = templates.get('yourid'), - theirid = templates.get('theirid'); + AccountHeader.createMenu(); - var editLink = $('#editLink'); - var settingsLink = $('#settingsLink'); - var favouritesLink = $('#favouritesLink'); + hideLinks(); - if (yourid === "0" || yourid !== theirid) { - editLink.hide(); - settingsLink.hide(); - favouritesLink.hide(); - } - - jQuery('.account-sub-links span a').removeClass('bold').each(function() { - var href = this.getAttribute('href'); - if (window.location.href.indexOf(href) !== -1) { - jQuery(this).addClass('bold'); - return false; - } - }); + selectActivePill(); } AccountHeader.createMenu = function() { var userslug = $('.account-username-box').attr('data-userslug'); - var html = '' + 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 (parseInt(yourid, 10) === 0 || parseInt(yourid, 10) !== parseInt(theirid, 10)) { + editLink.hide(); + settingsLink.hide(); + favouritesLink.hide(); + } + } + + function selectActivePill() { + $('.account-sub-links li').removeClass('active').each(function() { + var href = $(this).find('a').attr('href'); + if (window.location.href.indexOf(href) !== -1) { + $(this).addClass('active'); + return false; + } }); } 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/src/forum/topic.js b/public/src/forum/topic.js index f877870b1e..a532693cc8 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -296,7 +296,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { set_follow_state = function(state, quiet) { if (state && !followEl.hasClass('btn-success')) { followEl.addClass('btn-success'); - followEl[0].title = 'You are currently receiving updates to this topic'; + followEl.attr('title', 'You are currently receiving updates to this topic'); if (!quiet) { app.alert({ alert_id: 'topic_follow', @@ -308,7 +308,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { } } else if (!state && followEl.hasClass('btn-success')) { followEl.removeClass('btn-success'); - followEl[0].title = 'Be notified of new replies in this topic'; + followEl.attr('title', 'Be notified of new replies in this topic'); if (!quiet) { app.alert({ alert_id: 'topic_follow', @@ -325,23 +325,23 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { set_follow_state(state, true); }); - if (followEl[0]) { - followEl[0].addEventListener('click', function() { - socket.emit('topics.follow', tid, function(err, state) { - if(err) { - return app.alert({ - type: 'danger', - alert_id: 'topic_follow', - title: 'Please Log In', - message: 'Please register or log in in order to subscribe to this topic', - timeout: 5000 - }); - } + followEl.on('click', function() { + socket.emit('topics.follow', tid, function(err, state) { + if(err) { + return app.alert({ + type: 'danger', + alert_id: 'topic_follow', + title: 'Please Log In', + message: 'Please register or log in in order to subscribe to this topic', + timeout: 5000 + }); + } - set_follow_state(state); - }); - }, false); - } + set_follow_state(state); + }); + + return false; + }); enableInfiniteLoading(); @@ -438,16 +438,22 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { pid: pid, room_id: app.currentRoom }); + + return false; }); $('#post-container').on('click', '.flag', function() { - var pid = $(this).parents('.post-row').attr('data-pid'); + bootbox.confirm('Are you sure you want to flag this post?', function(confirm) { + if (confirm) { + var pid = $(this).parents('.post-row').attr('data-pid'); - socket.emit('posts.flag', pid, function(err) { - if(err) { - return app.alertError(err.message); + socket.emit('posts.flag', pid, function(err) { + if(err) { + return app.alertError(err.message); + } + app.alertSuccess('This post has been flagged for moderation.'); + }); } - app.alertSuccess('This post has been flagged for moderation.'); }); }); diff --git a/public/src/forum/users.js b/public/src/forum/users.js index 378e786e66..f4e9ff988d 100644 --- a/public/src/forum/users.js +++ b/public/src/forum/users.js @@ -109,13 +109,13 @@ define(function() { function loadMoreUsers() { var set = ''; - if (active === 'latest' || active === 'users') { + if (active === 'latest') { set = 'users:joindate'; } else if (active === 'sort-posts') { set = 'users:postcount'; } else if (active === 'sort-reputation') { set = 'users:reputation'; - } else if (active === 'online') { + } else if (active === 'online' || active === 'users') { set = 'users:online'; } diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 1cf14248ed..5b7d710151 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -244,6 +244,9 @@ define(['taskbar'], function(taskbar) { var selector = $(this).attr('data-pane'); postContainer.find('.tab-content div').removeClass('active'); postContainer.find(selector).addClass('active'); + if(selector === '.tab-write') { + bodyEl.focus(); + } return false; }); diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 4bcb96b7df..efdc406c7c 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -1,102 +1,103 @@ +
+ +
+
-
- -
-
- +