showStalewarning change

v1.18.x
barisusakli 9 years ago
parent d05d75a29f
commit 1bf6054345

@ -226,41 +226,39 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
} }
function onReplyClicked(button, tid) { function onReplyClicked(button, tid) {
showStaleWarning(function(proceed) { showStaleWarning(function() {
if (!proceed) { var selectedText = getSelectedText(button);
var selectedText = getSelectedText(button);
var username = getUserName(button); var username = getUserName(button);
if (getData(button, 'data-uid') === '0' || !getData(button, 'data-userslug')) { if (getData(button, 'data-uid') === '0' || !getData(button, 'data-userslug')) {
username = ''; username = '';
} }
var toPid = button.is('[component="post/reply"]') ? getData(button, 'data-pid') : null; var toPid = button.is('[component="post/reply"]') ? getData(button, 'data-pid') : null;
if (selectedText) { if (selectedText) {
$(window).trigger('action:composer.addQuote', { $(window).trigger('action:composer.addQuote', {
tid: tid, tid: tid,
slug: ajaxify.data.slug, slug: ajaxify.data.slug,
index: getData(button, 'data-index'), index: getData(button, 'data-index'),
pid: toPid, pid: toPid,
topicName: ajaxify.data.titleRaw, topicName: ajaxify.data.titleRaw,
username: username, username: username,
text: selectedText text: selectedText
}); });
} else { } else {
$(window).trigger('action:composer.post.new', { $(window).trigger('action:composer.post.new', {
tid: tid, tid: tid,
pid: toPid, pid: toPid,
topicName: ajaxify.data.titleRaw, topicName: ajaxify.data.titleRaw,
text: username ? username + ' ' : '' text: username ? username + ' ' : ''
}); });
}
} }
}); });
} }
function onQuoteClicked(button, tid) { function onQuoteClicked(button, tid) {
showStaleWarning(function(proceed) { showStaleWarning(function() {
function quote(text) { function quote(text) {
$(window).trigger('action:composer.addQuote', { $(window).trigger('action:composer.addQuote', {
@ -274,21 +272,19 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
}); });
} }
if (!proceed) { var username = getUserName(button);
var username = getUserName(button); var pid = getData(button, 'data-pid');
var pid = getData(button, 'data-pid'); var selectedText = getSelectedText(button);
var selectedText = getSelectedText(button); if (selectedText) {
if (selectedText) { return quote(selectedText);
return quote(selectedText); }
socket.emit('posts.getRawPost', pid, function(err, post) {
if (err) {
return app.alertError(err.message);
} }
socket.emit('posts.getRawPost', pid, function(err, post) {
if (err) {
return app.alertError(err.message);
}
quote(post); quote(post);
}); });
}
}); });
} }
@ -498,39 +494,39 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
} }
function showStaleWarning(callback) { function showStaleWarning(callback) {
if (ajaxify.data.lastposttime < (Date.now() - (1000 * 60 * 60 * 24 * ajaxify.data.topicStaleDays))) { if (ajaxify.data.lastposttime >= (Date.now() - (1000 * 60 * 60 * 24 * ajaxify.data.topicStaleDays))) {
translator.translate('[[topic:stale.warning]]', function(translated) { return callback();
var warning = bootbox.dialog({ }
title: '[[topic:stale.title]]',
message: translated, translator.translate('[[topic:stale.warning]]', function(translated) {
buttons: { var warning = bootbox.dialog({
reply: { title: '[[topic:stale.title]]',
label: '[[topic:stale.reply_anyway]]', message: translated,
className: 'btn-link', buttons: {
callback: function() { reply: {
callback(false); label: '[[topic:stale.reply_anyway]]',
} className: 'btn-link',
}, callback: function() {
create: { callback();
label: '[[topic:stale.create]]', }
className: 'btn-primary', },
callback: function() { create: {
translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function(body) { label: '[[topic:stale.create]]',
$(window).trigger('action:composer.topic.new', { className: 'btn-primary',
cid: ajaxify.data.cid, callback: function() {
body: body translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function(body) {
}); $(window).trigger('action:composer.topic.new', {
cid: ajaxify.data.cid,
body: body
}); });
} });
} }
} }
}); }
});
warning.modal(); warning.modal();
}); });
} else {
callback(false);
}
} }
return PostTools; return PostTools;

Loading…
Cancel
Save