|
|
@ -45,10 +45,6 @@ define([
|
|
|
|
var TRASH = "trash";
|
|
|
|
var TRASH = "trash";
|
|
|
|
var TRASH_NAME = Messages.fm_trashName;
|
|
|
|
var TRASH_NAME = Messages.fm_trashName;
|
|
|
|
|
|
|
|
|
|
|
|
// anon: Virtual path, not stored in the object but extracted from FILES_DATA
|
|
|
|
|
|
|
|
var ANON = "anon";
|
|
|
|
|
|
|
|
var ANON_NAME = Messages.fm_anonName || 'Anon pads......';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
|
|
|
|
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
|
|
|
|
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
|
|
|
|
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
|
|
|
|
var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode";
|
|
|
|
var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode";
|
|
|
@ -173,7 +169,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
// FILE MANAGER
|
|
|
|
// FILE MANAGER
|
|
|
|
// _WORKGROUP_ and other people drive : display Documents as main page
|
|
|
|
// _WORKGROUP_ and other people drive : display Documents as main page
|
|
|
|
var currentPath = module.currentPath = APP.loggedIn ? isOwnDrive() ? getLastOpenedFolder() : [ROOT] : [ANON];
|
|
|
|
var currentPath = module.currentPath = isOwnDrive() ? getLastOpenedFolder() : [ROOT];
|
|
|
|
var lastSelectTime;
|
|
|
|
var lastSelectTime;
|
|
|
|
var selectedElement;
|
|
|
|
var selectedElement;
|
|
|
|
|
|
|
|
|
|
|
@ -192,6 +188,11 @@ define([
|
|
|
|
var $folderOpenedIcon = $('<span>', {"class": "fa fa-folder-open folder", style:"color:#FEDE8B;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"});
|
|
|
|
var $folderOpenedIcon = $('<span>', {"class": "fa fa-folder-open folder", style:"color:#FEDE8B;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"});
|
|
|
|
var $folderOpenedEmptyIcon = $folderOpenedIcon.clone();
|
|
|
|
var $folderOpenedEmptyIcon = $folderOpenedIcon.clone();
|
|
|
|
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file"});
|
|
|
|
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file"});
|
|
|
|
|
|
|
|
var $padIcon = $('<span>', {"class": "fa fa-file-word-o file"});
|
|
|
|
|
|
|
|
var $codeIcon = $('<span>', {"class": "fa fa-file-code-o file"});
|
|
|
|
|
|
|
|
var $slideIcon = $('<span>', {"class": "fa fa-file-powerpoint-o file"});
|
|
|
|
|
|
|
|
var $pollIcon = $('<span>', {"class": "fa fa-calendar file"});
|
|
|
|
|
|
|
|
var $anonIcon = $('<span>', {"class": "fa fa-user-secret file listonly"});
|
|
|
|
var $upIcon = $('<span>', {"class": "fa fa-arrow-circle-up"});
|
|
|
|
var $upIcon = $('<span>', {"class": "fa fa-arrow-circle-up"});
|
|
|
|
var $unsortedIcon = $('<span>', {"class": "fa fa-files-o"});
|
|
|
|
var $unsortedIcon = $('<span>', {"class": "fa fa-files-o"});
|
|
|
|
var $templateIcon = $('<span>', {"class": "fa fa-cubes"});
|
|
|
|
var $templateIcon = $('<span>', {"class": "fa fa-cubes"});
|
|
|
@ -645,6 +646,22 @@ define([
|
|
|
|
$span.append($name).append($subfolders).append($files);
|
|
|
|
$span.append($name).append($subfolders).append($files);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getFileIcon = function (href) {
|
|
|
|
|
|
|
|
var $icon = $fileIcon.clone();
|
|
|
|
|
|
|
|
var data = filesOp.getFileData(href);
|
|
|
|
|
|
|
|
if (!data) { return $icon; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (href.indexOf('/pad/') !== -1) { $icon = $padIcon.clone() }
|
|
|
|
|
|
|
|
else if (href.indexOf('/code/') !== -1) { $icon = $codeIcon.clone() }
|
|
|
|
|
|
|
|
else if (href.indexOf('/slide/') !== -1) { $icon = $slideIcon.clone() }
|
|
|
|
|
|
|
|
else if (href.indexOf('/poll/') !== -1) { $icon = $pollIcon.clone() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!data.owner) {
|
|
|
|
|
|
|
|
$icon = $('<span>').append($anonIcon.clone()).append($icon);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $icon;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Create the "li" element corresponding to the file/folder located in "path"
|
|
|
|
// Create the "li" element corresponding to the file/folder located in "path"
|
|
|
|
var createElement = function (path, elPath, root, isFolder) {
|
|
|
|
var createElement = function (path, elPath, root, isFolder) {
|
|
|
|
// Forbid drag&drop inside the trash
|
|
|
|
// Forbid drag&drop inside the trash
|
|
|
@ -660,7 +677,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var element = filesOp.findElement(files, newPath);
|
|
|
|
var element = filesOp.findElement(files, newPath);
|
|
|
|
var $icon = $fileIcon.clone();
|
|
|
|
var $icon = !isFolder ? getFileIcon(element) : undefined;
|
|
|
|
var spanClass = 'file-element element';
|
|
|
|
var spanClass = 'file-element element';
|
|
|
|
var liClass = 'file-item';
|
|
|
|
var liClass = 'file-item';
|
|
|
|
if (isFolder) {
|
|
|
|
if (isFolder) {
|
|
|
@ -732,7 +749,6 @@ define([
|
|
|
|
else if (name === TRASH && path.length === 1) { name = TRASH_NAME; }
|
|
|
|
else if (name === TRASH && path.length === 1) { name = TRASH_NAME; }
|
|
|
|
else if (name === UNSORTED && path.length === 1) { name = UNSORTED_NAME; }
|
|
|
|
else if (name === UNSORTED && path.length === 1) { name = UNSORTED_NAME; }
|
|
|
|
else if (name === TEMPLATE && path.length === 1) { name = TEMPLATE_NAME; }
|
|
|
|
else if (name === TEMPLATE && path.length === 1) { name = TEMPLATE_NAME; }
|
|
|
|
else if (name === ANON && path.length === 1) { name = ANON_NAME; }
|
|
|
|
|
|
|
|
else if (name === FILES_DATA && path.length === 1) { name = FILES_DATA_NAME; }
|
|
|
|
else if (name === FILES_DATA && path.length === 1) { name = FILES_DATA_NAME; }
|
|
|
|
else if (filesOp.isPathInTrash(path)) { name = getTrashTitle(path); }
|
|
|
|
else if (filesOp.isPathInTrash(path)) { name = getTrashTitle(path); }
|
|
|
|
var $title = $('<h1>').text(name);
|
|
|
|
var $title = $('<h1>').text(name);
|
|
|
@ -844,7 +860,7 @@ define([
|
|
|
|
options.push({tag: 'hr'});
|
|
|
|
options.push({tag: 'hr'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AppConfig.availablePadTypes.forEach(function (type) {
|
|
|
|
AppConfig.availablePadTypes.forEach(function (type) {
|
|
|
|
var path = filesOp.comparePath(currentPath, [ANON]) ? '' : '/#?path=' + encodeURIComponent(currentPath);
|
|
|
|
var path = '/#?path=' + encodeURIComponent(currentPath);
|
|
|
|
options.push({
|
|
|
|
options.push({
|
|
|
|
tag: 'a',
|
|
|
|
tag: 'a',
|
|
|
|
attributes: {
|
|
|
|
attributes: {
|
|
|
@ -1086,7 +1102,7 @@ define([
|
|
|
|
//return;
|
|
|
|
//return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var idx = files[rootName].indexOf(href);
|
|
|
|
var idx = files[rootName].indexOf(href);
|
|
|
|
var $icon = $fileIcon.clone();
|
|
|
|
var $icon = getFileIcon(href);
|
|
|
|
var $name = $('<span>', { 'class': 'file-element element' });
|
|
|
|
var $name = $('<span>', { 'class': 'file-element element' });
|
|
|
|
addFileData(href, file.title, $name, false);
|
|
|
|
addFileData(href, file.title, $name, false);
|
|
|
|
var $element = $('<li>', {
|
|
|
|
var $element = $('<li>', {
|
|
|
@ -1108,18 +1124,16 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var displayAllFiles = function ($container, anon) {
|
|
|
|
var displayAllFiles = function ($container) {
|
|
|
|
var allfiles = files[FILES_DATA];
|
|
|
|
var allfiles = files[FILES_DATA];
|
|
|
|
if (allfiles.length === 0) { return; }
|
|
|
|
if (allfiles.length === 0) { return; }
|
|
|
|
var $fileHeader = getFileListHeader(false);
|
|
|
|
var $fileHeader = getFileListHeader(false);
|
|
|
|
$container.append($fileHeader);
|
|
|
|
$container.append($fileHeader);
|
|
|
|
var keys = allfiles.filter(function (el) {
|
|
|
|
var keys = allfiles;
|
|
|
|
return anon && !el.owner || !anon && el.owner;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), false, true);
|
|
|
|
var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), false, true);
|
|
|
|
sortedFiles.forEach(function (file) {
|
|
|
|
sortedFiles.forEach(function (file) {
|
|
|
|
var $icon = $fileIcon.clone();
|
|
|
|
var $icon = getFileIcon(file.href);
|
|
|
|
var $name = $('<span>', { 'class': 'file-element element' });
|
|
|
|
var $name = $('<span>', { 'class': 'file-element element' });
|
|
|
|
addFileData(file.href, file.title, $name, false);
|
|
|
|
addFileData(file.href, file.title, $name, false);
|
|
|
|
var $element = $('<li>').append($icon).append($name).dblclick(function () {
|
|
|
|
var $element = $('<li>').append($icon).append($name).dblclick(function () {
|
|
|
@ -1181,7 +1195,7 @@ define([
|
|
|
|
if (!appStatus.isReady && !force) { return; }
|
|
|
|
if (!appStatus.isReady && !force) { return; }
|
|
|
|
// Only Trash and Root are available in not-owned files manager
|
|
|
|
// Only Trash and Root are available in not-owned files manager
|
|
|
|
if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
|
|
|
if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
|
|
|
log("TRANSLATE or REMOVE: Unable to open the selected category, displaying root"); //TODO translate
|
|
|
|
log("Unable to open the selected category, displaying root"); //TODO translate
|
|
|
|
currentPath = [ROOT];
|
|
|
|
currentPath = [ROOT];
|
|
|
|
displayDirectory(currentPath);
|
|
|
|
displayDirectory(currentPath);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1197,10 +1211,9 @@ define([
|
|
|
|
var isUnsorted = filesOp.comparePath(path, [UNSORTED]);
|
|
|
|
var isUnsorted = filesOp.comparePath(path, [UNSORTED]);
|
|
|
|
var isTemplate = filesOp.comparePath(path, [TEMPLATE]);
|
|
|
|
var isTemplate = filesOp.comparePath(path, [TEMPLATE]);
|
|
|
|
var isAllFiles = filesOp.comparePath(path, [FILES_DATA]);
|
|
|
|
var isAllFiles = filesOp.comparePath(path, [FILES_DATA]);
|
|
|
|
var isAnon = filesOp.comparePath(path, [ANON]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var root = filesOp.findElement(files, path);
|
|
|
|
var root = filesOp.findElement(files, path);
|
|
|
|
if (typeof(root) === "undefined" && !isAnon) {
|
|
|
|
if (typeof(root) === "undefined") {
|
|
|
|
log(Messages.fm_unknownFolderError);
|
|
|
|
log(Messages.fm_unknownFolderError);
|
|
|
|
debug("Unable to locate the selected directory: ", path);
|
|
|
|
debug("Unable to locate the selected directory: ", path);
|
|
|
|
var parentPath = path.slice();
|
|
|
|
var parentPath = path.slice();
|
|
|
@ -1236,12 +1249,9 @@ define([
|
|
|
|
var $fileHeader = getFileListHeader(true);
|
|
|
|
var $fileHeader = getFileListHeader(true);
|
|
|
|
|
|
|
|
|
|
|
|
if (isUnsorted || isTemplate) {
|
|
|
|
if (isUnsorted || isTemplate) {
|
|
|
|
// 3rd parameter is "draggable": anon pads shouldn't be draggable
|
|
|
|
displayHrefArray($list, path[0]);
|
|
|
|
displayHrefArray($list, path[0], !isAnon);
|
|
|
|
|
|
|
|
} else if (isAllFiles) {
|
|
|
|
} else if (isAllFiles) {
|
|
|
|
displayAllFiles($list, false);
|
|
|
|
displayAllFiles($list);
|
|
|
|
} else if (isAnon) {
|
|
|
|
|
|
|
|
displayAllFiles($list, true);
|
|
|
|
|
|
|
|
} else if (isTrashRoot) {
|
|
|
|
} else if (isTrashRoot) {
|
|
|
|
displayTrashRoot($list, $folderHeader, $fileHeader);
|
|
|
|
displayTrashRoot($list, $folderHeader, $fileHeader);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -1392,18 +1402,6 @@ define([
|
|
|
|
$container.append($allfilesList);
|
|
|
|
$container.append($allfilesList);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var createAnonFiles = function ($container, path, anonUser) {
|
|
|
|
|
|
|
|
var $icon = $unsortedIcon.clone();
|
|
|
|
|
|
|
|
var isOpened = filesOp.comparePath(path, currentPath);
|
|
|
|
|
|
|
|
var $allfilesElement = createTreeElement(ANON_NAME, $icon, [ANON], false, false, false, isOpened);
|
|
|
|
|
|
|
|
$allfilesElement.addClass('root');
|
|
|
|
|
|
|
|
var $allfilesList = $('<ul>', { id: 'anonTree', 'class': 'category2' }).append($allfilesElement);
|
|
|
|
|
|
|
|
if (anonUser) {
|
|
|
|
|
|
|
|
$allfilesList.removeClass('category2');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$container.append($allfilesList);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var createTrash = function ($container, path) {
|
|
|
|
var createTrash = function ($container, path) {
|
|
|
|
var $icon = filesOp.isFolderEmpty(files[TRASH]) ? $trashEmptyIcon.clone() : $trashIcon.clone();
|
|
|
|
var $icon = filesOp.isFolderEmpty(files[TRASH]) ? $trashEmptyIcon.clone() : $trashIcon.clone();
|
|
|
|
var isOpened = filesOp.comparePath(path, currentPath);
|
|
|
|
var isOpened = filesOp.comparePath(path, currentPath);
|
|
|
@ -1426,15 +1424,10 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var resetTree = module.resetTree = function () {
|
|
|
|
var resetTree = module.resetTree = function () {
|
|
|
|
$tree.html('');
|
|
|
|
$tree.html('');
|
|
|
|
if (!APP.loggedIn) {
|
|
|
|
|
|
|
|
createAnonFiles($tree, [ANON], true);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
createTree($tree, [ROOT]);
|
|
|
|
createTree($tree, [ROOT]);
|
|
|
|
if (!isWorkgroup()) {
|
|
|
|
if (!isWorkgroup()) {
|
|
|
|
createUnsorted($tree, [UNSORTED]);
|
|
|
|
createUnsorted($tree, [UNSORTED]);
|
|
|
|
createTemplate($tree, [TEMPLATE]);
|
|
|
|
createTemplate($tree, [TEMPLATE]);
|
|
|
|
createAnonFiles($tree, [ANON]);
|
|
|
|
|
|
|
|
createAllFiles($tree, [FILES_DATA]);
|
|
|
|
createAllFiles($tree, [FILES_DATA]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createTrash($tree, [TRASH]);
|
|
|
|
createTrash($tree, [TRASH]);
|
|
|
@ -1636,26 +1629,23 @@ define([
|
|
|
|
var $selected = $iframe.find('.selected');
|
|
|
|
var $selected = $iframe.find('.selected');
|
|
|
|
if (!$selected.length) { return; }
|
|
|
|
if (!$selected.length) { return; }
|
|
|
|
var paths = [];
|
|
|
|
var paths = [];
|
|
|
|
|
|
|
|
var isTrash = filesOp.isPathInTrash(currentPath);
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
if (!$(elmt).data('path')) { return; }
|
|
|
|
if (!$(elmt).data('path')) { return; }
|
|
|
|
paths.push($(elmt).data('path'));
|
|
|
|
paths.push($(elmt).data('path'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// If we are in the trash or if we are holding the "shift" key, delete permanently,
|
|
|
|
// If we are in the trash or anon pad or if we are holding the "shift" key, delete permanently,
|
|
|
|
// else move to trash
|
|
|
|
if (isTrash || e.shiftKey) {
|
|
|
|
if (filesOp.isPathInTrash(currentPath) || e.shiftKey) {
|
|
|
|
var cb = filesOp.removeFromTrash; // We're in the trash
|
|
|
|
var cb = filesOp.removeFromTrash;
|
|
|
|
if (!isTrash) {
|
|
|
|
if (!filesOp.isPathInTrash(currentPath)) {
|
|
|
|
cb = filesOp.deletePathPermanently; // We're in root/unsorted/template
|
|
|
|
// If we are not in the trash, we just have to remove the key from root/unsorted
|
|
|
|
|
|
|
|
cb = filesOp.deletePathPermanently;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If we are already in the trash, delete the elements permanently
|
|
|
|
|
|
|
|
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
|
|
|
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
|
|
|
if (paths.length === 1) { // If we delete only one element, display its name in the popup
|
|
|
|
if (paths.length === 1) {
|
|
|
|
var path = paths[0];
|
|
|
|
msg = Messages.fm_removePermanentlyDialog;
|
|
|
|
var element = filesOp.findElement(files, path);
|
|
|
|
|
|
|
|
var name = filesOp.isInTrashRoot(path) ? path[1] : (filesOp.isPathInHrefArray(path) ? filesOp.getTitle(element) : path[path.length - 1]);
|
|
|
|
|
|
|
|
msg = Messages._getKey("fm_removePermanentlyDialog", [name]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.confirm(msg, function(res) {
|
|
|
|
Cryptpad.confirm(msg, function(res) {
|
|
|
|
if (!res) { return; }
|
|
|
|
if (!res) { return; }
|
|
|
|
paths.forEach(function(p) {
|
|
|
|
paths.forEach(function(p) {
|
|
|
@ -1665,6 +1655,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// else move to trash
|
|
|
|
moveElements(paths, [TRASH], false, refresh);
|
|
|
|
moveElements(paths, [TRASH], false, refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|