From 8809caac28ad59de429607da75e1cf6db52b00ce Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 10 Feb 2013 12:31:54 +0000 Subject: [PATCH] open external links only once, Notes can contain links, fixes #883 --- static/js/pandora/infoView.0xdb.js | 1 + static/js/pandora/utils.js | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/static/js/pandora/infoView.0xdb.js b/static/js/pandora/infoView.0xdb.js index 5d7367dd..8d232358 100644 --- a/static/js/pandora/infoView.0xdb.js +++ b/static/js/pandora/infoView.0xdb.js @@ -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', diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 5e6195c7..52f5bd8d 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -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); + } } }); };