MINOR Only load preview panel if its visible, to avoid unnecessary asset loads and processing. Only refresh edit form view from preview events when its visible.

This commit is contained in:
Ingo Schommer 2011-12-19 15:06:04 +01:00
parent f1f8dcd24d
commit 11b3b43c84
2 changed files with 14 additions and 3 deletions

View File

@ -37,10 +37,16 @@
this.find('iframe').addClass('center'); this.find('iframe').addClass('center');
this.find('iframe').bind('load', function() { this.find('iframe').bind('load', function() {
self._fixIframeLinks(); 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() { 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 = ui.xmlhttp.getResponseHeader('x-frontend-url');
var url = $('.cms-edit-form').find(':input[name=StageURLSegment]').val(); var url = $('.cms-edit-form').find(':input[name=StageURLSegment]').val();
if(url) { if(url) {
@ -241,7 +247,12 @@
onclick: function(e) { onclick: function(e) {
e.preventDefault(); 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();
}
} }
}); });
}); });

View File

@ -17,7 +17,7 @@
$Content $Content
<div class="cms-preview east <% if IsPreviewExpanded %>is-expanded<% else %>is-collapsed<% end_if %>" data-layout="{type: 'border'}"> <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 class="cms-preview-controls south"></div>
</div> </div>