Merge branch 'staging' into framework

pull/1/head
Caleb James DeLisle 7 years ago
commit 15337603bb

@ -161,6 +161,7 @@ define(function () {
out.tags_searchHint = "Commencez une recherche par # dans votre CryptDrive pour retrouver vos pads par mot-clé."; out.tags_searchHint = "Commencez une recherche par # dans votre CryptDrive pour retrouver vos pads par mot-clé.";
out.tags_notShared = "Vos mots-clés ne sont pas partagés avec les autres utilisateurs."; out.tags_notShared = "Vos mots-clés ne sont pas partagés avec les autres utilisateurs.";
out.tags_duplicate = "Mot-clé déjà présent : {0}"; out.tags_duplicate = "Mot-clé déjà présent : {0}";
out.tags_noentry = "Vous ne pouvez pas ajouter de mots-clés à un pad supprimé!";
out.slideOptionsText = "Options"; out.slideOptionsText = "Options";
out.slideOptionsTitle = "Personnaliser la présentation"; out.slideOptionsTitle = "Personnaliser la présentation";

@ -163,8 +163,8 @@ define(function () {
out.tags_searchHint = "Find files by their tags by searching in your CryptDrive"; out.tags_searchHint = "Find files by their tags by searching in your CryptDrive";
out.tags_searchHint = "Start a search with # in your CryptDrive to find your tagged pads."; out.tags_searchHint = "Start a search with # in your CryptDrive to find your tagged pads.";
out.tags_notShared = "Your tags are not shared with other users"; out.tags_notShared = "Your tags are not shared with other users";
out.tags_duplicate = "Duplicate tag: {0}"; out.tags_duplicate = "Duplicate tag: {0}";
out.tags_noentry = "You can't tag a deleted pad!";
out.slideOptionsText = "Options"; out.slideOptionsText = "Options";
out.slideOptionsTitle = "Customize your slides"; out.slideOptionsTitle = "Customize your slides";

@ -28,6 +28,9 @@ define([
var u8 = file.blob; // This is not a blob but a uint8array var u8 = file.blob; // This is not a blob but a uint8array
var metadata = file.metadata; var metadata = file.metadata;
// if it exists, dropEvent contains the new pad location in the drive
var dropEvent = file.dropEvent;
var key = Nacl.randomBytes(32); var key = Nacl.randomBytes(32);
var next = FileCrypto.encrypt(u8, metadata, key); var next = FileCrypto.encrypt(u8, metadata, key);
@ -73,6 +76,7 @@ define([
if (noStore) { return void onComplete(href); } if (noStore) { return void onComplete(href); }
common.initialPath = dropEvent && dropEvent.path;
common.renamePad(title || "", href, function (err) { common.renamePad(title || "", href, function (err) {
if (err) { return void console.error(err); } if (err) { return void console.error(err); }
onComplete(href); onComplete(href);

@ -93,7 +93,6 @@ define([
var metadata = file.metadata; var metadata = file.metadata;
var id = file.id; var id = file.id;
var dropEvent = file.dropEvent; var dropEvent = file.dropEvent;
delete file.dropEvent;
if (queue.inProgress) { return; } if (queue.inProgress) { return; }
queue.inProgress = true; queue.inProgress = true;

@ -31,7 +31,12 @@ define([
UI.updateTags = function (common, href) { UI.updateTags = function (common, href) {
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
sframeChan.query('Q_TAGS_GET', href || null, function (err, res) { sframeChan.query('Q_TAGS_GET', href || null, function (err, res) {
if (err || res.error) { return void console.error(err || res.error); } if (err || res.error) {
if (res.error === 'NO_ENTRY') {
Cryptpad.alert(Messages.tags_noentry);
}
return void console.error(err || res.error);
}
Cryptpad.dialog.tagPrompt(res.data, function (tags) { Cryptpad.dialog.tagPrompt(res.data, function (tags) {
if (!Array.isArray(tags)) { return; } if (!Array.isArray(tags)) { return; }
sframeChan.event('EV_TAGS_SET', { sframeChan.event('EV_TAGS_SET', {
@ -98,6 +103,7 @@ define([
break; break;
case 'template': case 'template':
if (!AppConfig.enableTemplates) { return; } if (!AppConfig.enableTemplates) { return; }
if (!common.isLoggedIn()) { return; }
button = $('<button>', { button = $('<button>', {
title: Messages.saveTemplateButton, title: Messages.saveTemplateButton,
}).append($('<span>', {'class':'fa fa-bookmark', style: 'font:'+size+' FontAwesome'})); }).append($('<span>', {'class':'fa fa-bookmark', style: 'font:'+size+' FontAwesome'}));
@ -581,11 +587,18 @@ define([
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var focus; var focus;
var pickerCfg = {
types: [type],
where: ['template'],
hidden: true
};
var onConfirm = function (yes) { var onConfirm = function (yes) {
if (!yes) { if (!yes) {
if (focus) { focus.focus(); } if (focus) { focus.focus(); }
return; return;
} }
delete pickerCfg.hidden;
common.openFilePicker(pickerCfg);
var first = true; // We can only pick a template once (for a new document) var first = true; // We can only pick a template once (for a new document)
var fileDialogCfg = { var fileDialogCfg = {
onSelect: function (data) { onSelect: function (data) {
@ -602,15 +615,11 @@ define([
} }
}; };
common.initFilePicker(fileDialogCfg); common.initFilePicker(fileDialogCfg);
var pickerCfg = {
types: [type],
where: ['template']
};
common.openFilePicker(pickerCfg);
}; };
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
if (data) { if (data) {
common.openFilePicker(pickerCfg);
focus = document.activeElement; focus = document.activeElement;
Cryptpad.confirm(Messages.useTemplate, onConfirm, { Cryptpad.confirm(Messages.useTemplate, onConfirm, {
ok: Messages.useTemplateOK, ok: Messages.useTemplateOK,

@ -362,7 +362,8 @@ define([
// File picker // File picker
var FP = {}; var FP = {};
var initFilePicker = function (types) { var initFilePicker = function (cfg) {
if (!FP.$iframe) {
var config = {}; var config = {};
config.onFilePicked = function (data) { config.onFilePicked = function (data) {
sframeChan.event('EV_FILE_PICKED', data); sframeChan.event('EV_FILE_PICKED', data);
@ -371,13 +372,16 @@ define([
FP.$iframe.hide(); FP.$iframe.hide();
}; };
config.onFileUpload = onFileUpload; config.onFileUpload = onFileUpload;
config.types = types; config.types = cfg;
if (!FP.$iframe) {
FP.$iframe = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body')); FP.$iframe = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body'));
FP.picker = FilePicker.create(config); FP.picker = FilePicker.create(config);
} else { } else {
FP.$iframe.show(); FP.$iframe.show();
FP.picker.refresh(types); FP.picker.refresh(cfg);
}
if (cfg.hidden) {
FP.$iframe.hide();
return;
} }
FP.$iframe.focus(); FP.$iframe.focus();
}; };

@ -190,6 +190,7 @@ define([
}); });
}; };
funcs.setPadAttribute = function (key, value, cb) { funcs.setPadAttribute = function (key, value, cb) {
cb = cb || $.noop;
ctx.sframeChan.query('Q_SET_PAD_ATTRIBUTE', { ctx.sframeChan.query('Q_SET_PAD_ATTRIBUTE', {
key: key, key: key,
value: value value: value

@ -499,7 +499,6 @@ define([
}); });
}; };
var spliceFileData = exp.removeData = function (id) { var spliceFileData = exp.removeData = function (id) {
files[FILES_DATA][id] = undefined;
delete files[FILES_DATA][id]; delete files[FILES_DATA][id];
}; };
@ -649,7 +648,6 @@ define([
var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null; var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null;
if (hash && key.indexOf(hash) === 0) { if (hash && key.indexOf(hash) === 0) {
debug("Deleting pad attribute in the realtime object"); debug("Deleting pad attribute in the realtime object");
files[key] = undefined;
delete files[key]; delete files[key];
} }
}); });
@ -709,7 +707,6 @@ define([
var parentPath = path.slice(); var parentPath = path.slice();
var key = parentPath.pop(); var key = parentPath.pop();
var parentEl = find(parentPath); var parentEl = find(parentPath);
parentEl[key] = undefined;
delete parentEl[key]; delete parentEl[key];
}); });
@ -728,7 +725,6 @@ define([
return; return;
} }
// Trash but not root: it's just a tree so remove the key // Trash but not root: it's just a tree so remove the key
parentEl[key] = undefined;
delete parentEl[key]; delete parentEl[key];
}); });
deleteMultipleTrashRoot(trashRoot); deleteMultipleTrashRoot(trashRoot);
@ -767,7 +763,6 @@ define([
return; return;
} }
parentEl[newName] = element; parentEl[newName] = element;
parentEl[oldName] = undefined;
delete parentEl[oldName]; delete parentEl[oldName];
if (typeof cb === "function") { cb(); } if (typeof cb === "function") { cb(); }
return; return;
@ -777,7 +772,6 @@ define([
var data = files[FILES_DATA][element]; var data = files[FILES_DATA][element];
if (!data) { return; } if (!data) { return; }
if (!newName || newName.trim() === "") { if (!newName || newName.trim() === "") {
data.filename = undefined;
delete data.filename; delete data.filename;
if (typeof cb === "function") { cb(); } if (typeof cb === "function") { cb(); }
return; return;
@ -899,9 +893,7 @@ define([
delete parent[okey]; delete parent[okey];
}); });
}); });
files[OLD_FILES_DATA] = undefined;
delete files[OLD_FILES_DATA]; delete files[OLD_FILES_DATA];
files.migrate = undefined;
delete files.migrate; delete files.migrate;
console.log('done'); console.log('done');
todo(); todo();
@ -942,7 +934,6 @@ define([
for (var el in element) { for (var el in element) {
if (!isFile(element[el], true) && !isFolder(element[el])) { if (!isFile(element[el], true) && !isFolder(element[el])) {
debug("An element in ROOT was not a folder nor a file. ", element[el]); debug("An element in ROOT was not a folder nor a file. ", element[el]);
element[el] = undefined;
delete element[el]; delete element[el];
continue; continue;
} }
@ -994,11 +985,9 @@ define([
for (var el in tr) { for (var el in tr) {
if (!Array.isArray(tr[el])) { if (!Array.isArray(tr[el])) {
debug("An element in TRASH root is not an array. ", tr[el]); debug("An element in TRASH root is not an array. ", tr[el]);
tr[el] = undefined;
delete tr[el]; delete tr[el];
} else if (tr[el].length === 0) { } else if (tr[el].length === 0) {
debug("Empty array in TRASH root. ", tr[el]); debug("Empty array in TRASH root. ", tr[el]);
tr[el] = undefined;
delete tr[el]; delete tr[el];
} else { } else {
toClean = []; toClean = [];

@ -1037,9 +1037,6 @@ define([
ev.dataTransfer.setData("text", stringify(data)); ev.dataTransfer.setData("text", stringify(data));
}; };
var onFileDrop = APP.onFileDrop = function (file, e) {
APP.FM.onFileDrop(file, e);
};
var findDropPath = function (target) { var findDropPath = function (target) {
var $target = $(target); var $target = $(target);
var $el = findDataHolder($target); var $el = findDataHolder($target);
@ -1050,6 +1047,13 @@ define([
} }
return newPath; return newPath;
}; };
var onFileDrop = APP.onFileDrop = function (file, e) {
var ev = {
target: e.target,
path: findDropPath(e.target)
};
APP.FM.onFileDrop(file, ev);
};
var onDrop = function (ev) { var onDrop = function (ev) {
ev.preventDefault(); ev.preventDefault();
$('.cp-app-drive-element-droppable').removeClass('cp-app-drive-element-droppable'); $('.cp-app-drive-element-droppable').removeClass('cp-app-drive-element-droppable');
@ -1474,7 +1478,8 @@ define([
}).on('change', function (e) { }).on('change', function (e) {
var file = e.target.files[0]; var file = e.target.files[0];
var ev = { var ev = {
target: $content[0] target: $content[0],
path: findDropPath($content[0])
}; };
APP.FM.handleFile(file, ev); APP.FM.handleFile(file, ev);
}); });
@ -2846,25 +2851,8 @@ define([
var fmConfig = { var fmConfig = {
noHandlers: true, noHandlers: true,
onUploaded: function (ev, data) { onUploaded: function () {
try {
// Get the folder path
console.log(ev.target);
console.log(data);
var newPath = findDropPath(ev.target);
if (!newPath) { return void refresh(); }
var href = data.url;
// Get the current file location in ROOT
var id = filesOp.getIdFromHref(href);
var paths = filesOp.findFile(id);
if (paths.length !== 1) { return; }
// Try to move and refresh
moveElements([paths[0]], newPath, true);
refresh(); refresh();
} catch (e) {
console.error(e);
refresh();
}
}, },
body: $('body') body: $('body')
}; };

@ -94,6 +94,8 @@ define([
Title.updateTitle(title || Title.defaultTitle); Title.updateTitle(title || Title.defaultTitle);
toolbar.addElement(['pageTitle'], {pageTitle: title}); toolbar.addElement(['pageTitle'], {pageTitle: title});
common.setPadAttribute('fileType', metadata.type);
var displayFile = function (ev, sizeMb, CB) { var displayFile = function (ev, sizeMb, CB) {
var called_back; var called_back;
var cb = function (e) { var cb = function (e) {

@ -109,7 +109,7 @@ define([
}); });
//If file, display the upload button //If file, display the upload button
if (types.indexOf('file') !== -1) { if (types.indexOf('file') !== -1 && common.isLoggedIn()) {
$filter.append(common.createButton('upload', false, data)); $filter.append(common.createButton('upload', false, data));
} }

@ -277,10 +277,13 @@ div#cp-app-slide-modal #cp-app-slide-modal-content, #cp-app-slide-print {
// fixes image overflowing // fixes image overflowing
media-tag { media-tag {
height: 100%; height: 100%;
flex-flow: row;
justify-content: center;
& + * { & + * {
margin-top: 1rem; margin-top: 1rem;
} }
img { flex: unset; }
} }
img { img {

Loading…
Cancel
Save