FIX: clicking an attachment link works only once
This commit is contained in:
parent
e36272cb68
commit
b809e02c6c
|
@ -112,18 +112,17 @@ Discourse.ClickTrack = {
|
|||
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');
|
||||
win.focus();
|
||||
|
||||
// restore href
|
||||
setTimeout(function(){
|
||||
$link.removeClass('no-href');
|
||||
$link.attr('href', $link.data('href'));
|
||||
$link.data('href', null);
|
||||
},50);
|
||||
|
||||
} else {
|
||||
Discourse.URL.redirectTo(trackingUrl);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,16 @@ test("removes the href and put it as a data attribute", function() {
|
|||
ok(Discourse.URL.redirectTo.calledOnce);
|
||||
});
|
||||
|
||||
asyncTest("restores the href after a while", function() {
|
||||
expect(1);
|
||||
|
||||
track(generateClickEventOn('a'));
|
||||
|
||||
setTimeout(function() {
|
||||
start();
|
||||
equal(fixture('a').attr('href'), "http://www.google.com");
|
||||
}, 75);
|
||||
});
|
||||
|
||||
var badgeClickCount = function(id, expected) {
|
||||
track(generateClickEventOn('#' + id));
|
||||
|
|
Loading…
Reference in New Issue