From 2aec7c2569a8bed190dc525f85c72756a3bfdb82 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 7 Apr 2020 15:24:12 +0200 Subject: [PATCH] Open the access modal in the secure iframe --- www/common/common-interface.js | 1 + www/common/common-ui-elements.js | 6 +----- www/common/inner/common-modal.js | 5 ++++- www/common/sframe-common-outer.js | 4 ++++ www/secureiframe/inner.js | 16 ++++++++++++++++ www/secureiframe/main.js | 4 ++++ 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 2b3939370..b2cd042a8 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -196,6 +196,7 @@ define([ ]); var $frame = $(frame); frame.closeModal = function (cb) { + frame.closeModal = function () {}; // Prevent further calls $frame.fadeOut(150, function () { $frame.detach(); if (typeof(cb) === "function") { cb(); } diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 2729be386..2aa47096f 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1592,11 +1592,7 @@ define([ .text(Messages.accessButton)) .click(common.prepareFeedback(type)) .click(function () { - require(['/common/inner/access.js'], function (Access) { - Access.getAccessModal(common, {}, function (e) { - if (e) { console.error(e); } - }); - }); + sframeChan.event('EV_ACCESS_OPEN'); }); break; case 'properties': diff --git a/www/common/inner/common-modal.js b/www/common/inner/common-modal.js index 2e8c32e21..de9b54c4b 100644 --- a/www/common/inner/common-modal.js +++ b/www/common/inner/common-modal.js @@ -129,7 +129,10 @@ define([ tabs[i] = { content: c && UI.dialog.customModal(node, { buttons: obj.buttons || button, - onClose: function () { blocked = false; } + onClose: function () { + blocked = false; + if (typeof(opts.onClose) === "function") { opts.onClose(); } + } }), disabled: !c, title: obj.title, diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 62491ffad..a7ffd206c 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -1020,6 +1020,10 @@ define([ initSecureModal('filepicker', data || {}, cb); }); + sframeChan.on('EV_ACCESS_OPEN', function (data) { + initSecureModal('access', data || {}, null); + }); + sframeChan.on('EV_SHARE_OPEN', function (data) { initSecureModal('share', data || {}, null); }); diff --git a/www/secureiframe/inner.js b/www/secureiframe/inner.js index e628decb6..343774662 100644 --- a/www/secureiframe/inner.js +++ b/www/secureiframe/inner.js @@ -40,6 +40,8 @@ define([ var displayed; var create = {}; + + // Share modal create['share'] = function (data) { var priv = metadataMgr.getPrivateData(); var f = (data && data.file) ? UIElements.createFileShareModal @@ -71,6 +73,20 @@ define([ displayed = modal; }; + // Access modal + create['access'] = function (data) { + require(['/common/inner/access.js'], function (Access) { + Access.getAccessModal(common, { + onClose: function () { + hideIframe(); + } + }, function (e, modal) { + if (e) { console.error(e); } + displayed = modal; + }); + }); + }; + // File uploader var onFilePicked = function (data) { var privateData = metadataMgr.getPrivateData(); diff --git a/www/secureiframe/main.js b/www/secureiframe/main.js index a50a67bb2..95fa826a6 100644 --- a/www/secureiframe/main.js +++ b/www/secureiframe/main.js @@ -108,6 +108,10 @@ define([ config.addCommonRpc(sframeChan); + Cryptpad.padRpc.onMetadataEvent.reg(function (data) { + sframeChan.event('EV_RT_METADATA', data); + }); + sframeChan.on('EV_CACHE_PUT', function (x) { Object.keys(x).forEach(function (k) { localStorage['CRYPTPAD_CACHE|' + k] = x[k];