Skip to content
This repository
Browse code

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
Ingo Schommer authored August 27, 2012

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  admin/javascript/LeftAndMain.Preview.js
12  admin/javascript/LeftAndMain.Preview.js
@@ -138,9 +138,17 @@
138 138
 					var href = links[i].getAttribute('href');
139 139
 					if(!href) continue;
140 140
 					
141  
-					// Disable external links
142  
-					if (href.match(/^http:\/\//)) links[i].setAttribute('href', 'javascript:false');
  141
+					// Open external links in new window to avoid "escaping" the
  142
+					// internal page context in the preview iframe,
  143
+					// which is important to stay in for the CMS logic.
  144
+					if (href.match(/^http:\/\//)) links[i].setAttribute('target', '_blank');
143 145
 				}
  146
+
  147
+				// Hide duplicate navigator, as it replicates existing UI in the CMS
  148
+				var navi = doc.getElementById('SilverStripeNavigator');
  149
+				if(navi) navi.style.display = 'none';
  150
+				var naviMsg = doc.getElementById('SilverStripeNavigatorMessage');
  151
+				if(naviMsg) naviMsg.style.display = 'none';
144 152
 			},
145 153
 			
146 154
 			expand: function(inclMenu) {

0 notes on commit 1d2288b

Please sign in to comment.
Something went wrong with that request. Please try again.