fix: #7798, fix nested post selection

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 8bf40d04c9
commit 666e0eaff9

@ -18,8 +18,14 @@ define('postSelect', ['components'], function (components) {
disableClicksOnPosts(); disableClicksOnPosts();
}; };
function onPostClicked() { function onPostClicked(ev) {
PostSelect.togglePostSelection($(this)); 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 () { PostSelect.disable = function () {
@ -31,21 +37,15 @@ define('postSelect', ['components'], function (components) {
enableClicksOnPosts(); enableClicksOnPosts();
}; };
PostSelect.togglePostSelection = function (post) { PostSelect.togglePostSelection = function (postEls, pid) {
var newPid = post.attr('data-pid'); if (pid) {
var index = PostSelect.pids.indexOf(pid);
if (!allowMainPostSelect && parseInt(post.attr('data-index'), 10) === 0) {
return;
}
if (newPid) {
var index = PostSelect.pids.indexOf(newPid);
if (index === -1) { if (index === -1) {
PostSelect.pids.push(newPid); PostSelect.pids.push(pid);
post.toggleClass('bg-success', true); postEls.toggleClass('bg-success', true);
} else { } else {
PostSelect.pids.splice(index, 1); PostSelect.pids.splice(index, 1);
post.toggleClass('bg-success', false); postEls.toggleClass('bg-success', false);
} }
if (PostSelect.pids.length) { if (PostSelect.pids.length) {
@ -57,7 +57,6 @@ define('postSelect', ['components'], function (components) {
} }
}; };
function disableClicks() { function disableClicks() {
return false; return false;
} }

Loading…
Cancel
Save