FIX: erratic behaviour when clicking an attachment link

This commit is contained in:
Régis Hanol 2015-04-27 20:45:06 +02:00
parent 8c930c97e0
commit ad3d2269b2

View file

@ -73,6 +73,14 @@ export default {
$link.data('auto-route', true);
}
// restore href
setTimeout(() => {
$link.removeClass('no-href');
$link.attr('href', $link.data('href'));
$link.data('href', null);
return;
}, 50);
// warn the user if they can't download the file
if (Discourse.SiteSettings.prevent_anons_from_downloading_files && $link.hasClass("attachment") && !Discourse.User.current()) {
bootbox.alert(I18n.t("post.errors.attachment_download_requires_login"));
@ -94,13 +102,6 @@ export default {
return false;
}
// restore href
setTimeout(function() {
$link.removeClass('no-href');
$link.attr('href', $link.data('href'));
$link.data('href', null);
}, 50);
// Otherwise, use a custom URL with a redirect
if (Discourse.User.currentProp('external_links_in_new_tab')) {
var win = window.open(trackingUrl, '_blank');