Skip to content

Node.js based forum software built for the modern web

fix: #7798, fix nested post selection

Barış Soner Uşaklı666e0eaff9ad
diff --git a/public/src/modules/postSelect.js b/public/src/modules/postSelect.js
index a44420e2d3..d2ca3ff81c 100644
--- a/public/src/modules/postSelect.js
+++ b/public/src/modules/postSelect.js
@@ -18,8 +18,14 @@ define('postSelect', ['components'], function (components) {
disableClicksOnPosts();
};
- function onPostClicked() {
- PostSelect.togglePostSelection($(this));
+ function onPostClicked(ev) {
+ ev.stopPropagation();
+ var pidClicked = $(this).attr('data-pid');
+ var postEls = $('[component="topic"] [data-pid="' + pidClicked + '"]');
+ if (!allowMainPostSelect && parseInt($(this).attr('data-index'), 10) === 0) {
+ return;
+ }
+ PostSelect.togglePostSelection(postEls, pidClicked);
}
PostSelect.disable = function () {
@@ -31,21 +37,15 @@ define('postSelect', ['components'], function (components) {
enableClicksOnPosts();
};
- PostSelect.togglePostSelection = function (post) {
- var newPid = post.attr('data-pid');
-
- if (!allowMainPostSelect && parseInt(post.attr('data-index'), 10) === 0) {
- return;
- }
-
- if (newPid) {
- var index = PostSelect.pids.indexOf(newPid);
+ PostSelect.togglePostSelection = function (postEls, pid) {
+ if (pid) {
+ var index = PostSelect.pids.indexOf(pid);
if (index === -1) {
- PostSelect.pids.push(newPid);
- post.toggleClass('bg-success', true);
+ PostSelect.pids.push(pid);
+ postEls.toggleClass('bg-success', true);
} else {
PostSelect.pids.splice(index, 1);
- post.toggleClass('bg-success', false);
+ postEls.toggleClass('bg-success', false);
}
if (PostSelect.pids.length) {
@@ -57,7 +57,6 @@ define('postSelect', ['components'], function (components) {
}
};
-
function disableClicks() {
return false;
}