Merge pull request #418 from xwiki-labs/cryptDriveStuff

Crypt drive stuff
pull/1/head
ansuz 5 years ago committed by GitHub
commit 592df7e152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -230,9 +230,15 @@ define([
if (!Visible.currently()) { to = window.setTimeout(interval, Thumb.UPDATE_FIRST); } if (!Visible.currently()) { to = window.setTimeout(interval, Thumb.UPDATE_FIRST); }
}; };
var addThumbnail = function (err, thumb, $span, cb) { var addThumbnail = function (err, thumb, $span, cb) {
var u8 = Nacl.util.decodeBase64(thumb.split(',')[1]);
var blob = new Blob([u8], {
type: 'image/png'
});
var url = URL.createObjectURL(blob);
var img = new Image(); var img = new Image();
img.src = thumb.slice(0,5) === 'data:' ? thumb : 'data:image/png;base64,'+thumb; img.src = url;
$span.find('.cp-icon').hide(); $span.find('.cp-icon').hide();
$span.prepend(img); $span.prepend(img);
cb($(img)); cb($(img));

@ -30,6 +30,7 @@
@drive_content-bg-ro: darken(@drive_content-bg, 10%); @drive_content-bg-ro: darken(@drive_content-bg, 10%);
@drive_selected-bg: #888; @drive_selected-bg: #888;
@drive_droppable-bg: #FE9A2E;
/* PAGE */ /* PAGE */
@ -157,7 +158,7 @@
} }
.cp-app-drive-element-droppable { .cp-app-drive-element-droppable {
background-color: #FE9A2E; background-color: @drive_droppable-bg;
color: #222; color: #222;
} }
@ -939,6 +940,7 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
transition: all 0.15s; transition: all 0.15s;
cursor: pointer;
&:first-child { &:first-child {
flex-shrink: 1; flex-shrink: 1;
@ -946,17 +948,20 @@
&.cp-app-drive-path-separator { &.cp-app-drive-path-separator {
color: #ccc; color: #ccc;
cursor: default;
} }
&.cp-app-drive-path-collapse { &.cp-app-drive-path-collapse {
position: relative; position: relative;
} }
&:hover { &.cp-app-drive-element-droppable {
background-color: @drive_droppable-bg;
}
&:not(.cp-app-drive-element-droppable):hover {
&:not(.cp-app-drive-path-separator) { &:not(.cp-app-drive-path-separator) {
background-color: darken(@colortheme_drive-bg, 15%); background-color: darken(@colortheme_drive-bg, 15%);
text-decoration: underline; text-decoration: underline;
cursor: pointer;
} }
& ~ .cp-app-drive-path-element { & ~ .cp-app-drive-path-element {
background-color: darken(@colortheme_drive-bg, 15%); background-color: darken(@colortheme_drive-bg, 15%);

@ -41,7 +41,10 @@ define([
{ {
var APP = window.APP = { var APP = window.APP = {
editable: false, editable: false,
mobile: function () { return $('body').width() <= 600; }, // Menu and content area are not inline-block anymore for mobiles mobile: function () {
if (window.matchMedia) { return !window.matchMedia('(any-pointer:fine)').matches; }
else { return $('body').width() <= 600; }
},
isMac: navigator.platform === "MacIntel", isMac: navigator.platform === "MacIntel",
}; };
@ -297,6 +300,33 @@ define([
}); });
}; };
APP.selectedFiles = [];
var isElementSelected = function ($element) {
var elementId = $element.data("path").slice(-1)[0];
return APP.selectedFiles.indexOf(elementId) !== -1;
};
var selectElement = function ($element) {
var elementId = $element.data("path").slice(-1)[0];
if (APP.selectedFiles.indexOf(elementId) === -1) {
APP.selectedFiles.push(elementId);
}
$element.addClass("cp-app-drive-element-selected");
};
var unselectElement = function ($element) {
var elementId = $element.data("path").slice(-1)[0];
var index = APP.selectedFiles.indexOf(elementId);
if (index !== -1) {
APP.selectedFiles.splice(index, 1);
}
$element.removeClass("cp-app-drive-element-selected");
};
var findSelectedElements = function () {
return $(".cp-app-drive-element-selected");
};
var createContextMenu = function () { var createContextMenu = function () {
var menu = h('div.cp-contextmenu.dropdown.cp-unselectable', [ var menu = h('div.cp-contextmenu.dropdown.cp-unselectable', [
h('ul.dropdown-menu', { h('ul.dropdown-menu', {
@ -563,7 +593,8 @@ define([
var sel = {}; var sel = {};
var removeSelected = function (keepObj) { var removeSelected = function (keepObj) {
$('.cp-app-drive-element-selected').removeClass("cp-app-drive-element-selected"); APP.selectedFiles = [];
findSelectedElements().removeClass("cp-app-drive-element-selected");
var $container = $driveToolbar.find('#cp-app-drive-toolbar-contextbuttons'); var $container = $driveToolbar.find('#cp-app-drive-toolbar-contextbuttons');
if (!$container.length) { return; } if (!$container.length) { return; }
$container.html(''); $container.html('');
@ -673,7 +704,9 @@ define([
delete sel.move; delete sel.move;
$content.find('.cp-app-drive-element-selected-tmp') $content.find('.cp-app-drive-element-selected-tmp')
.removeClass('cp-app-drive-element-selected-tmp') .removeClass('cp-app-drive-element-selected-tmp')
.addClass('cp-app-drive-element-selected'); .each(function (idx, element) {
selectElement($(element));
});
e.stopPropagation(); e.stopPropagation();
}); });
@ -708,7 +741,9 @@ define([
// Ctrl+A select all // Ctrl+A select all
if (e.which === 65 && (e.ctrlKey || (e.metaKey && APP.isMac))) { if (e.which === 65 && (e.ctrlKey || (e.metaKey && APP.isMac))) {
$content.find('.cp-app-drive-element:not(.cp-app-drive-element-selected)') $content.find('.cp-app-drive-element:not(.cp-app-drive-element-selected)')
.addClass('cp-app-drive-element-selected'); .each(function (idx, element) {
selectElement($(element));
});
return; return;
} }
@ -721,7 +756,7 @@ define([
APP.onElementClick(ev, $(el)); APP.onElementClick(ev, $(el));
}; };
var $selection = $content.find('.cp-app-drive-element.cp-app-drive-element-selected'); var $selection = findSelectedElements();
if ($selection.length === 0) { return void click($elements.first()[0]); } if ($selection.length === 0) { return void click($elements.first()[0]); }
var lastIndex = typeof sel.endSelected === "number" ? sel.endSelected : var lastIndex = typeof sel.endSelected === "number" ? sel.endSelected :
@ -840,12 +875,12 @@ define([
return; return;
} }
removeInput(); removeInput();
removeSelected();
var $name = $element.find('.cp-app-drive-element-name'); var $name = $element.find('.cp-app-drive-element-name');
if (!$name.length) { if (!$name.length) {
$name = $element.find('> .cp-app-drive-element'); $name = $element.find('> .cp-app-drive-element');
} }
$name.hide(); $name.hide();
var isFolder = $element.is(".cp-app-drive-element-folder:not(.cp-app-drive-element-sharedf)");
var el = manager.find(path); var el = manager.find(path);
var name = manager.isFile(el) ? manager.getTitle(el) : path[path.length - 1]; var name = manager.isFile(el) ? manager.getTitle(el) : path[path.length - 1];
if (manager.isSharedFolder(el)) { if (manager.isSharedFolder(el)) {
@ -867,14 +902,21 @@ define([
var newName = $input.val(); var newName = $input.val();
if (JSON.stringify(path) === JSON.stringify(currentPath)) { if (JSON.stringify(path) === JSON.stringify(currentPath)) {
manager.rename(path, $input.val(), function () { manager.rename(path, $input.val(), function () {
renameFoldersOpened(path, newName); if (isFolder) {
path[path.length - 1] = newName; renameFoldersOpened(path, newName);
path[path.length - 1] = newName;
}
APP.displayDirectory(path); APP.displayDirectory(path);
}); });
} }
else { else {
manager.rename(path, $input.val(), function () { manager.rename(path, $input.val(), function () {
renameFoldersOpened(path, newName); if (isFolder) {
renameFoldersOpened(path, newName);
unselectElement($element);
$element.data("path", $element.data("path").slice(0, -1).concat(newName));
selectElement($element);
}
refresh(); refresh();
}); });
} }
@ -895,7 +937,6 @@ define([
// We don't want to open the file/folder when clicking on the input // We don't want to open the file/folder when clicking on the input
$input.on('click dblclick', function (e) { $input.on('click dblclick', function (e) {
removeSelected();
e.stopPropagation(); e.stopPropagation();
}); });
// Remove the browser ability to drag text from the input to avoid // Remove the browser ability to drag text from the input to avoid
@ -1115,8 +1156,9 @@ define([
var getSelectedPaths = function ($element) { var getSelectedPaths = function ($element) {
var paths = []; var paths = [];
if ($('.cp-app-drive-element-selected').length > 1) { if (!$element || $element.length === 0) { return paths; }
var $selected = $('.cp-app-drive-element-selected'); if (findSelectedElements().length > 1) {
var $selected = findSelectedElements();
$selected.each(function (idx, elmt) { $selected.each(function (idx, elmt) {
var ePath = $(elmt).data('path'); var ePath = $(elmt).data('path');
if (ePath) { if (ePath) {
@ -1145,7 +1187,7 @@ define([
} else { } else {
$driveToolbar.find('cp-app-drive-toolbar-emptytrash').hide(); $driveToolbar.find('cp-app-drive-toolbar-emptytrash').hide();
} }
var $li = $content.find('.cp-app-drive-element-selected'); var $li = findSelectedElements();
if ($li.length === 0) { if ($li.length === 0) {
$li = findDataHolder($tree.find('.cp-app-drive-element-active')); $li = findDataHolder($tree.find('.cp-app-drive-element-active'));
} }
@ -1212,6 +1254,7 @@ define([
if (pos+eh <= h && pos >= 0) { return; } if (pos+eh <= h && pos >= 0) { return; }
$content.scrollTop(v); $content.scrollTop(v);
}; };
// Add the "selected" class to the "li" corresponding to the clicked element // Add the "selected" class to the "li" corresponding to the clicked element
var onElementClick = APP.onElementClick = function (e, $element) { var onElementClick = APP.onElementClick = function (e, $element) {
// If "Ctrl" is pressed, do not remove the current selection // If "Ctrl" is pressed, do not remove the current selection
@ -1248,23 +1291,23 @@ define([
var $el; var $el;
removeSelected(true); removeSelected(true);
sel.oldSelection.forEach(function (el) { sel.oldSelection.forEach(function (el) {
if (!$(el).hasClass("cp-app-drive-element-selected")) { if (!isElementSelected($(el))) {
$(el).addClass("cp-app-drive-element-selected"); selectElement($(el));
} }
}); });
for (var i = Math.min(sel.startSelected, sel.endSelected); for (var i = Math.min(sel.startSelected, sel.endSelected);
i <= Math.max(sel.startSelected, sel.endSelected); i <= Math.max(sel.startSelected, sel.endSelected);
i++) { i++) {
$el = $($elements.get(i)); $el = $($elements.get(i));
if (!$el.hasClass("cp-app-drive-element-selected")) { if (!isElementSelected($el)) {
$el.addClass("cp-app-drive-element-selected"); selectElement($el);
} }
} }
} else { } else {
if (!$element.hasClass("cp-app-drive-element-selected")) { if (!isElementSelected($element)) {
$element.addClass("cp-app-drive-element-selected"); selectElement($element);
} else { } else {
$element.removeClass("cp-app-drive-element-selected"); unselectElement($element);
} }
} }
updateContextButton(); updateContextButton();
@ -1298,7 +1341,14 @@ define([
}); });
}); });
$menu.css({ display: "block" }); $menu.css({ display: "block" });
if (APP.mobile()) { return; } if (APP.mobile()) {
$menu.css({
top: ($("#cp-app-drive-toolbar-context-mobile").offset().top + 32) + 'px',
right: '0px',
left: ''
});
return;
}
var h = $menu.outerHeight(); var h = $menu.outerHeight();
var w = $menu.outerWidth(); var w = $menu.outerWidth();
var wH = window.innerHeight; var wH = window.innerHeight;
@ -1351,6 +1401,17 @@ define([
} else { } else {
var $element = findDataHolder($(e.target)); var $element = findDataHolder($(e.target));
// if clicked from tree
var fromTree = $element.closest("#cp-app-drive-tree").length;
if (fromTree) {
removeSelected();
}
// if clicked on non selected element
if (!isElementSelected($element)) {
removeSelected();
}
if (type === 'trash' && !$element.data('path')) { return; } if (type === 'trash' && !$element.data('path')) { return; }
if (!$element.length) { if (!$element.length) {
@ -1359,8 +1420,8 @@ define([
return false; return false;
} }
if (!$element.hasClass('cp-app-drive-element-selected')) { if (!isElementSelected($element)) {
onElementClick(undefined, $element); selectElement($element);
} }
paths = getSelectedPaths($element); paths = getSelectedPaths($element);
@ -1430,6 +1491,7 @@ define([
if (!res) { return; } if (!res) { return; }
manager.delete(pathsList, function () { manager.delete(pathsList, function () {
pathsList.forEach(removeFoldersOpened); pathsList.forEach(removeFoldersOpened);
removeSelected();
refresh(); refresh();
}); });
}, null, true); }, null, true);
@ -1440,7 +1502,7 @@ define([
var paths = []; var paths = [];
var $element = findDataHolder($(ev.target)); var $element = findDataHolder($(ev.target));
if ($element.hasClass('cp-app-drive-element-selected')) { if ($element.hasClass('cp-app-drive-element-selected')) {
var $selected = $('.cp-app-drive-element-selected'); var $selected = findSelectedElements();
$selected.each(function (idx, elmt) { $selected.each(function (idx, elmt) {
var ePath = $(elmt).data('path'); var ePath = $(elmt).data('path');
if (ePath) { if (ePath) {
@ -1457,7 +1519,7 @@ define([
}); });
} else { } else {
removeSelected(); removeSelected();
$element.addClass('cp-app-drive-element-selected'); selectElement($element);
var val = manager.find(path); var val = manager.find(path);
if (!val) { return; } // The element is not in the object if (!val) { return; } // The element is not in the object
paths = [{ paths = [{
@ -1476,7 +1538,13 @@ define([
var findDropPath = function (target) { var findDropPath = function (target) {
var $target = $(target); var $target = $(target);
var $el = findDataHolder($target); var $el;
if ($target.is(".cp-app-drive-path-element")) {
$el = $target;
}
else {
$el = findDataHolder($target);
}
var newPath = $el.data('path'); var newPath = $el.data('path');
var dropEl = newPath && manager.find(newPath); var dropEl = newPath && manager.find(newPath);
if (newPath && manager.isSharedFolder(dropEl)) { if (newPath && manager.isSharedFolder(dropEl)) {
@ -1604,7 +1672,8 @@ define([
$owner.attr('title', Messages.fm_padIsOwnedOther); $owner.attr('title', Messages.fm_padIsOwnedOther);
} }
}; };
var addFileData = function (element, $span) { var thumbsUrls = {};
var addFileData = function (element, $element) {
if (!manager.isFile(element)) { return; } if (!manager.isFile(element)) { return; }
var data = manager.getFileData(element); var data = manager.getFileData(element);
@ -1613,7 +1682,7 @@ define([
var hrefData = Hash.parsePadUrl(href); var hrefData = Hash.parsePadUrl(href);
if (hrefData.type) { if (hrefData.type) {
$span.addClass('cp-border-color-'+hrefData.type); $element.addClass('cp-border-color-'+hrefData.type);
} }
var $state = $('<span>', {'class': 'cp-app-drive-element-state'}); var $state = $('<span>', {'class': 'cp-app-drive-element-state'});
@ -1633,25 +1702,38 @@ define([
var $expire = $expirableIcon.clone().appendTo($state); var $expire = $expirableIcon.clone().appendTo($state);
$expire.attr('title', Messages._getKey('fm_expirablePad', [new Date(data.expire).toLocaleString()])); $expire.attr('title', Messages._getKey('fm_expirablePad', [new Date(data.expire).toLocaleString()]));
} }
_addOwnership($span, $state, data); _addOwnership($element, $state, data);
var name = manager.getTitle(element); var name = manager.getTitle(element);
// The element with the class '.name' is underlined when the 'li' is hovered // The element with the class '.name' is underlined when the 'li' is hovered
var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name); var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name);
$span.append($name); $element.append($name);
$span.append($state); $element.append($state);
$span.attr('title', name); $element.attr('title', name);
// display the thumbnail
// if the thumbnail has already been displayed once, do not reload it, keep the same url
if (thumbsUrls[element]) {
var img = new Image();
img.src = thumbsUrls[element];
$element.find('.cp-icon').addClass('cp-app-drive-element-list');
$element.prepend(img);
$(img).addClass('cp-app-drive-element-grid cp-app-drive-element-thumbnail');
$(img).attr("draggable", false);
}
else {
common.displayThumbnail(href || data.roHref, data.channel, data.password, $element, function ($thumb) {
// Called only if the thumbnail exists
// Remove the .hide() added by displayThumnail() because it hides the icon in list mode too
$element.find('.cp-icon').removeAttr('style').addClass('cp-app-drive-element-list');
$thumb.addClass('cp-app-drive-element-grid cp-app-drive-element-thumbnail');
$thumb.attr("draggable", false);
thumbsUrls[element] = $thumb[0].src;
});
}
var type = Messages.type[hrefData.type] || hrefData.type; var type = Messages.type[hrefData.type] || hrefData.type;
common.displayThumbnail(href || data.roHref, data.channel, data.password, $span, function ($thumb) {
// Called only if the thumbnail exists
// Remove the .hide() added by displayThumnail() because it hides the icon in
// list mode too
$span.find('.cp-icon').removeAttr('style').addClass('cp-app-drive-element-list');
$thumb.addClass('cp-app-drive-element-grid')
.addClass('cp-app-drive-element-thumbnail');
});
var $type = $('<span>', { var $type = $('<span>', {
'class': 'cp-app-drive-element-type cp-app-drive-element-list' 'class': 'cp-app-drive-element-type cp-app-drive-element-list'
}).text(type); }).text(type);
@ -1661,7 +1743,7 @@ define([
var $cdate = $('<span>', { var $cdate = $('<span>', {
'class': 'cp-app-drive-element-ctime cp-app-drive-element-list' 'class': 'cp-app-drive-element-ctime cp-app-drive-element-list'
}).text(getDate(data.ctime)); }).text(getDate(data.ctime));
$span.append($type).append($adate).append($cdate); $element.append($type).append($adate).append($cdate);
}; };
var addFolderData = function (element, key, $span) { var addFolderData = function (element, key, $span) {
@ -1737,12 +1819,9 @@ define([
draggable: true, draggable: true,
'class': 'cp-app-drive-element-row' 'class': 'cp-app-drive-element-row'
}); });
if (!isFolder && Array.isArray(APP.selectedFiles)) { $element.data('path', newPath);
var idx = APP.selectedFiles.indexOf(element); if (isElementSelected($element)) {
if (idx !== -1) { selectElement($element);
$element.addClass('cp-app-drive-element-selected');
APP.selectedFiles.splice(idx, 1);
}
} }
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
if (isFolder) { if (isFolder) {
@ -1758,11 +1837,10 @@ define([
addFileData(element, $element); addFileData(element, $element);
} }
$element.addClass(liClass); $element.addClass(liClass);
$element.data('path', newPath);
addDragAndDropHandlers($element, newPath, isFolder, !isTrash); addDragAndDropHandlers($element, newPath, isFolder, !isTrash);
$element.click(function(e) { $element.click(function(e) {
e.stopPropagation(); e.stopPropagation();
onElementClick(e, $element, newPath); onElementClick(e, $element);
}); });
if (!isTrash) { if (!isTrash) {
$element.contextmenu(openContextMenu('tree')); $element.contextmenu(openContextMenu('tree'));
@ -1913,6 +1991,8 @@ define([
} else if (idx > 0 && manager.isFile(el)) { } else if (idx > 0 && manager.isFile(el)) {
name = getElementName(path); name = getElementName(path);
} }
$span.data("path", path.slice(0, idx + 1));
addDragAndDropHandlers($span, path.slice(0, idx), true, true);
if (idx === 0) { name = p === SHARED_FOLDER ? name : getPrettyName(p); } if (idx === 0) { name = p === SHARED_FOLDER ? name : getPrettyName(p); }
else { else {
@ -2557,22 +2637,19 @@ define([
'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass, 'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass,
draggable: draggable draggable: draggable
}); });
if (Array.isArray(APP.selectedFiles)) {
var sidx = APP.selectedFiles.indexOf(id); var path = [rootName, idx];
if (sidx !== -1) { $element.data('path', path);
$element.addClass('cp-app-drive-element-selected'); if (isElementSelected($element)) {
APP.selectedFiles.splice(sidx, 1); selectElement($element);
}
} }
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
openFile(id); openFile(id);
}); });
addFileData(id, $element); addFileData(id, $element);
var path = [rootName, idx];
$element.data('path', path);
$element.click(function(e) { $element.click(function(e) {
e.stopPropagation(); e.stopPropagation();
onElementClick(e, $element, path); onElementClick(e, $element);
}); });
$element.contextmenu(openContextMenu('default')); $element.contextmenu(openContextMenu('default'));
$element.data('context', 'default'); $element.data('context', 'default');
@ -2699,8 +2776,8 @@ define([
e.preventDefault(); e.preventDefault();
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; } if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
else { parentPath.pop(); } else { parentPath.pop(); }
APP.selectedFiles = [r.id];
APP.displayDirectory(parentPath); APP.displayDirectory(parentPath);
APP.selectedFiles = path.slice(-1);
}).appendTo($openDir); }).appendTo($openDir);
} }
$('<a>').text(Messages.fc_prop).click(function () { $('<a>').text(Messages.fc_prop).click(function () {
@ -2791,7 +2868,7 @@ define([
$element.data('path', path); $element.data('path', path);
$element.click(function(e) { $element.click(function(e) {
e.stopPropagation(); e.stopPropagation();
onElementClick(e, $element, path); onElementClick(e, $element);
}); });
$element.contextmenu(openContextMenu('default')); $element.contextmenu(openContextMenu('default'));
$element.data('context', 'default'); $element.data('context', 'default');
@ -3015,7 +3092,7 @@ define([
$context.click(function (e) { $context.click(function (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var $li = $content.find('.cp-app-drive-element-selected'); var $li = findSelectedElements();
if ($li.length !== 1) { if ($li.length !== 1) {
$li = findDataHolder($tree.find('.cp-app-drive-element-active')); $li = findDataHolder($tree.find('.cp-app-drive-element-active'));
} }
@ -3025,11 +3102,6 @@ define([
return; return;
} }
// Open the menu // Open the menu
$('.cp-contextmenu').css({
top: ($context.offset().top + 32) + 'px',
right: '0px',
left: ''
});
$li.contextmenu(); $li.contextmenu();
}); });
} else { } else {
@ -3097,7 +3169,7 @@ define([
} }
});*/ });*/
var $sel = $content.find('.cp-app-drive-element-selected'); var $sel = findSelectedElements();
if ($sel.length) { if ($sel.length) {
$sel[0].scrollIntoView(); $sel[0].scrollIntoView();
} else { } else {
@ -3109,6 +3181,9 @@ define([
if (history.isHistoryMode) { if (history.isHistoryMode) {
return void _displayDirectory(path, force); return void _displayDirectory(path, force);
} }
if (!manager.comparePath(currentPath, path)) {
removeSelected();
}
updateObject(sframeChan, proxy, function () { updateObject(sframeChan, proxy, function () {
copyObjectValue(files, proxy.drive); copyObjectValue(files, proxy.drive);
updateSharedFolders(sframeChan, manager, files, folders, function () { updateSharedFolders(sframeChan, manager, files, folders, function () {
@ -3459,6 +3534,7 @@ define([
if (!res) { return; } if (!res) { return; }
manager.delete(pathsList, function () { manager.delete(pathsList, function () {
pathsList.forEach(removeFoldersOpened); pathsList.forEach(removeFoldersOpened);
removeSelected();
refresh(); refresh();
}); });
}); });
@ -3705,16 +3781,15 @@ define([
var parentPath = paths[0].path.slice(); var parentPath = paths[0].path.slice();
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; } if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
else { parentPath.pop(); } else { parentPath.pop(); }
el = manager.find(paths[0].path);
APP.selectedFiles = [el];
APP.displayDirectory(parentPath); APP.displayDirectory(parentPath);
APP.selectedFiles = paths[0].path.slice(-1);
} }
APP.hideMenu(); APP.hideMenu();
}); });
$content.on("keydown", function (e) { $(window).on("keydown", function (e) {
if (e.which === 113) { if (e.which === 113) { // if F2 key pressed
var paths = $contextMenu.data('paths'); var paths = getSelectedPaths(findSelectedElements().first());
if (paths.length !== 1) { return; } if (paths.length !== 1) { return; }
displayRenameInput(paths[0].element, paths[0].path); displayRenameInput(paths[0].element, paths[0].path);
} }
@ -3726,10 +3801,8 @@ define([
e.preventDefault(); e.preventDefault();
}); });
$appContainer.on('mouseup', function (e) { $appContainer.on('mouseup', function (e) {
//if (sel.down) { return; }
if (e.which !== 1) { return ; } if (e.which !== 1) { return ; }
APP.hideMenu(e); APP.hideMenu(e);
//removeSelected(e);
}); });
$appContainer.on('click', function (e) { $appContainer.on('click', function (e) {
if (e.which !== 1) { return ; } if (e.which !== 1) { return ; }
@ -3748,7 +3821,7 @@ define([
if (manager.isPathIn(currentPath, [FILES_DATA]) && APP.loggedIn) { if (manager.isPathIn(currentPath, [FILES_DATA]) && APP.loggedIn) {
return; // We can't remove elements directly from filesData return; // We can't remove elements directly from filesData
} }
var $selected = $('.cp-app-drive-element-selected'); var $selected = findSelectedElements();
if (!$selected.length) { return; } if (!$selected.length) { return; }
var paths = []; var paths = [];
var isTrash = manager.isPathIn(currentPath, [TRASH]); var isTrash = manager.isPathIn(currentPath, [TRASH]);

Loading…
Cancel
Save