diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index 422b76bfe..884f1b65c 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -587,11 +587,18 @@ define([ var sframeChan = common.getSframeChannel(); var focus; + var pickerCfg = { + types: [type], + where: ['template'], + hidden: true + }; var onConfirm = function (yes) { if (!yes) { if (focus) { focus.focus(); } return; } + delete pickerCfg.hidden; + common.openFilePicker(pickerCfg); var first = true; // We can only pick a template once (for a new document) var fileDialogCfg = { onSelect: function (data) { @@ -608,15 +615,11 @@ define([ } }; common.initFilePicker(fileDialogCfg); - var pickerCfg = { - types: [type], - where: ['template'] - }; - common.openFilePicker(pickerCfg); }; sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { if (data) { + common.openFilePicker(pickerCfg); focus = document.activeElement; Cryptpad.confirm(Messages.useTemplate, onConfirm, { ok: Messages.useTemplateOK, diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 46534fe9d..2daa275f7 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -362,22 +362,26 @@ define([ // File picker var FP = {}; - var initFilePicker = function (types) { - var config = {}; - config.onFilePicked = function (data) { - sframeChan.event('EV_FILE_PICKED', data); - }; - config.onClose = function () { - FP.$iframe.hide(); - }; - config.onFileUpload = onFileUpload; - config.types = types; + var initFilePicker = function (cfg) { if (!FP.$iframe) { + var config = {}; + config.onFilePicked = function (data) { + sframeChan.event('EV_FILE_PICKED', data); + }; + config.onClose = function () { + FP.$iframe.hide(); + }; + config.onFileUpload = onFileUpload; + config.types = cfg; FP.$iframe = $('