From ad3d2269b2b76c45fcdcfba9a5a6379c2cf140ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 27 Apr 2015 20:45:06 +0200 Subject: [PATCH] FIX: erratic behaviour when clicking an attachment link --- .../javascripts/discourse/lib/click-track.js.es6 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index 5360bc4c37..d7f11cb310 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -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');