Merge branch 'staging' into framework

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

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 = [];