mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-09-02 02:26:30 +02:00
scroll to post 2
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
});
|
||||
|
||||
@@ -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>' +
|
||||
|
||||
16
src/posts.js
16
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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user