|
|
@ -353,10 +353,14 @@ define([
|
|
|
|
},0);
|
|
|
|
},0);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var filterContextMenu = function ($menu, $element) {
|
|
|
|
var filterContextMenu = function ($menu, paths) {
|
|
|
|
var path = $element.data('path');
|
|
|
|
//var path = $element.data('path');
|
|
|
|
|
|
|
|
|
|
|
|
var hide = [];
|
|
|
|
var hide = [];
|
|
|
|
|
|
|
|
var hasFolder = false;
|
|
|
|
|
|
|
|
paths.forEach(function (p, i) {
|
|
|
|
|
|
|
|
var path = p.path;
|
|
|
|
|
|
|
|
var $element = p.element;
|
|
|
|
if (!APP.editable) {
|
|
|
|
if (!APP.editable) {
|
|
|
|
hide.push($menu.find('a.editable'));
|
|
|
|
hide.push($menu.find('a.editable'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -364,14 +368,30 @@ define([
|
|
|
|
hide.push($menu.find('a.own'));
|
|
|
|
hide.push($menu.find('a.own'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($element.is('.file-element')) {
|
|
|
|
if ($element.is('.file-element')) {
|
|
|
|
|
|
|
|
// No folder in files
|
|
|
|
hide.push($menu.find('a.newfolder'));
|
|
|
|
hide.push($menu.find('a.newfolder'));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (hasFolder) {
|
|
|
|
|
|
|
|
// More than 1 folder selected: cannot create a new subfolder
|
|
|
|
|
|
|
|
hide.push($menu.find('a.newfolder'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hasFolder = true;
|
|
|
|
hide.push($menu.find('a.open_ro'));
|
|
|
|
hide.push($menu.find('a.open_ro'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (path && path.length > 4) {
|
|
|
|
if (path && path.length > 4) {
|
|
|
|
hide.push($menu.find('a.restore'));
|
|
|
|
hide.push($menu.find('a.restore'));
|
|
|
|
hide.push($menu.find('a.properties'));
|
|
|
|
hide.push($menu.find('a.properties'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (paths.length > 1) {
|
|
|
|
|
|
|
|
hide.push($menu.find('a.restore'));
|
|
|
|
|
|
|
|
hide.push($menu.find('a.properties'));
|
|
|
|
|
|
|
|
hide.push($menu.find('a.rename'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasFolder && paths.length > 1) {
|
|
|
|
|
|
|
|
// Cannot open multiple folders
|
|
|
|
|
|
|
|
hide.push($menu.find('a.open'));
|
|
|
|
|
|
|
|
}
|
|
|
|
return hide;
|
|
|
|
return hide;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -384,9 +404,35 @@ define([
|
|
|
|
$driveToolbar.find('.path').css('max-width', 'calc(100vw - '+$tree.width()+'px - '+l+'px)');
|
|
|
|
$driveToolbar.find('.path').css('max-width', 'calc(100vw - '+$tree.width()+'px - '+l+'px)');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getSelectedPaths = function ($element) {
|
|
|
|
|
|
|
|
var paths = [];
|
|
|
|
|
|
|
|
if ($iframe.find('.selected').length > 1) {
|
|
|
|
|
|
|
|
var $selected = $iframe.find('.selected');
|
|
|
|
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
|
|
|
|
var ePath = $(elmt).data('path');
|
|
|
|
|
|
|
|
if (ePath) {
|
|
|
|
|
|
|
|
paths.push({
|
|
|
|
|
|
|
|
path: ePath,
|
|
|
|
|
|
|
|
element: $(elmt)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!paths.length) {
|
|
|
|
|
|
|
|
var path = $element.data('path');
|
|
|
|
|
|
|
|
if (!path) { return false; }
|
|
|
|
|
|
|
|
paths.push({
|
|
|
|
|
|
|
|
path: path,
|
|
|
|
|
|
|
|
element: $element
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return paths;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateContextButton = function () {
|
|
|
|
var updateContextButton = function () {
|
|
|
|
var $li = $content.find('.selected');
|
|
|
|
var $li = $content.find('.selected');
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
if ($li.length === 0) {
|
|
|
|
$li = findDataHolder($tree.find('.element.active'));
|
|
|
|
$li = findDataHolder($tree.find('.element.active'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var $button = $driveToolbar.find('#contextButton');
|
|
|
|
var $button = $driveToolbar.find('#contextButton');
|
|
|
@ -412,13 +458,13 @@ define([
|
|
|
|
var $container = $driveToolbar.find('#contextButtonsContainer');
|
|
|
|
var $container = $driveToolbar.find('#contextButtonsContainer');
|
|
|
|
if (!$container.length) { return; }
|
|
|
|
if (!$container.length) { return; }
|
|
|
|
$container.html('');
|
|
|
|
$container.html('');
|
|
|
|
var $element = $li;
|
|
|
|
var $element = $li.length === 1 ? $li : $($li[0]);
|
|
|
|
|
|
|
|
var paths = getSelectedPaths($element);
|
|
|
|
var $menu = $element.data('context');
|
|
|
|
var $menu = $element.data('context');
|
|
|
|
var path = $element.data('path');
|
|
|
|
if (!$menu) { return; }
|
|
|
|
if (!$menu || !path) { return; }
|
|
|
|
|
|
|
|
var actions = [];
|
|
|
|
var actions = [];
|
|
|
|
var $actions = $menu.find('a');
|
|
|
|
var $actions = $menu.find('a');
|
|
|
|
var toHide = filterContextMenu($menu, $element);
|
|
|
|
var toHide = filterContextMenu($menu, paths);
|
|
|
|
$actions = $actions.filter(function (i, el) {
|
|
|
|
$actions = $actions.filter(function (i, el) {
|
|
|
|
for (var j = 0; j < toHide.length; j++) {
|
|
|
|
for (var j = 0; j < toHide.length; j++) {
|
|
|
|
if ($(el).is(toHide[j])) { return false; }
|
|
|
|
if ($(el).is(toHide[j])) { return false; }
|
|
|
@ -433,8 +479,9 @@ define([
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$a.text($(el).text());
|
|
|
|
$a.text($(el).text());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(el).data('path', path);
|
|
|
|
$(el).data('paths', paths);
|
|
|
|
$(el).data('element', $element);
|
|
|
|
//$(el).data('path', path);
|
|
|
|
|
|
|
|
//:$(el).data('element', $element);
|
|
|
|
$container.append($a);
|
|
|
|
$container.append($a);
|
|
|
|
$a.click(function() { $(el).click(); });
|
|
|
|
$a.click(function() { $(el).click(); });
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -460,6 +507,9 @@ define([
|
|
|
|
$element.removeClass("selected");
|
|
|
|
$element.removeClass("selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateContextButton();
|
|
|
|
updateContextButton();
|
|
|
|
|
|
|
|
if ($iframe.find('.selected').length > 1) {
|
|
|
|
|
|
|
|
module.hideMenu();
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Open the selected context menu on the closest "li" element
|
|
|
|
// Open the selected context menu on the closest "li" element
|
|
|
@ -475,10 +525,9 @@ define([
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var path = $element.data('path');
|
|
|
|
var paths = getSelectedPaths($element);
|
|
|
|
if (!path) { return false; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var toHide = filterContextMenu($menu, $element);
|
|
|
|
var toHide = filterContextMenu($menu, paths);
|
|
|
|
toHide.forEach(function ($a) {
|
|
|
|
toHide.forEach(function ($a) {
|
|
|
|
$a.parent('li').hide();
|
|
|
|
$a.parent('li').hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -495,10 +544,13 @@ define([
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (paths.length === 1) {
|
|
|
|
onElementClick(undefined, $element);
|
|
|
|
onElementClick(undefined, $element);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$menu.find('a').data('path', path);
|
|
|
|
$menu.find('a').data('paths', paths);
|
|
|
|
$menu.find('a').data('element', $element);
|
|
|
|
//$menu.find('a').data('path', path);
|
|
|
|
|
|
|
|
//$menu.find('a').data('element', $element);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -515,6 +567,7 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var openTrashTreeContextMenu = function (e) {
|
|
|
|
var openTrashTreeContextMenu = function (e) {
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
$trashTreeContextMenu.find('li').show();
|
|
|
|
$trashTreeContextMenu.find('li').show();
|
|
|
|
openContextMenu(e, $trashTreeContextMenu);
|
|
|
|
openContextMenu(e, $trashTreeContextMenu);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1690,62 +1743,76 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
$contextMenu.on("click", "a", function(e) {
|
|
|
|
$contextMenu.on("click", "a", function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
var path = $(this).data('path');
|
|
|
|
var paths = $(this).data('paths');
|
|
|
|
var $element = $(this).data('element');
|
|
|
|
//var path = $(this).data('path');
|
|
|
|
if (!$element || !path || path.length < 2) {
|
|
|
|
//var $element = $(this).data('element');
|
|
|
|
|
|
|
|
if (paths.length === 0) {
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
debug("Directory context menu on a forbidden or unexisting element. ", $element, path);
|
|
|
|
debug("Directory context menu on a forbidden or unexisting element. ", paths);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($(this).hasClass("rename")) {
|
|
|
|
if ($(this).hasClass("rename")) {
|
|
|
|
displayRenameInput($element, path);
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
|
|
|
|
displayRenameInput(paths[0].element, paths[0].path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if($(this).hasClass("delete")) {
|
|
|
|
else if($(this).hasClass("delete")) {
|
|
|
|
moveElements([path], [TRASH], false, refresh);
|
|
|
|
var pathsList = [];
|
|
|
|
|
|
|
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
|
|
|
|
|
|
|
moveElements(pathsList, [TRASH], false, refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('open')) {
|
|
|
|
else if ($(this).hasClass('open')) {
|
|
|
|
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
|
|
|
|
var $element = p.element;
|
|
|
|
$element.click();
|
|
|
|
$element.click();
|
|
|
|
$element.dblclick();
|
|
|
|
$element.dblclick();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
var el = filesOp.findElement(files, path);
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
|
|
|
|
var el = filesOp.findElement(files, p.path);
|
|
|
|
if (filesOp.isFolder(el)) { return; }
|
|
|
|
if (filesOp.isFolder(el)) { return; }
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
openFile(roUrl);
|
|
|
|
openFile(roUrl, false);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('newfolder')) {
|
|
|
|
else if ($(this).hasClass('newfolder')) {
|
|
|
|
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var onCreated = function (info) {
|
|
|
|
var onCreated = function (info) {
|
|
|
|
module.newFolder = info.newPath;
|
|
|
|
module.newFolder = info.newPath;
|
|
|
|
module.displayDirectory(path);
|
|
|
|
module.displayDirectory(path);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
filesOp.createNewFolder(path, null, onCreated);
|
|
|
|
filesOp.createNewFolder(paths[0].path, null, onCreated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.hideMenu();
|
|
|
|
module.hideMenu();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$defaultContextMenu.on("click", "a", function(e) {
|
|
|
|
$defaultContextMenu.on("click", "a", function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
var path = $(this).data('path');
|
|
|
|
var paths = $(this).data('paths');
|
|
|
|
var $element = $(this).data('element');
|
|
|
|
if (paths.length === 0) {
|
|
|
|
if (!$element || !path || path.length < 2) {
|
|
|
|
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
debug("Directory context menu on a forbidden or unexisting element. ", $element, path);
|
|
|
|
debug("Context menu on a forbidden or unexisting element. ", paths);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($(this).hasClass('open')) {
|
|
|
|
if ($(this).hasClass('open')) {
|
|
|
|
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
|
|
|
|
var $element = p.element;
|
|
|
|
$element.dblclick();
|
|
|
|
$element.dblclick();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
var el = filesOp.findElement(files, path);
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
if (filesOp.isPathInFilesData(path)) {
|
|
|
|
var el = filesOp.findElement(files, p.path);
|
|
|
|
el = el.href;
|
|
|
|
if (filesOp.isPathInFilesData(p.path)) { el = el.href; }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!el || filesOp.isFolder(el)) { return; }
|
|
|
|
if (!el || filesOp.isFolder(el)) { return; }
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
openFile(roUrl);
|
|
|
|
openFile(roUrl, false);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('delete')) {
|
|
|
|
else if ($(this).hasClass('delete')) {
|
|
|
|
moveElements([path], [TRASH], false, refresh);
|
|
|
|
var pathsList = [];
|
|
|
|
|
|
|
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
|
|
|
|
|
|
|
moveElements(pathsList, [TRASH], false, refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.hideMenu();
|
|
|
|
module.hideMenu();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1770,11 +1837,10 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
$trashTreeContextMenu.on('click', 'a', function (e) {
|
|
|
|
$trashTreeContextMenu.on('click', 'a', function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
var path = $(this).data('path');
|
|
|
|
var paths = $(this).data('paths');
|
|
|
|
var $element = $(this).data('element');
|
|
|
|
if (paths.length !== 1 || !paths[0].element || !filesOp.comparePath(paths[0].path, [TRASH])) {
|
|
|
|
if (!$element || !filesOp.comparePath(path, [TRASH])) {
|
|
|
|
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
debug("Trash tree context menu on a forbidden or unexisting element. ", $element, path);
|
|
|
|
debug("Trash tree context menu on a forbidden or unexisting element. ", paths);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($(this).hasClass("empty")) {
|
|
|
|
if ($(this).hasClass("empty")) {
|
|
|
@ -1788,22 +1854,34 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
$trashContextMenu.on('click', 'a', function (e) {
|
|
|
|
$trashContextMenu.on('click', 'a', function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
var path = $(this).data('path');
|
|
|
|
var paths = $(this).data('paths');
|
|
|
|
var $element = $(this).data('element');
|
|
|
|
if (paths.length === 0) {
|
|
|
|
if (!$element || !path || path.length < 2) {
|
|
|
|
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
debug("Trash context menu on a forbidden or unexisting element. ", $element, path);
|
|
|
|
debug("Trash context menu on a forbidden or unexisting element. ", paths);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var name = path[path.length - 1];
|
|
|
|
var path = paths[0].path;
|
|
|
|
|
|
|
|
var name = paths[0].path[paths[0].path.length - 1];
|
|
|
|
if ($(this).hasClass("remove")) {
|
|
|
|
if ($(this).hasClass("remove")) {
|
|
|
|
|
|
|
|
if (paths.length === 1) {
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_removePermanentlyDialog", [name]), function(res) {
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_removePermanentlyDialog", [name]), function(res) {
|
|
|
|
if (!res) { return; }
|
|
|
|
if (!res) { return; }
|
|
|
|
filesOp.removeFromTrash(path, refresh);
|
|
|
|
filesOp.removeFromTrash(path, refresh);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var pathsList = [];
|
|
|
|
|
|
|
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
|
|
|
|
|
|
|
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
|
|
|
|
|
|
|
Cryptpad.confirm(msg, function(res) {
|
|
|
|
|
|
|
|
if (!res) { return; }
|
|
|
|
|
|
|
|
filesOp.deletePathsPermanently(pathsList);
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("restore")) {
|
|
|
|
else if ($(this).hasClass("restore")) {
|
|
|
|
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
if (path.length === 4) { name = path[1]; }
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_restoreDialog", [name]), function(res) {
|
|
|
|
Cryptpad.confirm(Messages._getKey("fm_restoreDialog", [name]), function(res) {
|
|
|
|
if (!res) { return; }
|
|
|
|
if (!res) { return; }
|
|
|
@ -1811,6 +1889,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("properties")) {
|
|
|
|
else if ($(this).hasClass("properties")) {
|
|
|
|
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (path.length !== 4) { return; }
|
|
|
|
if (path.length !== 4) { return; }
|
|
|
|
var element = filesOp.getTrashElementData(path);
|
|
|
|
var element = filesOp.getTrashElementData(path);
|
|
|
|
var sPath = stringifyPath(element.path);
|
|
|
|
var sPath = stringifyPath(element.path);
|
|
|
|