diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index fd406f7aa..970fc815e 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -600,6 +600,8 @@ define(function () {
out.upload_rename = "Souhaitez-vous renommer {0} avant son stockage en ligne ?
" +
"L'extension du fichier ({1}) sera ajoutée automatiquement. "+
"Ce nom sera permanent et visible par les autres utilisateurs.";
+ out.upload_password = "Souhaitez-vous protéger ce fichier avec un mot de passe ?
" +
+ "Choisir Ne plus demander implique qu'aucun fichier importé durant cette session n'aura de mot de passe.";
out.upload_serverError = "Erreur interne: impossible d'importer le fichier pour l'instant.";
out.upload_uploadPending = "Vous avez déjà un fichier en cours d'importation. Souhaitez-vous l'annuler et importer ce nouveau fichier ?";
out.upload_success = "Votre fichier ({0}) a été importé avec succès et ajouté à votre CryptDrive.";
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index eb29b9395..21e1b1817 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -604,6 +604,8 @@ define(function () {
out.upload_rename = "Do you want to rename {0} before uploading it to the server?
" +
"The file extension ({1}) will be added automatically. "+
"This name will be permanent and visible to other users.";
+ out.upload_password = "Do you want to protect your file with a password?
" +
+ "If you choose Do not ask me again, uploaded files won't have a password.";
out.upload_serverError = "Server Error: unable to upload your file at this time.";
out.upload_uploadPending = "You already have an upload in progress. Cancel it and upload your new file?";
out.upload_success = "Your file ({0}) has been successfully uploaded and added to your drive.";
diff --git a/www/common/common-interface.js b/www/common/common-interface.js
index 0592d859a..2653c71b3 100644
--- a/www/common/common-interface.js
+++ b/www/common/common-interface.js
@@ -425,9 +425,14 @@ define([
cb = cb || function () {};
opt = opt || {};
- var input = dialog.textInput();
+ var inputBlock = opt.password ? UI.passwordInput() : dialog.textInput();
+ var input = opt.password ? $(inputBlock).find('input')[0] : inputBlock;
input.value = typeof(def) === 'string'? def: '';
+ if (opt.password) {
+ $(inputBlock).find('.cp-checkmark').css('margin-bottom', '15px');
+ }
+
var message;
if (typeof(msg) === 'string') {
if (!force) { msg = Util.fixHTML(msg); }
@@ -441,7 +446,7 @@ define([
var cancel = dialog.cancelButton(opt.cancel);
var frame = dialog.frame([
message,
- input,
+ inputBlock,
dialog.nav([ cancel, ok, ]),
]);
diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js
index 2c212701e..54ad2096c 100644
--- a/www/common/sframe-common-file.js
+++ b/www/common/sframe-common-file.js
@@ -212,8 +212,10 @@ define([
queue.next();
};
- // Don't show the rename prompt if we don't want to store the file in the drive (avatar)
+ // Don't show the rename and password prompts if we don't store the file in the drive
+ // e.g. avatar
var showNamePrompt = !config.noStore;
+ var showPasswordPrompt = !config.noStore;
var promptName = function (file, cb) {
var extIdx = file.name.lastIndexOf('.');
@@ -225,6 +227,7 @@ define([
]);
UI.prompt(msg, name, function (newName) {
if (newName === null) {
+ // "Don't ask me again"
showNamePrompt = false;
return void cb (file.name);
}
@@ -235,6 +238,19 @@ define([
cb(newName);
}, {cancel: Messages.doNotAskAgain}, true);
};
+
+ var promptPassword = function (file, cb) {
+ var msg = Messages.upload_password;
+ UI.prompt(msg, '', function (password) {
+ if (password === null) {
+ // "Don't ask me again"
+ showPasswordPrompt = false;
+ return void cb ();
+ }
+ cb(password);
+ }, {cancel: Messages.doNotAskAgain, password: true}, true);
+ };
+
var handleFileState = {
queue: [],
inProgress: false
@@ -246,6 +262,7 @@ define([
var thumb;
var file_arraybuffer;
var name = file.name;
+ var password;
var finish = function () {
var metadata = {
name: name,
@@ -255,6 +272,7 @@ define([
queue.push({
blob: file_arraybuffer,
metadata: metadata,
+ password: password,
dropEvent: e
});
handleFileState.inProgress = false;
@@ -263,11 +281,18 @@ define([
handleFile(next[0], next[1]);
}
};
+ var getPassword = function () {
+ if (!showPasswordPrompt) { return void finish(); }
+ promptPassword(file, function (pw) {
+ password = pw;
+ finish();
+ });
+ };
var getName = function () {
- if (!showNamePrompt) { return void finish(); }
+ if (!showNamePrompt) { return void getPassword(); }
promptName(file, function (newName) {
name = newName;
- finish();
+ getPassword();
});
};