|
|
|
@ -205,6 +205,17 @@ define([
|
|
|
|
|
var $trashTreeContextMenu = $iframe.find("#trashTreeContextMenu");
|
|
|
|
|
var $trashContextMenu = $iframe.find("#trashContextMenu");
|
|
|
|
|
|
|
|
|
|
$tree.on('drop dragover', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
$driveToolbar.on('drop dragover', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TOOLBAR
|
|
|
|
|
|
|
|
|
|
/* add a "change username" button */
|
|
|
|
@ -954,23 +965,7 @@ define([
|
|
|
|
|
if (filesOp.isPathIn(newPath, [TRASH]) && paths.length && paths[0][0] === TRASH) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// "force" is currently unused but may be configurable by user
|
|
|
|
|
if (newPath[0] !== TRASH || force) {
|
|
|
|
|
andThen();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var msg = Messages._getKey('fm_removeSeveralDialog', [paths.length]);
|
|
|
|
|
if (paths.length === 1) {
|
|
|
|
|
var path = paths[0].slice();
|
|
|
|
|
var el = filesOp.find(path);
|
|
|
|
|
var name = filesOp.isFile(el) ? getElementName(path) : path.pop();
|
|
|
|
|
msg = Messages._getKey('fm_removeDialog', [name]);
|
|
|
|
|
}
|
|
|
|
|
Cryptpad.confirm(msg, function (res) {
|
|
|
|
|
$(ifrw).focus();
|
|
|
|
|
if (!res) { return; }
|
|
|
|
|
andThen();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// Drag & drop:
|
|
|
|
|
// The data transferred is a stringified JSON containing the path of the dragged element
|
|
|
|
@ -1012,13 +1007,30 @@ 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);
|
|
|
|
|
var newPath = $el.data('path');
|
|
|
|
|
if ((!newPath || filesOp.isFile(filesOp.find(newPath)))
|
|
|
|
|
&& $target.parents('#content')) {
|
|
|
|
|
newPath = currentPath;
|
|
|
|
|
}
|
|
|
|
|
return newPath;
|
|
|
|
|
};
|
|
|
|
|
var onDrop = function (ev) {
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
$iframe.find('.droppable').removeClass('droppable');
|
|
|
|
|
var data = ev.dataTransfer.getData("text");
|
|
|
|
|
|
|
|
|
|
// Don't the the normal drop handler for file upload
|
|
|
|
|
var fileDrop = ev.dataTransfer.files;
|
|
|
|
|
if (fileDrop.length) { return void onFileDrop(fileDrop, ev); }
|
|
|
|
|
|
|
|
|
|
var oldPaths = JSON.parse(data).path;
|
|
|
|
|
if (!oldPaths) { return; }
|
|
|
|
|
|
|
|
|
|
// Dropped elements can be moved from the same file manager or imported from another one.
|
|
|
|
|
// A moved element should be removed from its previous location
|
|
|
|
|
var movedPaths = [];
|
|
|
|
@ -1032,8 +1044,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var $el = findDataHolder($(ev.target));
|
|
|
|
|
var newPath = $el.data('path');
|
|
|
|
|
var newPath = findDropPath(ev.target);
|
|
|
|
|
if (!newPath) { return; }
|
|
|
|
|
if (movedPaths && movedPaths.length) {
|
|
|
|
|
moveElements(movedPaths, newPath, null, refresh);
|
|
|
|
@ -1069,6 +1080,8 @@ define([
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
});
|
|
|
|
|
$element.on('drop', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
onDrop(e.originalEvent);
|
|
|
|
|
});
|
|
|
|
|
$element.on('dragenter', function (e) {
|
|
|
|
@ -1087,6 +1100,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
addDragAndDropHandlers($content, null, true, true);
|
|
|
|
|
|
|
|
|
|
// In list mode, display metadata from the filesData object
|
|
|
|
|
// _WORKGROUP_ : Do not display title, atime and ctime columns since we don't have files data
|
|
|
|
@ -1427,6 +1441,30 @@ define([
|
|
|
|
|
return $block;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createUploadButton = function () {
|
|
|
|
|
var inTrash = filesOp.isPathIn(currentPath, [TRASH]);
|
|
|
|
|
var $icon = $('<span>', {
|
|
|
|
|
'class': 'fa fa-upload'
|
|
|
|
|
});
|
|
|
|
|
var $input = $('<input>', {
|
|
|
|
|
'type': 'file',
|
|
|
|
|
'style': 'display: none;'
|
|
|
|
|
}).on('change', function (e) {
|
|
|
|
|
var file = e.target.files[0];
|
|
|
|
|
var ev = {
|
|
|
|
|
target: $content[0]
|
|
|
|
|
};
|
|
|
|
|
APP.FM.handleFile(file, ev);
|
|
|
|
|
});
|
|
|
|
|
var $button = $('<button>', {
|
|
|
|
|
'class': 'btn btn-primary new',
|
|
|
|
|
title: Messages.uploadButtonTitle
|
|
|
|
|
}).append($icon).append(' '+Messages.uploadButton).click(function () {
|
|
|
|
|
$input.click();
|
|
|
|
|
});
|
|
|
|
|
return $button;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var hideNewButton = function () {
|
|
|
|
|
$iframe.find('.dropdown-bar-content').hide();
|
|
|
|
|
};
|
|
|
|
@ -1863,6 +1901,7 @@ define([
|
|
|
|
|
|
|
|
|
|
// NewButton can be undefined if we're in read only mode
|
|
|
|
|
$toolbar.find('.leftside').append(createNewButton(isInRoot));
|
|
|
|
|
$toolbar.find('.leftside').append(createUploadButton());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $folderHeader = getFolderListHeader();
|
|
|
|
@ -2375,8 +2414,7 @@ define([
|
|
|
|
|
var name = paths[0].path[paths[0].path.length - 1];
|
|
|
|
|
if ($(this).hasClass("remove")) {
|
|
|
|
|
if (paths.length === 1) {
|
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_removePermanentlyDialog", [name]), function(res) {
|
|
|
|
|
Cryptpad.confirm(Messages.fm_removePermanentlyDialog, function(res) {
|
|
|
|
|
if (!res) { return; }
|
|
|
|
|
filesOp.delete([path], refresh);
|
|
|
|
|
});
|
|
|
|
@ -2392,7 +2430,14 @@ define([
|
|
|
|
|
}
|
|
|
|
|
else if ($(this).hasClass("restore")) {
|
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
|
if (path.length === 4) {
|
|
|
|
|
var el = filesOp.find(path);
|
|
|
|
|
if (filesOp.isFile(el)) {
|
|
|
|
|
name = filesOp.getTitle(el);
|
|
|
|
|
} else {
|
|
|
|
|
name = path[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_restoreDialog", [name]), function(res) {
|
|
|
|
|
if (!res) { return; }
|
|
|
|
|
filesOp.restore(path, refresh);
|
|
|
|
@ -2559,6 +2604,29 @@ define([
|
|
|
|
|
if (typeof(cb) === "function") { cb(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var fmConfig = {
|
|
|
|
|
noHandlers: true,
|
|
|
|
|
onUploaded: function (ev, data) {
|
|
|
|
|
try {
|
|
|
|
|
// Get the folder path
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
APP.FM = Cryptpad.createFileManager(fmConfig);
|
|
|
|
|
|
|
|
|
|
createReadme(proxy, function () {
|
|
|
|
|
refresh();
|
|
|
|
|
APP.userList.onChange();
|
|
|
|
@ -2657,7 +2725,7 @@ define([
|
|
|
|
|
|
|
|
|
|
var userList = APP.userList = info.userList;
|
|
|
|
|
var config = {
|
|
|
|
|
displayed: ['useradmin', 'spinner', 'lag', 'state', 'limit'],
|
|
|
|
|
displayed: ['useradmin', 'spinner', 'lag', 'state', 'limit', 'newpad'],
|
|
|
|
|
userList: {
|
|
|
|
|
list: userList,
|
|
|
|
|
userNetfluxId: info.myID
|
|
|
|
|