mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-27 06:40:37 +01:00
closes #6957
This commit is contained in:
@@ -6,15 +6,19 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function (compo
|
||||
var modal;
|
||||
var deleteBtn;
|
||||
var purgeBtn;
|
||||
var tid;
|
||||
|
||||
DeletePosts.init = function () {
|
||||
tid = ajaxify.data.tid;
|
||||
$('.topic').on('click', '[component="topic/delete/posts"]', onDeletePostsClicked);
|
||||
$(window).on('action:ajaxify.start', onAjaxifyStart);
|
||||
$(window).off('action:ajaxify.end', onAjaxifyEnd).on('action:ajaxify.end', onAjaxifyEnd);
|
||||
};
|
||||
|
||||
function onAjaxifyStart() {
|
||||
closeModal();
|
||||
$(window).off('action:ajaxify.start', onAjaxifyStart);
|
||||
function onAjaxifyEnd() {
|
||||
if (ajaxify.data.template.name !== 'topic' || ajaxify.data.tid !== tid) {
|
||||
closeModal();
|
||||
$(window).off('action:ajaxify.end', onAjaxifyEnd);
|
||||
}
|
||||
}
|
||||
|
||||
function onDeletePostsClicked() {
|
||||
@@ -84,8 +88,8 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function (compo
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
modal = null;
|
||||
postSelect.disable();
|
||||
}
|
||||
postSelect.disable();
|
||||
}
|
||||
|
||||
return DeletePosts;
|
||||
|
||||
@@ -5,15 +5,18 @@ define('forum/topic/fork', ['components', 'postSelect'], function (components, p
|
||||
var Fork = {};
|
||||
var forkModal;
|
||||
var forkCommit;
|
||||
|
||||
var fromTid;
|
||||
Fork.init = function () {
|
||||
fromTid = ajaxify.data.tid;
|
||||
$('.topic').on('click', '[component="topic/fork"]', onForkThreadClicked);
|
||||
$(window).on('action:ajaxify.start', onAjaxifyStart);
|
||||
$(window).off('action:ajaxify.end', onAjaxifyEnd).on('action:ajaxify.end', onAjaxifyEnd);
|
||||
};
|
||||
|
||||
function onAjaxifyStart() {
|
||||
closeForkModal();
|
||||
$(window).off('action:ajaxify.start', onAjaxifyStart);
|
||||
function onAjaxifyEnd() {
|
||||
if (ajaxify.data.template.name !== 'topic' || ajaxify.data.tid !== fromTid) {
|
||||
closeForkModal();
|
||||
$(window).off('action:ajaxify.end', onAjaxifyEnd);
|
||||
}
|
||||
}
|
||||
|
||||
function onForkThreadClicked() {
|
||||
@@ -46,7 +49,7 @@ define('forum/topic/fork', ['components', 'postSelect'], function (components, p
|
||||
socket.emit('topics.createTopicFromPosts', {
|
||||
title: forkModal.find('#fork-title').val(),
|
||||
pids: postSelect.pids,
|
||||
fromTid: ajaxify.data.tid,
|
||||
fromTid: fromTid,
|
||||
}, function (err, newTopic) {
|
||||
function fadeOutAndRemove(pid) {
|
||||
components.get('post', 'pid', pid).fadeOut(500, function () {
|
||||
@@ -96,9 +99,8 @@ define('forum/topic/fork', ['components', 'postSelect'], function (components, p
|
||||
if (forkModal) {
|
||||
forkModal.remove();
|
||||
forkModal = null;
|
||||
postSelect.disable();
|
||||
}
|
||||
|
||||
postSelect.disable();
|
||||
}
|
||||
|
||||
return Fork;
|
||||
|
||||
@@ -9,14 +9,8 @@ define('forum/topic/move-post', ['components', 'postSelect'], function (componen
|
||||
|
||||
MovePost.init = function () {
|
||||
$('.topic').on('click', '[component="topic/move-posts"]', onMovePostsClicked);
|
||||
$(window).on('action:ajaxify.start', onAjaxifyStart);
|
||||
};
|
||||
|
||||
function onAjaxifyStart() {
|
||||
closeMoveModal();
|
||||
$(window).off('action:ajaxify.start', onAjaxifyStart);
|
||||
}
|
||||
|
||||
function onMovePostsClicked() {
|
||||
MovePost.openMovePostModal();
|
||||
}
|
||||
@@ -38,6 +32,9 @@ define('forum/topic/move-post', ['components', 'postSelect'], function (componen
|
||||
}
|
||||
|
||||
MovePost.openMovePostModal = function (postEl) {
|
||||
if (moveModal) {
|
||||
return;
|
||||
}
|
||||
app.parseAndTranslate('partials/move_post_modal', {}, function (html) {
|
||||
moveModal = html;
|
||||
|
||||
@@ -85,9 +82,8 @@ define('forum/topic/move-post', ['components', 'postSelect'], function (componen
|
||||
if (moveModal) {
|
||||
moveModal.remove();
|
||||
moveModal = null;
|
||||
postSelect.disable();
|
||||
}
|
||||
|
||||
postSelect.disable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,26 +3,31 @@
|
||||
|
||||
define('postSelect', ['components'], function (components) {
|
||||
var PostSelect = {};
|
||||
var onSelect;
|
||||
|
||||
PostSelect.pids = [];
|
||||
|
||||
PostSelect.init = function (onSelect) {
|
||||
PostSelect.init = function (_onSelect) {
|
||||
PostSelect.pids.length = 0;
|
||||
components.get('topic').on('click', '[data-pid]', function () {
|
||||
PostSelect.togglePostSelection($(this), onSelect);
|
||||
});
|
||||
onSelect = _onSelect;
|
||||
$('#content').on('click', '[component="topic"] [component="post"]', onPostClicked);
|
||||
disableClicksOnPosts();
|
||||
};
|
||||
|
||||
function onPostClicked() {
|
||||
PostSelect.togglePostSelection($(this));
|
||||
}
|
||||
|
||||
PostSelect.disable = function () {
|
||||
PostSelect.pids.forEach(function (pid) {
|
||||
components.get('post', 'pid', pid).toggleClass('bg-success', false);
|
||||
});
|
||||
components.get('topic').off('click', '[data-pid]');
|
||||
|
||||
$('#content').off('click', '[component="topic"] [component="post"]', onPostClicked);
|
||||
enableClicksOnPosts();
|
||||
};
|
||||
|
||||
PostSelect.togglePostSelection = function (post, callback) {
|
||||
PostSelect.togglePostSelection = function (post) {
|
||||
var newPid = post.attr('data-pid');
|
||||
|
||||
if (parseInt(post.attr('data-index'), 10) === 0) {
|
||||
@@ -42,7 +47,9 @@ define('postSelect', ['components'], function (components) {
|
||||
if (PostSelect.pids.length) {
|
||||
PostSelect.pids.sort(function (a, b) { return a - b; });
|
||||
}
|
||||
callback();
|
||||
if (typeof onSelect === 'function') {
|
||||
onSelect();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,11 +59,11 @@ define('postSelect', ['components'], function (components) {
|
||||
}
|
||||
|
||||
function disableClicksOnPosts() {
|
||||
components.get('post').on('click', 'button,a', disableClicks);
|
||||
$('#content').on('click', '[component="post"] button, [component="post"] a', disableClicks);
|
||||
}
|
||||
|
||||
function enableClicksOnPosts() {
|
||||
components.get('post').off('click', 'button,a', disableClicks);
|
||||
$('#content').off('click', '[component="post"] button, [component="post"] a', disableClicks);
|
||||
}
|
||||
|
||||
return PostSelect;
|
||||
|
||||
Reference in New Issue
Block a user