|
|
@ -10,13 +10,13 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|
|
|
|
|
|
|
|
|
|
|
var localeStringOpts = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
|
|
|
|
var localeStringOpts = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('posts.getDiffs', { pid: pid }, function (err, timestamps) {
|
|
|
|
socket.emit('posts.getDiffs', { pid: pid }, function (err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Benchpress.parse('partials/modals/post_history', {
|
|
|
|
Benchpress.parse('partials/modals/post_history', {
|
|
|
|
diffs: timestamps.map(function (timestamp) {
|
|
|
|
diffs: data.timestamps.map(function (timestamp) {
|
|
|
|
timestamp = parseInt(timestamp, 10);
|
|
|
|
timestamp = parseInt(timestamp, 10);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -24,7 +24,8 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|
|
|
pretty: new Date(timestamp).toLocaleString(config.userLang.replace('_', '-'), localeStringOpts),
|
|
|
|
pretty: new Date(timestamp).toLocaleString(config.userLang.replace('_', '-'), localeStringOpts),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
numDiffs: timestamps.length,
|
|
|
|
numDiffs: data.timestamps.length,
|
|
|
|
|
|
|
|
editable: data.editable,
|
|
|
|
}, function (html) {
|
|
|
|
}, function (html) {
|
|
|
|
translator.translate(html, function (html) {
|
|
|
|
translator.translate(html, function (html) {
|
|
|
|
var modal = bootbox.dialog({
|
|
|
|
var modal = bootbox.dialog({
|
|
|
@ -33,19 +34,26 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|
|
|
size: 'large',
|
|
|
|
size: 'large',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!timestamps.length) {
|
|
|
|
if (!data.timestamps.length) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var selectEl = modal.find('select');
|
|
|
|
var selectEl = modal.find('select');
|
|
|
|
|
|
|
|
var revertEl = modal.find('button[data-action="restore"]');
|
|
|
|
var postContainer = modal.find('ul.posts-list');
|
|
|
|
var postContainer = modal.find('ul.posts-list');
|
|
|
|
|
|
|
|
|
|
|
|
selectEl.on('change', function () {
|
|
|
|
selectEl.on('change', function () {
|
|
|
|
Diffs.load(pid, this.value, postContainer);
|
|
|
|
Diffs.load(pid, this.value, postContainer);
|
|
|
|
|
|
|
|
revertEl.prop('disabled', data.timestamps.indexOf(this.value) === -1);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
revertEl.on('click', function () {
|
|
|
|
|
|
|
|
Diffs.restore(pid, selectEl.val(), modal);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
modal.on('shown.bs.modal', function () {
|
|
|
|
modal.on('shown.bs.modal', function () {
|
|
|
|
Diffs.load(pid, selectEl.val(), postContainer);
|
|
|
|
Diffs.load(pid, selectEl.val(), postContainer);
|
|
|
|
|
|
|
|
revertEl.prop('disabled', true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -72,5 +80,20 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Diffs.restore = function (pid, since, modal) {
|
|
|
|
|
|
|
|
if (!config.enablePostHistory) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('posts.restoreDiff', { pid: pid, since: since }, function (err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
|
|
|
app.alertSuccess('[[topic:diffs.post-restored]]');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return Diffs;
|
|
|
|
return Diffs;
|
|
|
|
});
|
|
|
|
});
|
|
|
|