Store in CryptDrive from File menu

This commit is contained in:
yflory 2021-04-29 17:04:37 +02:00
parent a603b7b365
commit 7e8d26e668
3 changed files with 37 additions and 1 deletions

View File

@ -1434,13 +1434,13 @@ define([
*/
UI.createDrawer = function ($button, $content) {
$button.click(function () {
var topPos = $button[0].getBoundingClientRect().bottom;
$content.toggle();
$button.removeClass('cp-toolbar-button-active');
if ($content.is(':visible')) {
$button.addClass('cp-toolbar-button-active');
$content.focus();
var wh = $(window).height();
var topPos = $button[0].getBoundingClientRect().bottom;
$content.css('max-height', Math.floor(wh - topPos - 1)+'px');
}
});

View File

@ -788,6 +788,30 @@ define([
h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_savetodrive)
])).click(common.prepareFeedback(type));
break;
case 'storeindrive':
Messages.toolbar_storeInDrive = "Store in CryptDrive"; // XXX
button = $(h('button.cp-toolbar-storeindrive', {
style: 'display:none;'
}, [
h('i.fa.fa-hdd-o'),
h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_storeInDrive)
])).click(common.prepareFeedback(type)).click(function () {
$(button).hide();
common.getSframeChannel().query("Q_AUTOSTORE_STORE", null, function (err, obj) {
waitingForStoringCb = false;
var error = err || (obj && obj.error);
if (error) {
$(button).show();
if (error === 'E_OVER_LIMIT') {
return void UI.warn(Messages.pinLimitReached);
}
return void UI.warn(Messages.autostore_error);
}
$(document).trigger('cpPadStored');
UI.log(Messages.autostore_saved);
});
});
break;
case 'hashtag':
button = $('<button>', {
'class': 'fa fa-hashtag cp-toolbar-icon-hashtag',
@ -2797,6 +2821,7 @@ define([
// This pad will be deleted automatically, it shouldn't be stored
if (priv.burnAfterReading) { return; }
var typeMsg = priv.pathname.indexOf('/file/') !== -1 ? Messages.autostore_file :
priv.pathname.indexOf('/drive/') !== -1 ? Messages.autostore_sf :
Messages.autostore_pad;
@ -2808,11 +2833,18 @@ define([
var actions = h('div', [hide, store]);
var initialHide = data && data.autoStore && data.autoStore === -1;
if (initialHide) {
$('.cp-toolbar-storeindrive').show();
UIElements.displayCrowdfunding(common);
return;
}
var modal = UI.cornerPopup(text, actions, footer, {hidden: initialHide});
// Once the store pad popup is created, put the crowdfunding one in the queue
UIElements.displayCrowdfunding(common);
autoStoreModal[priv.channel] = modal;
$(modal.popup).find('.cp-corner-footer a').click(function (e) {
@ -2822,6 +2854,7 @@ define([
$(hide).click(function () {
delete autoStoreModal[priv.channel];
$('.cp-toolbar-storeindrive').show();
modal.delete();
});
var waitingForStoringCb = false;

View File

@ -912,6 +912,9 @@ define([
var $copy = common.createButton('copy', true);
toolbar.$drawer.append($copy);
var $store = common.createButton('storeindrive', true);
toolbar.$drawer.append($store);
if (!cpNfInner.metadataMgr.getPrivateData().isTemplate) {
var templateObj = {
rt: cpNfInner.chainpad,