mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
removed the rest of the .post-row selectors in favour for components system
This commit is contained in:
@@ -18,11 +18,11 @@ define('forum/topic/fork', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function disableClicksOnPosts() {
|
function disableClicksOnPosts() {
|
||||||
$('.post-row').on('click', 'button,a', disableClicks);
|
components.get('post').on('click', 'button,a', disableClicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableClicksOnPosts() {
|
function enableClicksOnPosts() {
|
||||||
$('.post-row').off('click', 'button,a', disableClicks);
|
components.get('post').off('click', 'button,a', disableClicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onForkThreadClicked() {
|
function onForkThreadClicked() {
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
};
|
};
|
||||||
|
|
||||||
function addVoteHandler() {
|
function addVoteHandler() {
|
||||||
components.get('topic').on('mouseenter', '.post-row .votes', function() {
|
components.get('topic').on('mouseenter', '[data-pid] .votes', function() {
|
||||||
loadDataAndCreateTooltip($(this));
|
loadDataAndCreateTooltip($(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadDataAndCreateTooltip(el) {
|
function loadDataAndCreateTooltip(el) {
|
||||||
var pid = el.parents('.post-row').attr('data-pid');
|
var pid = el.parents('[data-pid]').attr('data-pid');
|
||||||
socket.emit('posts.getUpvoters', [pid], function(err, data) {
|
socket.emit('posts.getUpvoters', [pid], function(err, data) {
|
||||||
if (!err && data.length) {
|
if (!err && data.length) {
|
||||||
createTooltip(el, data[0]);
|
createTooltip(el, data[0]);
|
||||||
@@ -185,7 +185,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleVote(button, className, method) {
|
function toggleVote(button, className, method) {
|
||||||
var post = button.parents('.post-row'),
|
var post = button.parents('[data-pid]'),
|
||||||
currentState = post.find(className).length;
|
currentState = post.find(className).length;
|
||||||
|
|
||||||
socket.emit(currentState ? 'posts.unvote' : method , {
|
socket.emit(currentState ? 'posts.unvote' : method , {
|
||||||
@@ -222,7 +222,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getData(button, data) {
|
function getData(button, data) {
|
||||||
return button.parents('.post-row').attr(data);
|
return button.parents('[data-pid]').attr(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserName(button) {
|
function getUserName(button) {
|
||||||
@@ -290,7 +290,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
});
|
});
|
||||||
|
|
||||||
moveBtn.on('click', function() {
|
moveBtn.on('click', function() {
|
||||||
movePost(button.parents('.post-row'), getData(button, 'data-pid'), topicId.val());
|
movePost(button.parents('[data-pid]'), getData(button, 'data-pid'), topicId.val());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openChat(button) {
|
function openChat(button) {
|
||||||
var post = button.parents('li.post-row');
|
var post = button.parents('data-pid');
|
||||||
|
|
||||||
app.openChat(post.attr('data-username'), post.attr('data-uid'));
|
app.openChat(post.attr('data-username'), post.attr('data-uid'));
|
||||||
button.parents('.btn-group').find('.dropdown-toggle').click();
|
button.parents('.btn-group').find('.dropdown-toggle').click();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ define('forum/topic/posts', [
|
|||||||
postcount.html(parseInt(postcount.html(), 10) + 1);
|
postcount.html(parseInt(postcount.html(), 10) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewPosts(data, '.post-row[data-index!="0"]', function(html) {
|
createNewPosts(data, components.get('post').not('[data-index=0]'), function(html) {
|
||||||
if (html) {
|
if (html) {
|
||||||
html.addClass('new');
|
html.addClass('new');
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ define('forum/topic/posts', [
|
|||||||
pagination.pageCount = Math.max(1, Math.ceil((posts[0].topic.postcount - 1) / config.postsPerPage));
|
pagination.pageCount = Math.max(1, Math.ceil((posts[0].topic.postcount - 1) / config.postsPerPage));
|
||||||
|
|
||||||
if (pagination.currentPage === pagination.pageCount) {
|
if (pagination.currentPage === pagination.pageCount) {
|
||||||
createNewPosts(data, '.post-row[data-index!="0"]', scrollToPost);
|
createNewPosts(data, components.get('post').not('[data-index=0]'), scrollToPost);
|
||||||
} else if (parseInt(posts[0].uid, 10) === parseInt(app.user.uid, 10)) {
|
} else if (parseInt(posts[0].uid, 10) === parseInt(app.user.uid, 10)) {
|
||||||
pagination.loadPage(pagination.pageCount, scrollToPost);
|
pagination.loadPage(pagination.pageCount, scrollToPost);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ define('forum/topic/posts', [
|
|||||||
// Save document height and position for future reference (about 5 lines down)
|
// Save document height and position for future reference (about 5 lines down)
|
||||||
var height = $(document).height(),
|
var height = $(document).height(),
|
||||||
scrollTop = $(document).scrollTop(),
|
scrollTop = $(document).scrollTop(),
|
||||||
originalPostEl = $('.post-row[data-index="0"]');
|
originalPostEl = components.get('post', 'index', 0);
|
||||||
|
|
||||||
// Insert the new post
|
// Insert the new post
|
||||||
html.insertBefore(before);
|
html.insertBefore(before);
|
||||||
@@ -164,7 +164,7 @@ define('forum/topic/posts', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleModTools(pid, privileges) {
|
function toggleModTools(pid, privileges) {
|
||||||
var postEl = $('.post-row[data-pid="' + pid + '"]');
|
var postEl = components.get('post', 'pid', pid);
|
||||||
|
|
||||||
if (!privileges.editable) {
|
if (!privileges.editable) {
|
||||||
postEl.find('.edit, .delete, .purge').remove();
|
postEl.find('.edit, .delete, .purge').remove();
|
||||||
@@ -208,7 +208,7 @@ define('forum/topic/posts', [
|
|||||||
indicatorEl.fadeOut();
|
indicatorEl.fadeOut();
|
||||||
|
|
||||||
if (data && data.posts && data.posts.length) {
|
if (data && data.posts && data.posts.length) {
|
||||||
createNewPosts(data, '.post-row[data-index!="0"]:not(.new)', done);
|
createNewPosts(data, components.get('post').not('[data-index=0]').not('.new'), done);
|
||||||
} else {
|
} else {
|
||||||
if (app.user.uid) {
|
if (app.user.uid) {
|
||||||
socket.emit('topics.markAsRead', [tid]);
|
socket.emit('topics.markAsRead', [tid]);
|
||||||
@@ -244,7 +244,7 @@ define('forum/topic/posts', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hidePostToolsForDeletedPosts(element) {
|
function hidePostToolsForDeletedPosts(element) {
|
||||||
element.find('.post-row.deleted').each(function() {
|
element.find('[data-pid].deleted').each(function() {
|
||||||
postTools.toggle($(this).attr('data-pid'), true);
|
postTools.toggle($(this).attr('data-pid'), true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ define('share', function() {
|
|||||||
|
|
||||||
function getPostUrl(clickedElement) {
|
function getPostUrl(clickedElement) {
|
||||||
var parts = window.location.pathname.split('/');
|
var parts = window.location.pathname.split('/');
|
||||||
var postIndex = parseInt(clickedElement.parents('.post-row').attr('data-index'), 10);
|
var postIndex = parseInt(clickedElement.parents('data-index').attr('data-index'), 10);
|
||||||
return '/' + parts[1] + '/' + parts[2] + (parts[3] ? '/' + parts[3] : '') + (postIndex ? '/' + (postIndex + 1) : '');
|
return '/' + parts[1] + '/' + parts[2] + (parts[3] ? '/' + parts[3] : '') + (postIndex ? '/' + (postIndex + 1) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user