Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 #638.

Also hide a duplicate $SilverStripeNavigator on the previewed
website (in case it has been manually applied to the template).
  • Loading branch information...
commit 1d2288b09171024107573a3c9c9bbe8687549c3d 1 parent dddc5bd
@chillu chillu authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 admin/javascript/LeftAndMain.Preview.js
View
12 admin/javascript/LeftAndMain.Preview.js
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.