From 3d3f58b3fca87bdf9674c4d827681e1ef8f95950 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 25 Jan 2018 14:20:55 +0100 Subject: [PATCH] Improve share modal customization to make it work with async functions --- www/common/common-ui-elements.js | 4 ++-- www/common/toolbar3.js | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index e43a66176..a11ec5859 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -375,8 +375,8 @@ define([ } if (val.embed) { $(link).find('#cp-share-embed').attr('checked', true); } if (val.present) { $(link).find('#cp-share-present').attr('checked', true); } - UI.openCustomModal(UI.dialog.tabs(tabs)); }); + return tabs; }; UIElements.createFileShareModal = function (config) { var origin = config.origin; @@ -451,7 +451,7 @@ define([ pathname: pathname }); } - UI.openCustomModal(UI.dialog.tabs(tabs)); + return tabs; }; UIElements.createButton = function (common, type, rightside, data, callback) { diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index c7afbaca8..a82e1ff6e 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -444,13 +444,14 @@ define([ 'class': 'fa fa-share-alt cp-toolbar-share-button', title: Messages.shareButton }); + var modal = UIElements.createShareModal({ + origin: origin, + pathname: pathname, + hashes: hashes, + common: Common + }); $shareBlock.click(function () { - UIElements.createShareModal({ - origin: origin, - pathname: pathname, - hashes: hashes, - common: Common - }); + UI.openCustomModal(UI.dialog.tabs(modal)); }); toolbar.$leftside.append($shareBlock); @@ -472,13 +473,14 @@ define([ 'class': 'fa fa-share-alt cp-toolbar-share-button', title: Messages.shareButton }); + var modal = UIElements.createFileShareModal({ + origin: origin, + pathname: pathname, + hashes: hashes, + common: Common + }); $shareBlock.click(function () { - UIElements.createFileShareModal({ - origin: origin, - pathname: pathname, - hashes: hashes, - common: Common - }); + UI.openCustomModal(UI.dialog.tabs(modal)); }); toolbar.$leftside.append($shareBlock);