|
|
@ -23,6 +23,7 @@ define('forum/topic/move-post', [
|
|
|
|
$('body').append(moveModal);
|
|
|
|
$('body').append(moveModal);
|
|
|
|
|
|
|
|
|
|
|
|
moveModal.find('.close,#move_posts_cancel').on('click', closeMoveModal);
|
|
|
|
moveModal.find('.close,#move_posts_cancel').on('click', closeMoveModal);
|
|
|
|
|
|
|
|
moveModal.find('#topicId').on('keyup', utils.debounce(checkMoveButtonEnable, 200));
|
|
|
|
postSelect.init(onPostToggled);
|
|
|
|
postSelect.init(onPostToggled);
|
|
|
|
showPostsSelected();
|
|
|
|
showPostsSelected();
|
|
|
|
|
|
|
|
|
|
|
@ -30,17 +31,18 @@ define('forum/topic/move-post', [
|
|
|
|
postSelect.togglePostSelection(postEl, postEl.attr('data-pid'));
|
|
|
|
postSelect.togglePostSelection(postEl, postEl.attr('data-pid'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(window).off('action:ajaxify.end', checkMoveButtonEnable)
|
|
|
|
$(window).off('action:ajaxify.end', onAjaxifyEnd)
|
|
|
|
.on('action:ajaxify.end', checkMoveButtonEnable);
|
|
|
|
.on('action:ajaxify.end', onAjaxifyEnd);
|
|
|
|
|
|
|
|
|
|
|
|
moveCommit.on('click', function () {
|
|
|
|
moveCommit.on('click', function () {
|
|
|
|
if (!ajaxify.data.template.topic || !ajaxify.data.tid) {
|
|
|
|
const targetTid = getTargetTid();
|
|
|
|
|
|
|
|
if (!targetTid) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
moveCommit.attr('disabled', true);
|
|
|
|
moveCommit.attr('disabled', true);
|
|
|
|
var data = {
|
|
|
|
var data = {
|
|
|
|
pids: postSelect.pids.slice(),
|
|
|
|
pids: postSelect.pids.slice(),
|
|
|
|
tid: ajaxify.data.tid,
|
|
|
|
tid: targetTid,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
alerts.alert({
|
|
|
|
alerts.alert({
|
|
|
|
alert_id: 'pids_move_' + postSelect.pids.join('-'),
|
|
|
|
alert_id: 'pids_move_' + postSelect.pids.join('-'),
|
|
|
@ -61,14 +63,45 @@ define('forum/topic/move-post', [
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onAjaxifyEnd() {
|
|
|
|
|
|
|
|
if (!moveModal) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var tidInput = moveModal.find('#topicId');
|
|
|
|
|
|
|
|
var targetTid = null;
|
|
|
|
|
|
|
|
if (ajaxify.data.template.topic && ajaxify.data.tid &&
|
|
|
|
|
|
|
|
parseInt(ajaxify.data.tid, 10) !== fromTid
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
targetTid = ajaxify.data.tid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targetTid && !tidInput.val()) {
|
|
|
|
|
|
|
|
tidInput.val(targetTid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
checkMoveButtonEnable();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getTargetTid() {
|
|
|
|
|
|
|
|
var tidInput = moveModal.find('#topicId');
|
|
|
|
|
|
|
|
if (tidInput.length && tidInput.val()) {
|
|
|
|
|
|
|
|
return tidInput.val();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ajaxify.data.template.topic && ajaxify.data.tid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showPostsSelected() {
|
|
|
|
function showPostsSelected() {
|
|
|
|
if (!moveModal) {
|
|
|
|
if (!moveModal) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var targetTid = getTargetTid();
|
|
|
|
if (postSelect.pids.length) {
|
|
|
|
if (postSelect.pids.length) {
|
|
|
|
if (ajaxify.data.template.topic && ajaxify.data.tid && ajaxify.data.tid !== fromTid) {
|
|
|
|
if (targetTid && parseInt(targetTid, 10) !== parseInt(fromTid, 10)) {
|
|
|
|
var translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, ajaxify.data.title);
|
|
|
|
api.get('/topics/' + targetTid, {}).then(function (data) {
|
|
|
|
moveModal.find('#pids').translateHtml(translateStr);
|
|
|
|
if (!data || !data.tid) {
|
|
|
|
|
|
|
|
return app.alertError('[[error:no-topic]]');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, data.title);
|
|
|
|
|
|
|
|
moveModal.find('#pids').translateHtml(translateStr);
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
moveModal.find('#pids').translateHtml('[[topic:x-posts-selected, ' + postSelect.pids.length + ']]');
|
|
|
|
moveModal.find('#pids').translateHtml('[[topic:x-posts-selected, ' + postSelect.pids.length + ']]');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -81,9 +114,9 @@ define('forum/topic/move-post', [
|
|
|
|
if (!moveModal) {
|
|
|
|
if (!moveModal) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var targetTid = getTargetTid();
|
|
|
|
if (postSelect.pids.length && ajaxify.data.tid &&
|
|
|
|
if (postSelect.pids.length && targetTid &&
|
|
|
|
ajaxify.data.template.topic && ajaxify.data.tid !== fromTid
|
|
|
|
parseInt(targetTid, 10) !== parseInt(fromTid, 10)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
moveCommit.removeAttr('disabled');
|
|
|
|
moveCommit.removeAttr('disabled');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -97,7 +130,7 @@ define('forum/topic/move-post', [
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function movePosts(data) {
|
|
|
|
function movePosts(data) {
|
|
|
|
if (!ajaxify.data.template.topic || !data.tid) {
|
|
|
|
if (!data.tid) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -119,6 +152,7 @@ define('forum/topic/move-post', [
|
|
|
|
moveModal.remove();
|
|
|
|
moveModal.remove();
|
|
|
|
moveModal = null;
|
|
|
|
moveModal = null;
|
|
|
|
postSelect.disable();
|
|
|
|
postSelect.disable();
|
|
|
|
|
|
|
|
$(window).off('action:ajaxify.end', onAjaxifyEnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|