Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX avoid javascript error when preview is https #5163

Merged
merged 2 commits into from
Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion admin/javascript/src/LeftAndMain.ActionTabSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ $.entwine('ss', function($) {
// because the panel is still open when the ajax edit form reloads.
var frame = $('.cms-container').find('iframe');
frame.each(function(index, iframe){
$(iframe).contents().off('click.ss-ui-action-tabset');
try {
$(iframe).contents().off('click.ss-ui-action-tabset');
} catch (e) {}
});
$(document).off('click.ss-ui-action-tabset');

Expand Down
34 changes: 24 additions & 10 deletions admin/javascript/src/LeftAndMain.Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,16 @@ $.entwine('ss.preview', function($){
_loadCurrentPage: function() {
if (!this.getIsPreviewEnabled()) return;

var doc = this.find('iframe')[0].contentDocument,
containerEl = $('.cms-container');
var doc,
containerEl = $('.cms-container');
try {
doc = this.find('iframe')[0].contentDocument;
} catch (e) {
// iframe can't be accessed - might be secure?
}
if (!doc) {
return;
}

// Load this page in the admin interface if appropriate
var id = $(doc).find('meta[name=x-page-id]').attr('content');
Expand All @@ -521,14 +529,20 @@ $.entwine('ss.preview', function($){
* Prepare the iframe content for preview.
*/
_adjustIframeForPreview: function() {
var iframe = this.find('iframe')[0];
if(iframe){
var doc = iframe.contentDocument;
}else{
return;
}

if(!doc) return;
var iframe = this.find('iframe')[0],
doc;
if(!iframe){
return;
}

try {
doc = iframe.contentDocument;
} catch (e) {
// iframe can't be accessed - might be secure?
}
if(!doc) {
return;
}

// 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.
Expand Down