diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index df5205287..9a9bc0b53 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -523,6 +523,9 @@ define(function () {
out.settings_codeUseTabs = "Utiliser des tabulations au lieu d'espaces";
out.upload_title = "Hébergement de fichiers";
+ 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_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 29735e18f..23a1f56c2 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -528,6 +528,9 @@ define(function () {
out.settings_codeUseTabs = "Indent using tabs (instead of spaces)";
out.upload_title = "File upload";
+ 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_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-thumbnail.js b/www/common/common-thumbnail.js
index 6c561e52a..f1e5b0631 100644
--- a/www/common/common-thumbnail.js
+++ b/www/common/common-thumbnail.js
@@ -105,6 +105,7 @@ define([
var ctx = c2.getContext('2d');
ctx.drawImage(canvas, D.x, D.y, D.w, D.h);
+
cb(void 0, c2.toDataURL());
};
@@ -124,19 +125,18 @@ define([
Thumb.fromVideoBlob = function (blob, cb) {
var url = URL.createObjectURL(blob);
var video = document.createElement("VIDEO");
-
- video.src = url;
video.addEventListener('loadedmetadata', function() {
- video.currentTime = Number(Math.floor(Math.min(video.duration/10, 5)));
video.addEventListener('loadeddata', function() {
var D = getResizedDimensions(video, 'video');
Thumb.fromCanvas(video, D, cb);
});
+ video.currentTime = Number(Math.floor(Math.min(video.duration/10, 5)));
});
video.addEventListener('error', function (e) {
console.error(e);
cb('ERROR');
});
+ video.src = url;
};
Thumb.fromPdfBlob = function (blob, cb) {
require.config({paths: {'pdfjs-dist': '/common/pdfjs'}});
diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js
index 4ebe35723..7feca4c51 100644
--- a/www/common/sframe-common-file.js
+++ b/www/common/sframe-common-file.js
@@ -95,7 +95,7 @@ define([
var id = file.id;
var dropEvent = file.dropEvent;
delete file.dropEvent;
- if (dropEvent.path) { file.path = dropEvent.path; }
+ if (dropEvent && dropEvent.path) { file.path = dropEvent.path; }
if (queue.inProgress) { return; }
queue.inProgress = true;
@@ -221,12 +221,41 @@ define([
queue.next();
};
- var handleFile = File.handleFile = function (file, e, thumbnail) {
+ var showNamePrompt = true;
+ var promptName = function (file, cb) {
+ var extIdx = file.name.lastIndexOf('.');
+ var name = extIdx !== -1 ? file.name.slice(0,extIdx) : file.name;
+ var ext = extIdx !== -1 ? file.name.slice(extIdx) : "";
+ var msg = Messages._getKey('upload_rename', [
+ Util.fixHTML(file.name),
+ Util.fixHTML(ext)
+ ]);
+ UI.prompt(msg, name, function (newName) {
+ if (newName === null) {
+ showNamePrompt = false;
+ return void cb (file.name);
+ }
+ if (!newName || !newName.trim()) { return void cb (file.name); }
+ var newExtIdx = newName.lastIndexOf('.');
+ var newExt = newExtIdx !== -1 ? newName.slice(newExtIdx) : "";
+ if (newExt !== ext) { newName += ext; }
+ cb(newName);
+ }, null, true);
+ };
+ var handleFileState = {
+ queue: [],
+ inProgress: false
+ };
+ var handleFile = File.handleFile = function (file, e) {
+ //if (handleFileState.inProgress) { return void handleFileState.queue.push(file); }
+ handleFileState.inProgress = true;
+
var thumb;
var file_arraybuffer;
+ var name = file.name;
var finish = function () {
var metadata = {
- name: file.name,
+ name: name,
type: file.type,
};
if (thumb) { metadata.thumbnail = thumb; }
@@ -235,26 +264,26 @@ define([
metadata: metadata,
dropEvent: e
});
+ handleFileState.inProgress = false;
+ if (handleFileState.queue.length) { handleFile(handleFileState.queue.shift()); }
+ };
+ var getName = function () {
+ promptName(file, function (newName) {
+ name = newName;
+ finish();
+ });
};
blobToArrayBuffer(file, function (e, buffer) {
if (e) { console.error(e); }
file_arraybuffer = buffer;
- if (thumbnail) { // there is already a thumbnail
- return blobToArrayBuffer(thumbnail, function (e, buffer) {
- if (e) { console.error(e); }
- thumb = arrayBufferToString(buffer);
- finish();
- });
- }
-
- if (!Thumb.isSupportedType(file.type)) { return finish(); }
+ if (!Thumb.isSupportedType(file.type)) { return getName(); }
// make a resized thumbnail from the image..
Thumb.fromBlob(file, function (e, thumb64) {
if (e) { console.error(e); }
- if (!thumb64) { return finish(); }
+ if (!thumb64) { return getName(); }
thumb = thumb64;
- finish();
+ getName();
});
});
};