Node.js based forum software built for the modern web
scroll to post 2
Baris Soner Usakli7297a2668564
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex aa63a1d3fa..cbdd0a965c 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -71,7 +71,10 @@ var ajaxify = {};jQuery('#content, #footer').stop(true, true).fadeIn(200, function() {console.log('done loading');- app.scrollToPost(hash.substr(1));+ if(window.location.hash)+ hash = window.location.hash;+ if(hash)+ app.scrollToPost(hash.substr(1));});}, url, template);diff --git a/public/src/app.js b/public/src/app.jsindex 91df13efa2..601edb7fea 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -302,6 +302,7 @@ var socket,}app.createNewPosts = function(data) {+ console.log('creating new posts');data.posts[0].display_moderator_tools = 'none';var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),uniqueid = new Date().getTime(),@@ -327,7 +328,7 @@ var socket,app.loadMorePosts = function(tid, callback) {if(app.infiniteLoaderActive)return;- infiniteLoaderActive = true;+ app.infiniteLoaderActive = true;socket.emit('api:topic.loadMore', {tid: tid,after: document.querySelectorAll('#post-container li[data-pid]').length@@ -354,10 +355,7 @@ var socket,});return;}-- //container.scrollTop(- // scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height()- //);+container.animate({scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height()});diff --git a/public/src/forum/category.js b/public/src/forum/category.jsindex 08f9602fa3..eb3b34c450 100644--- a/public/src/forum/category.js+++ b/public/src/forum/category.js@@ -80,7 +80,7 @@li.innerHTML = '<a href="/users/' + posts[i].userslug + '"><img title="' + posts[i].username + '" style="width: 48px; height: 48px; /*temporary*/" class="img-polaroid" src="' + posts[i].picture + '" class="" /></a>' +- '<a href="/topic/'+ posts[i].tid + '">' ++ '<a href="/topic/'+ posts[i].topicSlug + '#' + posts[i].pid + '">' +'<p>' +'<strong>' + posts[i].username + '</strong>: ' + posts[i].content +'</p>' +diff --git a/src/posts.js b/src/posts.jsindex 192c9d536d..e9d5ae6a4d 100644--- a/src/posts.js+++ b/src/posts.js@@ -57,14 +57,18 @@ var RDB = require('./redis.js'),function getPostSummary(pid, callback) {Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) {- Posts.addUserInfoToPost(postData, function() {+ if(postData.deleted === '1') {+ return;+ }- if(postData.deleted !== '1') {- returnData.push(postData);- }-- callback(null);+ Posts.addUserInfoToPost(postData, function() {+ topics.getTopicField(postData.tid, 'slug', function(topicSlug) {+ postData.topicSlug = topicSlug;+ returnData.push(postData);+ callback(null);+ });});+});}