|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
define('forum/topic/move', function () {
|
|
|
|
|
var Move = {};
|
|
|
|
|
var modal;
|
|
|
|
|
var selectedEl;
|
|
|
|
|
var selectedCategory;
|
|
|
|
|
|
|
|
|
|
Move.init = function (tids, currentCid, onComplete) {
|
|
|
|
|
Move.tids = tids;
|
|
|
|
@ -31,8 +31,17 @@ define('forum/topic/move', function () {
|
|
|
|
|
modal.find('.modal-header h3').translateText('[[topic:move_topics]]');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modal.on('click', '.category-list li[data-cid]', function () {
|
|
|
|
|
selectCategory($(this));
|
|
|
|
|
modal.find('#select-cid').on('change', function () {
|
|
|
|
|
var cid = $(this).val();
|
|
|
|
|
var optionEl = $(this).find('option[value="' + cid + '"]');
|
|
|
|
|
|
|
|
|
|
var selectedCategory = {
|
|
|
|
|
cid: cid,
|
|
|
|
|
name: optionEl.attr('data-name'),
|
|
|
|
|
text: optionEl.text(),
|
|
|
|
|
icon: optionEl.attr('data-icon'),
|
|
|
|
|
};
|
|
|
|
|
selectCategory(selectedCategory);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.find('#move_thread_commit').on('click', onCommitClicked);
|
|
|
|
@ -42,60 +51,25 @@ define('forum/topic/move', function () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseModal(categories, callback) {
|
|
|
|
|
templates.parse('partials/move_thread_modal', { categories: [] }, function (html) {
|
|
|
|
|
require(['translator'], function (translator) {
|
|
|
|
|
translator.translate(html, function (html) {
|
|
|
|
|
modal = $(html);
|
|
|
|
|
categories.forEach(function (category) {
|
|
|
|
|
if (!category.link) {
|
|
|
|
|
buildRecursive(modal.find('.category-list'), category, '');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildRecursive(parentEl, category, level) {
|
|
|
|
|
var categoryEl = $('<li/>');
|
|
|
|
|
app.parseAndTranslate('partials/move_thread_modal', { categories: categories }, function (html) {
|
|
|
|
|
modal = $(html);
|
|
|
|
|
|
|
|
|
|
if (category.bgColor) {
|
|
|
|
|
categoryEl.css('background-color', category.bgColor);
|
|
|
|
|
}
|
|
|
|
|
if (category.color) {
|
|
|
|
|
categoryEl.css('color', category.color);
|
|
|
|
|
}
|
|
|
|
|
categoryEl.toggleClass('disabled', !!category.disabled);
|
|
|
|
|
categoryEl.attr('data-cid', category.cid);
|
|
|
|
|
categoryEl.attr('data-icon', category.icon);
|
|
|
|
|
categoryEl.attr('data-name', category.name);
|
|
|
|
|
categoryEl.html('<i class="fa fa-fw ' + category.icon + '"></i> ' + category.name);
|
|
|
|
|
|
|
|
|
|
parentEl.append(level);
|
|
|
|
|
parentEl.append(categoryEl);
|
|
|
|
|
parentEl.append('<br/>');
|
|
|
|
|
|
|
|
|
|
var indent = ' ';
|
|
|
|
|
category.children.forEach(function (childCategory) {
|
|
|
|
|
if (!childCategory.link) {
|
|
|
|
|
buildRecursive(parentEl, childCategory, indent + level);
|
|
|
|
|
}
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectCategory(category) {
|
|
|
|
|
modal.find('#confirm-category-name').html(category.html());
|
|
|
|
|
modal.find('#confirm-category-name').text(category.name);
|
|
|
|
|
modal.find('#move-confirm').removeClass('hide');
|
|
|
|
|
|
|
|
|
|
selectedEl = category;
|
|
|
|
|
selectedCategory = category;
|
|
|
|
|
modal.find('#move_thread_commit').prop('disabled', false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onCommitClicked() {
|
|
|
|
|
var commitEl = modal.find('#move_thread_commit');
|
|
|
|
|
|
|
|
|
|
if (!commitEl.prop('disabled') && selectedEl.attr('data-cid')) {
|
|
|
|
|
if (!commitEl.prop('disabled') && selectedCategory && selectedCategory.cid) {
|
|
|
|
|
commitEl.prop('disabled', true);
|
|
|
|
|
|
|
|
|
|
moveTopics();
|
|
|
|
@ -105,7 +79,7 @@ define('forum/topic/move', function () {
|
|
|
|
|
function moveTopics() {
|
|
|
|
|
socket.emit(Move.moveAll ? 'topics.moveAll' : 'topics.move', {
|
|
|
|
|
tids: Move.tids,
|
|
|
|
|
cid: selectedEl.attr('data-cid'),
|
|
|
|
|
cid: selectedCategory.cid,
|
|
|
|
|
currentCid: Move.currentCid,
|
|
|
|
|
}, function (err) {
|
|
|
|
|
modal.modal('hide');
|
|
|
|
@ -114,7 +88,7 @@ define('forum/topic/move', function () {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.alertSuccess('[[topic:topic_move_success, ' + selectedEl.attr('data-name') + ']] <i class="fa fa-fw ' + selectedEl.attr('data-icon') + '"></i>');
|
|
|
|
|
app.alertSuccess('[[topic:topic_move_success, ' + selectedCategory.name + ']] <i class="fa fa-fw ' + selectedCategory.icon + '"></i>');
|
|
|
|
|
if (typeof Move.onComplete === 'function') {
|
|
|
|
|
Move.onComplete();
|
|
|
|
|
}
|
|
|
|
|