scroll to post 2

v1.18.x
Baris Soner Usakli 12 years ago
parent 720dd9e960
commit 7297a26685

@ -71,6 +71,9 @@ var ajaxify = {};
jQuery('#content, #footer').stop(true, true).fadeIn(200, function() { jQuery('#content, #footer').stop(true, true).fadeIn(200, function() {
console.log('done loading'); console.log('done loading');
if(window.location.hash)
hash = window.location.hash;
if(hash)
app.scrollToPost(hash.substr(1)); app.scrollToPost(hash.substr(1));
}); });

@ -302,6 +302,7 @@ var socket,
} }
app.createNewPosts = function(data) { app.createNewPosts = function(data) {
console.log('creating new posts');
data.posts[0].display_moderator_tools = 'none'; data.posts[0].display_moderator_tools = 'none';
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data), var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
uniqueid = new Date().getTime(), uniqueid = new Date().getTime(),
@ -327,7 +328,7 @@ var socket,
app.loadMorePosts = function(tid, callback) { app.loadMorePosts = function(tid, callback) {
if(app.infiniteLoaderActive) if(app.infiniteLoaderActive)
return; return;
infiniteLoaderActive = true; app.infiniteLoaderActive = true;
socket.emit('api:topic.loadMore', { socket.emit('api:topic.loadMore', {
tid: tid, tid: tid,
after: document.querySelectorAll('#post-container li[data-pid]').length after: document.querySelectorAll('#post-container li[data-pid]').length
@ -355,9 +356,6 @@ var socket,
return; return;
} }
//container.scrollTop(
// scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height()
//);
container.animate({ container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height() scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height()
}); });

@ -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>' + 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>' + '<p>' +
'<strong>' + posts[i].username + '</strong>: ' + posts[i].content + '<strong>' + posts[i].username + '</strong>: ' + posts[i].content +
'</p>' + '</p>' +

@ -57,15 +57,19 @@ var RDB = require('./redis.js'),
function getPostSummary(pid, callback) { function getPostSummary(pid, callback) {
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) { 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);
} }
Posts.addUserInfoToPost(postData, function() {
topics.getTopicField(postData.tid, 'slug', function(topicSlug) {
postData.topicSlug = topicSlug;
returnData.push(postData);
callback(null); callback(null);
}); });
}); });
});
} }
async.eachSeries(pids, getPostSummary, function(err) { async.eachSeries(pids, getPostSummary, function(err) {

Loading…
Cancel
Save