Autoload template picker to make it faster to appear when used
This commit is contained in:
@@ -587,11 +587,18 @@ define([
|
|||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
var focus;
|
var focus;
|
||||||
|
|
||||||
|
var pickerCfg = {
|
||||||
|
types: [type],
|
||||||
|
where: ['template'],
|
||||||
|
hidden: true
|
||||||
|
};
|
||||||
var onConfirm = function (yes) {
|
var onConfirm = function (yes) {
|
||||||
if (!yes) {
|
if (!yes) {
|
||||||
if (focus) { focus.focus(); }
|
if (focus) { focus.focus(); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
delete pickerCfg.hidden;
|
||||||
|
common.openFilePicker(pickerCfg);
|
||||||
var first = true; // We can only pick a template once (for a new document)
|
var first = true; // We can only pick a template once (for a new document)
|
||||||
var fileDialogCfg = {
|
var fileDialogCfg = {
|
||||||
onSelect: function (data) {
|
onSelect: function (data) {
|
||||||
@@ -608,15 +615,11 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
common.initFilePicker(fileDialogCfg);
|
common.initFilePicker(fileDialogCfg);
|
||||||
var pickerCfg = {
|
|
||||||
types: [type],
|
|
||||||
where: ['template']
|
|
||||||
};
|
|
||||||
common.openFilePicker(pickerCfg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
|
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
common.openFilePicker(pickerCfg);
|
||||||
focus = document.activeElement;
|
focus = document.activeElement;
|
||||||
Cryptpad.confirm(Messages.useTemplate, onConfirm, {
|
Cryptpad.confirm(Messages.useTemplate, onConfirm, {
|
||||||
ok: Messages.useTemplateOK,
|
ok: Messages.useTemplateOK,
|
||||||
|
|||||||
@@ -362,22 +362,26 @@ define([
|
|||||||
|
|
||||||
// File picker
|
// File picker
|
||||||
var FP = {};
|
var FP = {};
|
||||||
var initFilePicker = function (types) {
|
var initFilePicker = function (cfg) {
|
||||||
var config = {};
|
|
||||||
config.onFilePicked = function (data) {
|
|
||||||
sframeChan.event('EV_FILE_PICKED', data);
|
|
||||||
};
|
|
||||||
config.onClose = function () {
|
|
||||||
FP.$iframe.hide();
|
|
||||||
};
|
|
||||||
config.onFileUpload = onFileUpload;
|
|
||||||
config.types = types;
|
|
||||||
if (!FP.$iframe) {
|
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 = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body'));
|
FP.$iframe = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body'));
|
||||||
FP.picker = FilePicker.create(config);
|
FP.picker = FilePicker.create(config);
|
||||||
} else {
|
} else {
|
||||||
FP.$iframe.show();
|
FP.$iframe.show();
|
||||||
FP.picker.refresh(types);
|
FP.picker.refresh(cfg);
|
||||||
|
}
|
||||||
|
if (cfg.hidden) {
|
||||||
|
FP.$iframe.hide();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
FP.$iframe.focus();
|
FP.$iframe.focus();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user