open external links only once, Notes can contain links, fixes #883

This commit is contained in:
j 2013-02-10 12:31:54 +00:00
parent 3b44e38e14
commit 8809caac28
2 changed files with 11 additions and 7 deletions

View file

@ -549,6 +549,7 @@ pandora.ui.infoView = function(data) {
.append(formatKey('Notes', true)) .append(formatKey('Notes', true))
.append( .append(
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink,
height: 128, height: 128,
placeholder: formatLight('No notes'), placeholder: formatLight('No notes'),
tooltip: 'Doubleclick to edit', tooltip: 'Doubleclick to edit',

View file

@ -217,15 +217,16 @@ pandora.clickLink = function(e) {
}; };
pandora.createLinks = function($element) { pandora.createLinks = function($element) {
function isExternalLink(target) {
return $(target).is('a') && (
target.hostname != document.location.hostname
|| Ox.startsWith(target.pathname, '/static')
)
}
$element $element
.on({ .on({
click: function(e) { click: function(e) {
if( if(isExternalLink(e.target)) {
$(e.target).is('a') && (
e.target.hostname != document.location.hostname
|| Ox.startsWith(e.target.pathname, '/static')
)
) {
e.preventDefault(); e.preventDefault();
window.open('/url=' + encodeURIComponent(e.target.href), '_blank'); window.open('/url=' + encodeURIComponent(e.target.href), '_blank');
} }
@ -234,7 +235,9 @@ pandora.createLinks = function($element) {
}) })
.bindEvent({ .bindEvent({
singleclick: function(e) { singleclick: function(e) {
$(e.target).is('a') && pandora.clickLink(e); if(!isExternalLink(e.target)) {
pandora.clickLink(e);
}
} }
}); });
}; };