From e8a5244362ffc9bf59f0a53b4d89874c33a2e385 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 27 Aug 2018 14:58:09 +0200 Subject: [PATCH 1/3] Autostore base --- customize.dist/src/less2/include/corner.less | 75 +++++++++++++++++++ .../src/less2/include/framework.less | 3 + customize.dist/translations/messages.js | 6 ++ www/common/common-interface.js | 32 ++++++++ www/common/common-ui-elements.js | 34 +++++++++ www/common/cryptpad-common.js | 10 ++- www/common/outer/async-store.js | 40 ++++++---- www/common/outer/upload.js | 3 +- www/common/sframe-common-outer.js | 19 +++++ www/common/sframe-common.js | 4 + www/common/sframe-protocol.js | 3 + 11 files changed, 211 insertions(+), 18 deletions(-) create mode 100644 customize.dist/src/less2/include/corner.less diff --git a/customize.dist/src/less2/include/corner.less b/customize.dist/src/less2/include/corner.less new file mode 100644 index 000000000..5b140d217 --- /dev/null +++ b/customize.dist/src/less2/include/corner.less @@ -0,0 +1,75 @@ +@import (reference) "./colortheme-all.less"; + +.corner_main() { + --LessLoader_require: LessLoader_currentFile(); +}; +& { + @corner-button-ok: #2c9b00; + @corner-button-cancel: #990000; + + @keyframes appear { + 0% { + transform: scale(0.1); + } + 100% { + transform: scale(1.0); + } + } + + .cp-corner-container { + position: absolute; + right: 0; + bottom: 0; + width: 300px; + height: 200px; + border-top-left-radius: 200px; + padding: 15px; + text-align: right; + background-color: @colortheme_logo-1; + color: @colortheme_base; + z-index: 999; + scale: 0.1; + transform-origin: bottom right; + animation: appear 0.8s ease-in-out; + + .cp-corner-filler { + float: left; + clear: left; + height: 21px; + } + .cp-corner-text { + + } + .cp-corner-actions { + min-height: 30px; + margin: 15px auto; + display: inline-block; + } + .cp-corner-footer { + font-style: italic; + font-size: 0.8em; + } + + button { + color: white; + border: 0px; + padding: 5px; + color: @colortheme_base; + &.cp-corner-primary { + background-color: @corner-button-ok; + font-weight: bold; + &:hover { + background-color: lighten(@corner-button-ok, 10%); + } + } + &.cp-corner-cancel { + background-color: @corner-button-cancel; + margin-left: 10px; + &:hover { + background-color: lighten(@corner-button-cancel, 10%); + } + } + } + } +} + diff --git a/customize.dist/src/less2/include/framework.less b/customize.dist/src/less2/include/framework.less index 5caa847f4..f46018b8c 100644 --- a/customize.dist/src/less2/include/framework.less +++ b/customize.dist/src/less2/include/framework.less @@ -2,6 +2,7 @@ @import (reference) "./toolbar.less"; @import (reference) './fileupload.less'; @import (reference) './alertify.less'; +@import (reference) './corner.less'; @import (reference) './tokenfield.less'; @import (reference) './creation.less'; @import (reference) './tippy.less'; @@ -27,6 +28,7 @@ @color: @color ); .alertify_main(); + .corner_main(); .fileupload_main(); .tokenfield_main(); .tippy_main(); @@ -60,6 +62,7 @@ ); .fileupload_main(); .alertify_main(); + .corner_main(); .tippy_main(); .checkmark_main(20px); .password_main(); diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index f29290bff..c812f095b 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -1226,5 +1226,11 @@ define(function () { out.sharedFolders_create_password = "Folder password"; out.sharedFolders_share = "Share this URL with other registered users to give them access to the shared folder. Once they open this URL, the shared folder will be added to the root directory of their CryptDrive."; + // Manual pad storage popup + out.manual_notstored = "This pad is not stored in your drive. Do you want to store it now?"; // XXX + out.manual_settings = "You can enable automatic pad storage in your Settings page!"; // XXX + out.manual_store = "Store"; + out.manual_hide = "Don't store"; + return out; }); diff --git a/www/common/common-interface.js b/www/common/common-interface.js index a6bc0aec3..07ec891ef 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -879,5 +879,37 @@ define([ UI.createRadio = Pages.createRadio; + UI.cornerPopup = function (text, actions, footer) { + // XXX create "minimize" icon + var popup = h('div.cp-corner-container', [ + h('div.cp-corner-filler', { style: "width:130px;" }), + h('div.cp-corner-filler', { style: "width:90px;" }), + h('div.cp-corner-filler', { style: "width:60px;" }), + h('div.cp-corner-filler', { style: "width:40px;" }), + h('div.cp-corner-filler', { style: "width:20px;" }), + h('div.cp-corner-text', text), + h('div.cp-corner-actions', actions), + h('div.cp-corner-footer', footer) + ]); + + var hide = function () { + $(popup).hide(); + }; + var show = function () { + $(popup).show(); + }; + var deletePopup = function () { + $(popup).remove(); + }; + + $('body').append(popup); + + return { + hide: hide, + show: show, + delete: deletePopup + }; + }; + return UI; }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index fc54da947..8087f5af9 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2308,5 +2308,39 @@ define([ $(password).find('.cp-password-input').focus(); }; + var storePopupState = false; + UIElements.displayStorePadPopup = function (common) { + if (storePopupState) { return; } + storePopupState = true; + + var text = Messages.manual_notstored; + var footer = Messages.manual_settings; + + var hide = h('button.cp-corner-cancel', Messages.manual_hide); + var store = h('button.cp-corner-primary', Messages.manual_store); + var actions = h('div', [ + store, + hide, + ]); + + console.log(text, footer); + var modal = UI.cornerPopup(text, actions, footer); + + $(hide).click(function () { + modal.delete(); + }); + $(store).click(function () { + modal.delete(); + common.getSframeChannel().query("Q_AUTOSTORE_STORE", null, function (err, obj) { + if (err || (obj && obj.error)) { + console.error(err || obj.error); + return void UI.warn("Error"); // XXX + } + UI.log("Saved"); // XXX + }); + }); + + }; + return UIElements; }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 4652c104f..2c2f8b00b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -547,7 +547,7 @@ define([ postMessage("SET_PAD_TITLE", data, function (obj) { if (obj && obj.error) { - console.log("unable to set pad title"); + if (obj.error !== "EAUTH") { console.log("unable to set pad title"); } return void cb(obj.error); } cb(); @@ -925,6 +925,10 @@ define([ common.loading = {}; common.loading.onDriveEvent = Util.mkEvent(); + // (Auto)store pads + common.autoStore = {}; + common.autoStore.onStoreRequest = Util.mkEvent(); + common.getFullHistory = function (data, cb) { postMessage("GET_FULL_HISTORY", data, cb); }; @@ -1060,7 +1064,9 @@ define([ // Account deletion DELETE_ACCOUNT: common.startAccountDeletion, // Loading - LOADING_DRIVE: common.loading.onDriveEvent.fire + LOADING_DRIVE: common.loading.onDriveEvent.fire, + // AutoStore + AUTOSTORE_DISPLAY_POPUP: common.autoStore.onStoreRequest.fire, }; common.hasCSSVariables = function () { diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 4cb0503bb..368a0b7e9 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -765,22 +765,32 @@ define([ // Add the pad if it does not exist in our drive if (!contains) { - var roHref; - if (h.mode === "view") { - roHref = href; - href = undefined; + var autoStore = Util.find(store.proxy, ['settings', 'general', 'autostore']); + if (autoStore !== 1 && !data.forceSave && !data.path) { + // XXX + // send event to inner to display the corner popup + postMessage(clientId, "AUTOSTORE_DISPLAY_POPUP", { + autoStore: autoStore + }); + return void cb({error: "EAUTH"}); + } else { + var roHref; + if (h.mode === "view") { + roHref = href; + href = undefined; + } + Store.addPad(clientId, { + href: href, + roHref: roHref, + channel: channel, + title: title, + owners: owners, + expire: expire, + password: data.password, + path: data.path + }, cb); + return; } - Store.addPad(clientId, { - href: href, - roHref: roHref, - channel: channel, - title: title, - owners: owners, - expire: expire, - password: data.password, - path: data.path - }, cb); - return; } else { sendDriveEvent('DRIVE_CHANGE', { path: ['drive', UserObject.FILES_DATA] diff --git a/www/common/outer/upload.js b/www/common/outer/upload.js index 25029ed69..f2faefbe0 100644 --- a/www/common/outer/upload.js +++ b/www/common/outer/upload.js @@ -93,7 +93,8 @@ define([ path: path, password: password, channel: id, - owners: metadata.owners + owners: metadata.owners, + // XXX FORCESAVE ?? }; common.setPadTitle(data, function (err) { if (err) { return void console.error(err); } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 0761f1034..64c3581cb 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -358,6 +358,22 @@ define([ setDocumentTitle(); }); + Cryptpad.autoStore.onStoreRequest.reg(function (data) { + sframeChan.event("EV_AUTOSTORE_DISPLAY_POPUP", data); + }); + sframeChan.on('Q_AUTOSTORE_STORE', function (obj, cb) { + var data = { + password: password, + title: currentTitle, + channel: secret.channel, + path: initialPathInDrive, // Where to store the pad if we don't have it in our drive + forceSave: true + }; + Cryptpad.setPadTitle(data, function (err) { + cb(err); + }); + }); + sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) { Cryptpad.setDisplayName(newName, function (err) { @@ -399,6 +415,7 @@ define([ Cryptpad.saveAsTemplate(Cryptget.put, data, cb); }); + // Messaging sframeChan.on('Q_SEND_FRIEND_REQUEST', function (netfluxId, cb) { Cryptpad.inviteFromUserlist(netfluxId, cb); }); @@ -411,6 +428,7 @@ define([ sframeChan.event('EV_FRIEND_REQUEST', data); }); + // History sframeChan.on('Q_GET_FULL_HISTORY', function (data, cb) { var crypto = Crypto.createEncryptor(secret.keys); Cryptpad.getFullHistory({ @@ -452,6 +470,7 @@ define([ }); }); + // Store sframeChan.on('Q_GET_PAD_ATTRIBUTE', function (data, cb) { var href; if (readOnly && hashes.editHash) { diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 8331e5f60..64070a8c8 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -452,6 +452,10 @@ define([ UI.errorLoadingScreen($err, true, true); }); + ctx.sframeChan.on('EV_AUTOSTORE_DISPLAY_POPUP', function () { + UIElements.displayStorePadPopup(funcs); + }); + ctx.metadataMgr.onReady(waitFor()); }).nThen(function () { try { diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index fbe311ba8..8e3b4d035 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -254,4 +254,7 @@ define({ // Get all existing tags 'Q_GET_ALL_TAGS': true, + // Store pads in the drive + 'EV_AUTOSTORE_DISPLAY_POPUP': true, + 'Q_AUTOSTORE_STORE': true, }); From 9ebb5984678b8491481016901198a8fad224d929 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 28 Aug 2018 11:42:48 +0200 Subject: [PATCH 2/3] Make automatic pad storage configurable --- customize.dist/pages.js | 8 +- .../src/less2/include/checkmark.less | 24 +++ .../src/less2/include/colortheme.less | 1 + customize.dist/src/less2/include/corner.less | 54 +++++- customize.dist/translations/messages.js | 19 +- www/common/common-interface.js | 21 ++- www/common/common-ui-elements.js | 23 ++- www/common/outer/async-store.js | 3 +- www/common/outer/upload.js | 3 +- www/common/sframe-common-file.js | 24 ++- www/common/sframe-common.js | 4 +- www/settings/app-settings.less | 10 + www/settings/inner.js | 172 ++++++++++++------ 13 files changed, 286 insertions(+), 80 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 0167268ed..83a8e1dcc 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -9,7 +9,7 @@ define([ var Pages = {}; var urlArgs = Config.requireConf.urlArgs; - var setHTML = function (e, html) { + var setHTML = Pages.setHTML = function (e, html) { e.innerHTML = html; return e; }; @@ -712,11 +712,15 @@ define([ $(input).change(function () { $(mark).focus(); }); - return h('label.cp-radio', labelOpts, [ + var radio = h('label', labelOpts, [ input, mark, label ]); + + $(radio).addClass('cp-radio'); + + return radio; }; Pages['/user/'] = Pages['/user/index.html'] = function () { diff --git a/customize.dist/src/less2/include/checkmark.less b/customize.dist/src/less2/include/checkmark.less index 21d59cc19..da5a07a26 100644 --- a/customize.dist/src/less2/include/checkmark.less +++ b/customize.dist/src/less2/include/checkmark.less @@ -49,6 +49,12 @@ background-color: @colortheme_checkmark-back2; border-color: @colortheme_checkmark-back2; } + &:disabled ~ .cp-checkmark-mark { + background-color: @colortheme_checkmark-disabled; + } + &:disabled ~ .cp-checkmark-label { + color: @colortheme_checkmark-disabled; + } } } &:hover .cp-checkmark-mark { @@ -64,6 +70,12 @@ display: block; } } + &:disabled ~ .cp-checkmark-mark { + background-color: @colortheme_checkmark-disabled; + } + &:disabled ~ .cp-checkmark-label { + color: @colortheme_checkmark-disabled; + } } .cp-checkmark-label { @@ -128,6 +140,12 @@ &:checked ~ .cp-radio-mark { background-color: @colortheme_checkmark-back2; } + &:disabled ~ .cp-checkmark-mark { + background-color: @colortheme_checkmark-disabled; + } + &:disabled ~ .cp-checkmark-label { + color: @colortheme_checkmark-disabled; + } } } &:hover .cp-radio-mark { @@ -143,6 +161,12 @@ display: block; } } + &:disabled ~ .cp-checkmark-mark { + background-color: @colortheme_checkmark-disabled; + } + &:disabled ~ .cp-checkmark-label { + color: @colortheme_checkmark-disabled; + } } .cp-checkmark-label { diff --git a/customize.dist/src/less2/include/colortheme.less b/customize.dist/src/less2/include/colortheme.less index 905327685..94f91105c 100644 --- a/customize.dist/src/less2/include/colortheme.less +++ b/customize.dist/src/less2/include/colortheme.less @@ -143,3 +143,4 @@ @colortheme_checkmark-col1: @colortheme_form-color; @colortheme_checkmark-back2: @colortheme_form-bg-alt; @colortheme_checkmark-col2: @colortheme_form-color-alt; +@colortheme_checkmark-disabled: #AAA; diff --git a/customize.dist/src/less2/include/corner.less b/customize.dist/src/less2/include/corner.less index 5b140d217..fb8113907 100644 --- a/customize.dist/src/less2/include/corner.less +++ b/customize.dist/src/less2/include/corner.less @@ -6,6 +6,7 @@ & { @corner-button-ok: #2c9b00; @corner-button-cancel: #990000; + @corner-link: #ffff7a; @keyframes appear { 0% { @@ -15,6 +16,14 @@ transform: scale(1.0); } } + @keyframes minimize { + 0% { + transform: scale(1.0); + } + 100% { + transform: scale(0.1); + } + } .cp-corner-container { position: absolute; @@ -28,18 +37,51 @@ background-color: @colortheme_logo-1; color: @colortheme_base; z-index: 999; - scale: 0.1; transform-origin: bottom right; animation: appear 0.8s ease-in-out; + box-shadow: 0 0 10px 0 @colortheme_logo-1; + //transform: scale(0.1); + //transform: scale(1); .cp-corner-filler { float: left; clear: left; height: 21px; } - .cp-corner-text { - + .cp-corner-minimize, .cp-corner-maximize { + position: absolute; + height: 15px; + width: 20px; + top: 0; + right: 0; + font-size: 12px; + text-align: left; + cursor: pointer; + line-height: 15px; + display: none; + &:hover { + color: darken(@colortheme_base, 15%); + } + } + .cp-corner-minimize { + display: inline; } + &.cp-minimized { + transition: transform 0.8s ease-in-out; + transform: scale(0.1); + animation: none; + .cp-corner-text, .cp-corner-actions, .cp-corner-footer { + display: none; + } + .cp-corner-maximize { + display: inline; + font-size: 130px; + width: 180px; + height: 200px; + line-height: 200px; + } + } + .cp-corner-actions { min-height: 30px; margin: 15px auto; @@ -48,6 +90,12 @@ .cp-corner-footer { font-style: italic; font-size: 0.8em; + a { + color: @corner-link; + &:hover { + color: darken(@corner-link, 20%); + } + } } button { diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index c812f095b..6ef7e8e79 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -565,6 +565,14 @@ define(function () { out.settings_importConfirm = "Are you sure you want to import recent pads from this browser to your user account's CryptDrive?"; out.settings_importDone = "Import completed"; + out.settings_autostoreTitle = "Pad storage in CryptDrive"; + out.settings_autostoreHint = "Automatic pad storage results in all the pads you visit being stored in your CryptDrive.
" + + "Manual (always ask) results in the pads not being stored but a reminder will appear to ask you if you want to store them in CryptDrive.
" + + "Manual (never ask) results in the pads not being stored and option to store them will be available but in a hidden way."; + out.settings_autostoreYes = "Automatic"; + out.settings_autostoreNo = "Manual (never ask)"; + out.settings_autostoreMaybe = "Manual (always ask)"; + out.settings_userFeedbackTitle = "Feedback"; out.settings_userFeedbackHint1 = "CryptPad provides some very basic feedback to the server, to let us know how to improve your experience. "; out.settings_userFeedbackHint2 = "Your pad's content will never be shared with the server."; @@ -1227,10 +1235,13 @@ define(function () { out.sharedFolders_share = "Share this URL with other registered users to give them access to the shared folder. Once they open this URL, the shared folder will be added to the root directory of their CryptDrive."; // Manual pad storage popup - out.manual_notstored = "This pad is not stored in your drive. Do you want to store it now?"; // XXX - out.manual_settings = "You can enable automatic pad storage in your Settings page!"; // XXX - out.manual_store = "Store"; - out.manual_hide = "Don't store"; + out.autostore_notstored = "This pad is not in your CryptDrive. Do you want to store it now?"; // XXX + out.autostore_settings = "You can enable automatic pad storage in your Settings page!"; // XXX + out.autostore_store = "Store"; + out.autostore_hide = "Don't store"; + out.autostore_error = "Unexpected error: we were unable to store this pad, please try again."; + out.autostore_saved = "The pad was successfully stored in your CryptDrive!"; + out.autostore_forceSave = "Store the file in CryptDrive"; // File upload modal return out; }); diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 07ec891ef..4ec28b5f6 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -879,9 +879,12 @@ define([ UI.createRadio = Pages.createRadio; - UI.cornerPopup = function (text, actions, footer) { - // XXX create "minimize" icon + UI.cornerPopup = function (text, actions, footer, startHidden) { + var minimize = h('div.cp-corner-minimize.fa.fa-window-minimize'); + var maximize = h('div.cp-corner-maximize.fa.fa-window-maximize'); var popup = h('div.cp-corner-container', [ + minimize, + maximize, h('div.cp-corner-filler', { style: "width:130px;" }), h('div.cp-corner-filler', { style: "width:90px;" }), h('div.cp-corner-filler', { style: "width:60px;" }), @@ -889,9 +892,20 @@ define([ h('div.cp-corner-filler', { style: "width:20px;" }), h('div.cp-corner-text', text), h('div.cp-corner-actions', actions), - h('div.cp-corner-footer', footer) + Pages.setHTML(h('div.cp-corner-footer'), footer) ]); + $(minimize).click(function () { + $(popup).addClass('cp-minimized'); + }); + $(maximize).click(function () { + $(popup).removeClass('cp-minimized'); + }); + + if (startHidden) { + $(popup).addClass('cp-minimized'); + } + var hide = function () { $(popup).hide(); }; @@ -905,6 +919,7 @@ define([ $('body').append(popup); return { + popup: popup, hide: hide, show: show, delete: deletePopup diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 8087f5af9..cc918afc5 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2309,22 +2309,27 @@ define([ }; var storePopupState = false; - UIElements.displayStorePadPopup = function (common) { + UIElements.displayStorePadPopup = function (common, data) { if (storePopupState) { return; } storePopupState = true; - var text = Messages.manual_notstored; - var footer = Messages.manual_settings; + var text = Messages.autostore_notstored; + var footer = Messages.autostore_settings; - var hide = h('button.cp-corner-cancel', Messages.manual_hide); - var store = h('button.cp-corner-primary', Messages.manual_store); + var hide = h('button.cp-corner-cancel', Messages.autostore_hide); + var store = h('button.cp-corner-primary', Messages.autostore_store); var actions = h('div', [ store, hide, ]); - console.log(text, footer); - var modal = UI.cornerPopup(text, actions, footer); + var initialHide = data && data.autoStore && data.autoStore === -1; + var modal = UI.cornerPopup(text, actions, footer, initialHide); + + $(modal.popup).find('.cp-corner-footer a').click(function (e) { + e.preventDefault(); + common.openURL('/settings/'); + }); $(hide).click(function () { modal.delete(); @@ -2334,9 +2339,9 @@ define([ common.getSframeChannel().query("Q_AUTOSTORE_STORE", null, function (err, obj) { if (err || (obj && obj.error)) { console.error(err || obj.error); - return void UI.warn("Error"); // XXX + return void UI.warn(Messages.autostore_error); } - UI.log("Saved"); // XXX + UI.log(Messages.autostore_saved); }); }); diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 368a0b7e9..f9ea7dcb4 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -767,12 +767,11 @@ define([ if (!contains) { var autoStore = Util.find(store.proxy, ['settings', 'general', 'autostore']); if (autoStore !== 1 && !data.forceSave && !data.path) { - // XXX // send event to inner to display the corner popup postMessage(clientId, "AUTOSTORE_DISPLAY_POPUP", { autoStore: autoStore }); - return void cb({error: "EAUTH"}); + return void cb(); } else { var roHref; if (h.mode === "view") { diff --git a/www/common/outer/upload.js b/www/common/outer/upload.js index f2faefbe0..cd0f9b134 100644 --- a/www/common/outer/upload.js +++ b/www/common/outer/upload.js @@ -17,6 +17,7 @@ define([ var path = file.path; var password = file.password; + var forceSave = file.forceSave; var hash, secret, key, id, href; var getNewHash = function () { @@ -94,7 +95,7 @@ define([ password: password, channel: id, owners: metadata.owners, - // XXX FORCESAVE ?? + forceSave: forceSave }; common.setPadTitle(data, function (err) { if (err) { return void console.error(err); } diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index 83127d886..be9c320c5 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -233,6 +233,13 @@ define([ return q; }; + var privateData = common.getMetadataMgr().getPrivateData(); + var autoStore = Util.find(privateData, ['settings', 'general', 'autostore']) || 0; + var manualStore = autoStore === 1 ? undefined : + UI.createCheckbox('cp-upload-store', Messages.autostore_forceSave, true, { + input: { disabled: true } + }); + // Ask for name, password and owner var content = h('div', [ h('h4', Messages.upload_modal_title), @@ -247,8 +254,18 @@ define([ UI.createCheckbox('cp-upload-owned', Messages.upload_modal_owner, true), createHelper('/faq.html#keywords-owned', Messages.creation_owned1) ]), + manualStore ]); + $(content).find('#cp-upload-owned').on('change', function () { + var val = $(content).find('#cp-upload-owned').is(':checked'); + if (val) { + $(content).find('#cp-upload-store').prop('checked', true).prop('disabled', true); + } else { + $(content).find('#cp-upload-store').prop('disabled', false); + } + }); + UI.confirm(content, function (yes) { if (!yes) { return void cb(); } @@ -256,6 +273,7 @@ define([ var newName = $(content).find('#cp-upload-name').val(); var password = $(content).find('#cp-upload-password').val() || undefined; var owned = $(content).find('#cp-upload-owned').is(':checked'); + var forceSave = owned || $(content).find('#cp-upload-store').is(':checked'); // Add extension to the name if needed if (!newName || !newName.trim()) { newName = file.name; } @@ -266,7 +284,8 @@ define([ cb({ name: newName, password: password, - owned: owned + owned: owned, + forceSave: forceSave }); }); }; @@ -284,6 +303,7 @@ define([ var name = file.name; var password; var owned = true; + var forceSave; var finish = function (abort) { if (!abort) { var metadata = { @@ -296,6 +316,7 @@ define([ metadata: metadata, password: password, owned: owned, + forceSave: forceSave, dropEvent: e }); } @@ -316,6 +337,7 @@ define([ name = obj.name; password = obj.password; owned = obj.owned; + forceSave = obj.forceSave; finish(); }); }; diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 64070a8c8..240802829 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -452,8 +452,8 @@ define([ UI.errorLoadingScreen($err, true, true); }); - ctx.sframeChan.on('EV_AUTOSTORE_DISPLAY_POPUP', function () { - UIElements.displayStorePadPopup(funcs); + ctx.sframeChan.on('EV_AUTOSTORE_DISPLAY_POPUP', function (data) { + UIElements.displayStorePadPopup(funcs, data); }); ctx.metadataMgr.onReady(waitFor()); diff --git a/www/settings/app-settings.less b/www/settings/app-settings.less index c8e5eb2e3..67a31ed40 100644 --- a/www/settings/app-settings.less +++ b/www/settings/app-settings.less @@ -52,6 +52,16 @@ width: @sidebar_button-width; } } + + .cp-settings-autostore-radio { + display: flex; + align-items: center; + flex-wrap: wrap; + label { + margin-right: 40px; + } + } + .cp-settings-change-password { [type="password"], [type="text"] { width: @sidebar_button-width; diff --git a/www/settings/inner.js b/www/settings/inner.js index ee1038752..ddb11f4d9 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -47,8 +47,7 @@ define([ 'cp-settings-displayname', 'cp-settings-language-selector', 'cp-settings-logout-everywhere', - 'cp-settings-resettips', - 'cp-settings-thumbnails', + 'cp-settings-autostore', 'cp-settings-userfeedback', 'cp-settings-change-password', 'cp-settings-delete' @@ -60,6 +59,8 @@ define([ 'cp-settings-creation-template' ], 'drive': [ + 'cp-settings-resettips', + 'cp-settings-thumbnails', 'cp-settings-drive-backup', 'cp-settings-drive-import-local', 'cp-settings-drive-reset' @@ -208,71 +209,56 @@ define([ return $div; }; - create['resettips'] = function () { - var $div = $('
', {'class': 'cp-settings-resettips cp-sidebarlayout-element'}); - $('