NEW Open external links in preview mode in new window (fixes #7652)

Rather than disabling the links altogether, which is
counter-intuitive to most users.
See https://github.com/silverstripe/sapphire/pull/638.

Also hide a duplicate $SilverStripeNavigator on the previewed
website (in case it has been manually applied to the template).
This commit is contained in:
Ingo Schommer 2012-08-27 14:40:11 +02:00
parent dddc5bdf46
commit 1d2288b091
1 changed files with 10 additions and 2 deletions

View File

@ -138,9 +138,17 @@
var href = links[i].getAttribute('href');
if(!href) continue;
// Disable external links
if (href.match(/^http:\/\//)) links[i].setAttribute('href', 'javascript:false');
// Open external links in new window to avoid "escaping" the
// internal page context in the preview iframe,
// which is important to stay in for the CMS logic.
if (href.match(/^http:\/\//)) links[i].setAttribute('target', '_blank');
}
// Hide duplicate navigator, as it replicates existing UI in the CMS
var navi = doc.getElementById('SilverStripeNavigator');
if(navi) navi.style.display = 'none';
var naviMsg = doc.getElementById('SilverStripeNavigatorMessage');
if(naviMsg) naviMsg.style.display = 'none';
},
expand: function(inclMenu) {