Permalink
Browse files

MINOR Only load preview panel if its visible, to avoid unnecessary as…

…set loads and processing. Only refresh edit form view from preview events when its visible.
  • Loading branch information...
1 parent f1f8dcd commit 11b3b43c8413984fbfe98ae9eb49946fde35f8a8 @chillu chillu committed Dec 19, 2011
Showing with 14 additions and 3 deletions.
  1. +13 −2 admin/javascript/LeftAndMain.Preview.js
  2. +1 −1 admin/templates/LeftAndMain.ss
@@ -37,10 +37,16 @@
this.find('iframe').addClass('center');
this.find('iframe').bind('load', function() {
self._fixIframeLinks();
- self.loadCurrentPage();
+
+ // Load edit view for new page, but only if the preview is activated at the moment.
+ // This avoids e.g. force-redirections of the edit view on RedirectorPage instances.
+ if(!self.is('.is-collapsed')) self.loadCurrentPage();
});
var updateAfterXhr = function() {
+ // Only load when panel is visible (see details in iframe load event handler).
+ if(self.is('.is-collapsed')) return;
+
// var url = ui.xmlhttp.getResponseHeader('x-frontend-url');
var url = $('.cms-edit-form').find(':input[name=StageURLSegment]').val();
if(url) {
@@ -241,7 +247,12 @@
onclick: function(e) {
e.preventDefault();
- $('.cms-preview').toggle();
+ var preview = $('.cms-preview'), url = $('.cms-edit-form').find(':input[name=StageURLSegment]').val();
+ if(url) {
+ preview.loadUrl(url);
+ preview.unblock();
+ preview.toggle();
+ }
}
});
});
@@ -17,7 +17,7 @@
$Content
<div class="cms-preview east <% if IsPreviewExpanded %>is-expanded<% else %>is-collapsed<% end_if %>" data-layout="{type: 'border'}">
- <iframe src="<% if $PreviewLink %>$PreviewLink<% else %>about:blank<% end_if %>" class="center"></iframe>
+ <iframe src="about:blank" class="center"></iframe>
<div class="cms-preview-controls south"></div>
</div>

0 comments on commit 11b3b43

Please sign in to comment.