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(
Ox.Editable({
clickLink: pandora.clickLink,
height: 128,
placeholder: formatLight('No notes'),
tooltip: 'Doubleclick to edit',

View File

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