FIX: Links to images in posts won't go through the Discoruse router

This commit is contained in:
Robin Ward
2013-07-03 14:06:34 -04:00
parent b0e10673a2
commit ba0bd934ba
5 changed files with 22 additions and 26 deletions

View File

@ -148,21 +148,21 @@ Discourse = Ember.Application.createWithMixins({
});
$('#main').on('click.discourse', 'a', function(e) {
if (e.isDefaultPrevented() || e.shiftKey || e.metaKey || e.ctrlKey) return;
if (e.isDefaultPrevented() || e.shiftKey || e.metaKey || e.ctrlKey) { return; }
var $currentTarget = $(e.currentTarget);
var href = $currentTarget.attr('href');
if (!href) return;
if (href === '#') return;
if ($currentTarget.attr('target')) return;
if ($currentTarget.data('auto-route')) return;
if (!href) { return; }
if (href === '#') { return; }
if ($currentTarget.attr('target')) { return; }
if ($currentTarget.data('auto-route')) { return; }
// If it's an ember #linkTo skip it
if ($currentTarget.hasClass('ember-view')) return;
if ($currentTarget.hasClass('ember-view')) { return; }
if ($currentTarget.hasClass('lightbox')) return;
if (href.indexOf("mailto:") === 0) return;
if (href.match(/^http[s]?:\/\//i) && !href.match(new RegExp("^http:\\/\\/" + window.location.hostname, "i"))) return;
if ($currentTarget.hasClass('lightbox')) { return; }
if (href.indexOf("mailto:") === 0) { return; }
if (href.match(/^http[s]?:\/\//i) && !href.match(new RegExp("^http:\\/\\/" + window.location.hostname, "i"))) { return; }
e.preventDefault();
Discourse.URL.routeTo(href);