mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
some cleanup
This commit is contained in:
@@ -19,7 +19,8 @@ define(['composer'], function(composer) {
|
|||||||
},
|
},
|
||||||
topic_name = templates.get('topic_name'),
|
topic_name = templates.get('topic_name'),
|
||||||
currentPage = parseInt(templates.get('currentPage'), 10),
|
currentPage = parseInt(templates.get('currentPage'), 10),
|
||||||
pageCount = parseInt(templates.get('pageCount'), 10);
|
pageCount = parseInt(templates.get('pageCount'), 10),
|
||||||
|
Topic.postCount = templates.get('postcount');
|
||||||
|
|
||||||
|
|
||||||
function fixDeleteStateForPosts() {
|
function fixDeleteStateForPosts() {
|
||||||
@@ -40,7 +41,8 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
showBottomPostBar();
|
showBottomPostBar();
|
||||||
|
|
||||||
// Resetting thread state
|
updateHeader();
|
||||||
|
|
||||||
if (thread_state.locked === '1') set_locked_state(true);
|
if (thread_state.locked === '1') set_locked_state(true);
|
||||||
if (thread_state.deleted === '1') set_delete_state(true);
|
if (thread_state.deleted === '1') set_delete_state(true);
|
||||||
if (thread_state.pinned === '1') set_pinned_state(true);
|
if (thread_state.pinned === '1') set_pinned_state(true);
|
||||||
@@ -329,17 +331,6 @@ define(['composer'], function(composer) {
|
|||||||
Topic.scrollToPost(parseInt(bookmark, 10));
|
Topic.scrollToPost(parseInt(bookmark, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the paginator block, now that the DOM has finished loading
|
|
||||||
(function delayedHeaderUpdate() {
|
|
||||||
if (!Topic.postCount) {
|
|
||||||
setTimeout(function() {
|
|
||||||
delayedHeaderUpdate();
|
|
||||||
}, 25);
|
|
||||||
} else {
|
|
||||||
updateHeader();
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
$('#post-container').on('mouseenter', '.favourite-tooltip', function(e) {
|
$('#post-container').on('mouseenter', '.favourite-tooltip', function(e) {
|
||||||
if (!$(this).data('users-loaded')) {
|
if (!$(this).data('users-loaded')) {
|
||||||
$(this).data('users-loaded', "true");
|
$(this).data('users-loaded', "true");
|
||||||
@@ -389,7 +380,7 @@ define(['composer'], function(composer) {
|
|||||||
$('.pagination .previous').addClass('disabled');
|
$('.pagination .previous').addClass('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentPage === parseInt($('.pagination').attr('data-pageCount'), 10)) {
|
if(currentPage === pageCount) {
|
||||||
$('.pagination .next').addClass('disabled');
|
$('.pagination .next').addClass('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,6 +394,11 @@ define(['composer'], function(composer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(page === 1) {
|
||||||
|
ajaxify.go('topic/' + tid );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
socket.emit('topics.loadPage', {tid: tid, page: page}, function(err, data) {
|
socket.emit('topics.loadPage', {tid: tid, page: page}, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
@@ -451,11 +447,7 @@ define(['composer'], function(composer) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
parseAndTranslatePosts(data.posts, function(translatedHTML) {
|
||||||
var regexp = new RegExp("<!--[\\s]*IF @first[\\s]*-->([\\s\\S]*?)<!--[\\s]*ENDIF @first[\\s]*-->", 'g');
|
|
||||||
html = html.replace(regexp, '');
|
|
||||||
|
|
||||||
translator.translate(html, function(translatedHTML) {
|
|
||||||
var translated = $(translatedHTML);
|
var translated = $(translatedHTML);
|
||||||
|
|
||||||
$('#post-container').fadeOut(function() {
|
$('#post-container').fadeOut(function() {
|
||||||
@@ -464,22 +456,7 @@ define(['composer'], function(composer) {
|
|||||||
translated.appendTo($(this));
|
translated.appendTo($(this));
|
||||||
$(this).fadeIn('slow');
|
$(this).fadeIn('slow');
|
||||||
|
|
||||||
for (var x = 0, numPosts = data.posts.length; x < numPosts; x++) {
|
onNewPostsLoaded(data.posts);
|
||||||
socket.emit('posts.getPrivileges', data.posts[x].pid, function(err, privileges) {
|
|
||||||
if(err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
toggle_mod_tools(privileges.pid, privileges.editable);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
app.populateOnlineUsers();
|
|
||||||
app.createUserTooltips();
|
|
||||||
app.addCommasToNumbers();
|
|
||||||
$('span.timeago').timeago();
|
|
||||||
$('.post-content img').addClass('img-responsive');
|
|
||||||
updatePostCount();
|
|
||||||
showBottomPostBar();
|
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
@@ -554,7 +531,7 @@ define(['composer'], function(composer) {
|
|||||||
var pid = $(this).parents('.post-row').attr('data-pid');
|
var pid = $(this).parents('.post-row').attr('data-pid');
|
||||||
$('#post_' + pid + '_link').val(window.location.href + "#" + pid);
|
$('#post_' + pid + '_link').val(window.location.href + "#" + pid);
|
||||||
// without the setTimeout can't select the text in the input
|
// without the setTimeout can't select the text in the input
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
$('#post_' + pid + '_link').select();
|
$('#post_' + pid + '_link').select();
|
||||||
}, 50);
|
}, 50);
|
||||||
});
|
});
|
||||||
@@ -1064,8 +1041,6 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Topic.postCount = templates.get('postcount');
|
|
||||||
|
|
||||||
window.onscroll = updateHeader;
|
window.onscroll = updateHeader;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1186,6 +1161,7 @@ define(['composer'], function(composer) {
|
|||||||
function findInsertionPoint() {
|
function findInsertionPoint() {
|
||||||
var after = null,
|
var after = null,
|
||||||
firstPid = data.posts[0].pid;
|
firstPid = data.posts[0].pid;
|
||||||
|
|
||||||
$('#post-container li[data-pid]').each(function() {
|
$('#post-container li[data-pid]').each(function() {
|
||||||
if(parseInt(firstPid, 10) > parseInt($(this).attr('data-pid'), 10)) {
|
if(parseInt(firstPid, 10) > parseInt($(this).attr('data-pid'), 10)) {
|
||||||
after = $(this);
|
after = $(this);
|
||||||
@@ -1206,11 +1182,7 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
var insertAfter = findInsertionPoint();
|
var insertAfter = findInsertionPoint();
|
||||||
|
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
parseAndTranslatePosts(data.posts, function(translatedHTML) {
|
||||||
var regexp = new RegExp("<!--[\\s]*IF @first[\\s]*-->([\\s\\S]*?)<!--[\\s]*ENDIF @first[\\s]*-->", 'g');
|
|
||||||
html = html.replace(regexp, '');
|
|
||||||
|
|
||||||
translator.translate(html, function(translatedHTML) {
|
|
||||||
var translated = $(translatedHTML);
|
var translated = $(translatedHTML);
|
||||||
|
|
||||||
if(!infiniteLoaded) {
|
if(!infiniteLoaded) {
|
||||||
@@ -1221,8 +1193,22 @@ define(['composer'], function(composer) {
|
|||||||
.hide()
|
.hide()
|
||||||
.fadeIn('slow');
|
.fadeIn('slow');
|
||||||
|
|
||||||
for (var x = 0, numPosts = data.posts.length; x < numPosts; x++) {
|
onNewPostsLoaded(data.posts);
|
||||||
socket.emit('posts.getPrivileges', data.posts[x].pid, function(err, privileges) {
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseAndTranslatePosts(posts, callback) {
|
||||||
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse({posts: posts});
|
||||||
|
var regexp = new RegExp("<!--[\\s]*IF @first[\\s]*-->([\\s\\S]*?)<!--[\\s]*ENDIF @first[\\s]*-->", 'g');
|
||||||
|
html = html.replace(regexp, '');
|
||||||
|
|
||||||
|
translator.translate(html, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onNewPostsLoaded(posts) {
|
||||||
|
for (var x = 0, numPosts = posts.length; x < numPosts; x++) {
|
||||||
|
socket.emit('posts.getPrivileges', posts[x].pid, function(err, privileges) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
@@ -1239,9 +1225,9 @@ define(['composer'], function(composer) {
|
|||||||
$('.post-content img').addClass('img-responsive');
|
$('.post-content img').addClass('img-responsive');
|
||||||
updatePostCount();
|
updatePostCount();
|
||||||
showBottomPostBar();
|
showBottomPostBar();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggle_mod_tools(pid, state) {
|
function toggle_mod_tools(pid, state) {
|
||||||
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
|
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
|
||||||
editEl = postEl.find('.edit'),
|
editEl = postEl.find('.edit'),
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
postContainer.css('visibility', 'visible')
|
postContainer.css('visibility', 'visible')
|
||||||
.css('z-index', 1);
|
.css('z-index', 2);
|
||||||
|
|
||||||
$('body').css({'margin-bottom': postContainer.css('height')});
|
$('body').css({'margin-bottom': postContainer.css('height')});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user