Merge branch 'staging' into framework

This commit is contained in:
Caleb James DeLisle 2017-10-13 13:41:24 +03:00
commit 15337603bb
12 changed files with 54 additions and 54 deletions

View File

@ -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_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_noentry = "Vous ne pouvez pas ajouter de mots-clés à un pad supprimé!";
out.slideOptionsText = "Options";
out.slideOptionsTitle = "Personnaliser la présentation";

View File

@ -163,8 +163,8 @@ define(function () {
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_notShared = "Your tags are not shared with other users";
out.tags_duplicate = "Duplicate tag: {0}";
out.tags_noentry = "You can't tag a deleted pad!";
out.slideOptionsText = "Options";
out.slideOptionsTitle = "Customize your slides";

View File

@ -28,6 +28,9 @@ define([
var u8 = file.blob; // This is not a blob but a uint8array
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 next = FileCrypto.encrypt(u8, metadata, key);
@ -73,6 +76,7 @@ define([
if (noStore) { return void onComplete(href); }
common.initialPath = dropEvent && dropEvent.path;
common.renamePad(title || "", href, function (err) {
if (err) { return void console.error(err); }
onComplete(href);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1037,9 +1037,6 @@ define([
ev.dataTransfer.setData("text", stringify(data));
};
var onFileDrop = APP.onFileDrop = function (file, e) {
APP.FM.onFileDrop(file, e);
};
var findDropPath = function (target) {
var $target = $(target);
var $el = findDataHolder($target);
@ -1050,6 +1047,13 @@ define([
}
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) {
ev.preventDefault();
$('.cp-app-drive-element-droppable').removeClass('cp-app-drive-element-droppable');
@ -1474,7 +1478,8 @@ define([
}).on('change', function (e) {
var file = e.target.files[0];
var ev = {
target: $content[0]
target: $content[0],
path: findDropPath($content[0])
};
APP.FM.handleFile(file, ev);
});
@ -2846,25 +2851,8 @@ define([
var fmConfig = {
noHandlers: true,
onUploaded: function (ev, data) {
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();
} catch (e) {
console.error(e);
refresh();
}
onUploaded: function () {
refresh();
},
body: $('body')
};

View File

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

View File

@ -109,7 +109,7 @@ define([
});
//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));
}

View File

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