Fixes bug where hitting cancel didn't contain the old behaviour (opening the reply dialogue anyway), and instead just plain did nothing.
v1.18.x
Julian Lam 9 years ago
parent 0b6d92ea3e
commit 8b3f1684f7

@ -135,66 +135,67 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
} }
function onReplyClicked(button, tid, topicName) { function onReplyClicked(button, tid, topicName) {
if (ajaxify.data.lastposttime < (Date.now() - (1000*60*60*24*config.topicStaleDays))) { showStaleWarning(function(proceed) {
return showStaleWarning(); console.log('proceed is', proceed);
} if (!proceed) {
var selectionText = '',
var selectionText = '', selection = window.getSelection ? window.getSelection() : document.selection.createRange();
selection = window.getSelection ? window.getSelection() : document.selection.createRange();
if ($(selection.baseNode).parents('[component="post/content"]').length > 0) {
if ($(selection.baseNode).parents('[component="post/content"]').length > 0) { selectionText = selection.toString();
selectionText = selection.toString(); }
}
var username = getUserName(selectionText ? $(selection.baseNode) : button); var username = getUserName(selectionText ? $(selection.baseNode) : button);
if (getData(button, 'data-uid') === '0') { if (getData(button, 'data-uid') === '0') {
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 (selectionText.length) { if (selectionText.length) {
$(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: topicName, topicName: topicName,
username: username, username: username,
text: selectionText text: selectionText
}); });
} else { } else {
$(window).trigger('action:composer.post.new', { $(window).trigger('action:composer.post.new', {
tid: tid, tid: tid,
pid: toPid, pid: toPid,
topicName: topicName, topicName: topicName,
text: username ? username + ' ' : '' text: username ? username + ' ' : ''
}); });
} }
}
});
} }
function onQuoteClicked(button, tid, topicName) { function onQuoteClicked(button, tid, topicName) {
if (ajaxify.data.lastposttime < (Date.now() - (1000*60*60*24*config.topicStaleDays))) { showStaleWarning(function(proceed) {
return showStaleWarning(); if (!proceed) {
} var username = getUserName(button),
pid = getData(button, 'data-pid');
var username = getUserName(button), socket.emit('posts.getRawPost', pid, function(err, post) {
pid = getData(button, 'data-pid'); if(err) {
return app.alertError(err.message);
}
socket.emit('posts.getRawPost', pid, function(err, post) { $(window).trigger('action:composer.addQuote', {
if(err) { tid: tid,
return app.alertError(err.message); slug: ajaxify.data.slug,
index: getData(button, 'data-index'),
pid: pid,
username: username,
topicName: topicName,
text: post
});
});
} }
$(window).trigger('action:composer.addQuote', {
tid: tid,
slug: ajaxify.data.slug,
index: getData(button, 'data-index'),
pid: pid,
username: username,
topicName: topicName,
text: post
});
}); });
} }
@ -387,16 +388,23 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
return false; return false;
} }
function showStaleWarning() { function showStaleWarning(callback) {
translator.translate('[[topic:stale_topic_warning]]', function(translated) { if (ajaxify.data.lastposttime < (Date.now() - (1000*60*60*24*config.topicStaleDays))) {
bootbox.confirm(translated, function(create) { translator.translate('[[topic:stale_topic_warning]]', function(translated) {
if (create) { bootbox.confirm(translated, function(create) {
$(window).trigger('action:composer.topic.new', { if (create) {
cid: ajaxify.data.cid $(window).trigger('action:composer.topic.new', {
}); cid: ajaxify.data.cid
} });
}
callback(create);
});
}); });
}); } else {
callback(false);
}
} }
return PostTools; return PostTools;

Loading…
Cancel
Save