Store in CryptDrive from File menu

pull/1/head
yflory 4 years ago
parent a603b7b365
commit 7e8d26e668

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

@ -788,6 +788,30 @@ define([
h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_savetodrive) h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_savetodrive)
])).click(common.prepareFeedback(type)); ])).click(common.prepareFeedback(type));
break; 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': case 'hashtag':
button = $('<button>', { button = $('<button>', {
'class': 'fa fa-hashtag cp-toolbar-icon-hashtag', 'class': 'fa fa-hashtag cp-toolbar-icon-hashtag',
@ -2797,6 +2821,7 @@ define([
// This pad will be deleted automatically, it shouldn't be stored // This pad will be deleted automatically, it shouldn't be stored
if (priv.burnAfterReading) { return; } if (priv.burnAfterReading) { return; }
var typeMsg = priv.pathname.indexOf('/file/') !== -1 ? Messages.autostore_file : var typeMsg = priv.pathname.indexOf('/file/') !== -1 ? Messages.autostore_file :
priv.pathname.indexOf('/drive/') !== -1 ? Messages.autostore_sf : priv.pathname.indexOf('/drive/') !== -1 ? Messages.autostore_sf :
Messages.autostore_pad; Messages.autostore_pad;
@ -2808,11 +2833,18 @@ define([
var actions = h('div', [hide, store]); var actions = h('div', [hide, store]);
var initialHide = data && data.autoStore && data.autoStore === -1; 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}); var modal = UI.cornerPopup(text, actions, footer, {hidden: initialHide});
// Once the store pad popup is created, put the crowdfunding one in the queue // Once the store pad popup is created, put the crowdfunding one in the queue
UIElements.displayCrowdfunding(common); UIElements.displayCrowdfunding(common);
autoStoreModal[priv.channel] = modal; autoStoreModal[priv.channel] = modal;
$(modal.popup).find('.cp-corner-footer a').click(function (e) { $(modal.popup).find('.cp-corner-footer a').click(function (e) {
@ -2822,6 +2854,7 @@ define([
$(hide).click(function () { $(hide).click(function () {
delete autoStoreModal[priv.channel]; delete autoStoreModal[priv.channel];
$('.cp-toolbar-storeindrive').show();
modal.delete(); modal.delete();
}); });
var waitingForStoringCb = false; var waitingForStoringCb = false;

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

Loading…
Cancel
Save