From d98bbf7df9ebb47b640f570ac056292bac89984c Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 6 Sep 2017 11:03:20 +0200 Subject: [PATCH] Fix the pad app when cryptpad is in an iframe --- www/common/sframe-channel.js | 4 ++-- www/common/sframe-common-interface.js | 10 +++++----- www/common/sframe-common.js | 2 +- www/common/toolbar3.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/www/common/sframe-channel.js b/www/common/sframe-channel.js index 6bfffb028..5d363390f 100644 --- a/www/common/sframe-channel.js +++ b/www/common/sframe-channel.js @@ -7,7 +7,7 @@ define([ return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', ''); }; - var create = function (ow, cb) { + var create = function (ow, cb, isSandbox) { var otherWindow; var handlers = {}; var queries = {}; @@ -130,7 +130,7 @@ define([ console.log(msg); } }); - if (window !== window.top) { + if (isSandbox) { // we're in the sandbox otherWindow = ow; cb(chan); diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index f0f3a7da0..f812e3eec 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -230,31 +230,31 @@ define([ $userAdmin.find('a.logout').click(function () { Common.logout(function () { - window.top.location = origin+'/'; + window.parent.location = origin+'/'; }); }); $userAdmin.find('a.settings').click(function () { if (padType) { window.open(origin+'/settings/'); } else { - window.top.location = origin+'/settings/'; + window.parent.location = origin+'/settings/'; } }); $userAdmin.find('a.profile').click(function () { if (padType) { window.open(origin+'/profile/'); } else { - window.top.location = origin+'/profile/'; + window.parent.location = origin+'/profile/'; } }); $userAdmin.find('a.login').click(function () { Common.setLoginRedirect(function () { - window.top.location = origin+'/login/'; + window.parent.location = origin+'/login/'; }); }); $userAdmin.find('a.register').click(function () { Common.setLoginRedirect(function () { - window.top.location = origin+'/register/'; + window.parent.location = origin+'/register/'; }); }); diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index f75720d7f..bf42642a2 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -298,7 +298,7 @@ define([ Object.freeze(funcs); return { create: function (cb) { nThen(function (waitFor) { - SFrameChannel.create(window.top, waitFor(function (sfc) { ctx.sframeChan = sfc; })); + SFrameChannel.create(window.parent, waitFor(function (sfc) { ctx.sframeChan = sfc; }), true); // CpNfInner.start() should be here.... }).nThen(function () { ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan); diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index fbd1dd1e0..36d607c8c 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -611,7 +611,7 @@ define([ window.open(href); return; } - window.top.location = href; + window.parent.location = href; }; var onContext = function (e) { e.stopPropagation(); };