Display or hide the context menu in a more intuitive way with multiselect

This commit is contained in:
yflory 2017-03-21 12:37:45 +01:00
parent 51033ab70a
commit 5f4990cc80

View file

@ -506,14 +506,19 @@ define([
var onElementClick = function (e, $element, path) {
// If "Ctrl" is pressed, do not remove the current selection
removeInput();
$element = findDataHolder($element);
// If we're selecting a new element with the left click, hide the menu
if (e) { module.hideMenu(); }
// Remove the selection if we don't hold ctrl key or if we are right-clicking
if (!e || !e.ctrlKey) {
removeSelected();
}
$element = findDataHolder($element);
if (!$element.length) {
log(Messages.fm_selectError);
return;
}
// Add the selected class to the clicked / right-clicked element
// Remove the class if it already has it (cannot happen if the user is not holding ctrl key)
if (!$element.hasClass("selected")) {
$element.addClass("selected");
lastSelectTime = now();
@ -521,9 +526,6 @@ define([
$element.removeClass("selected");
}
updateContextButton();
if ($iframe.find('.selected').length > 1) {
module.hideMenu();
}
};
// Open the selected context menu on the closest "li" element
@ -539,6 +541,10 @@ define([
return false;
}
if (!$element.hasClass('selected')) { //paths.length === 1) {
onElementClick(undefined, $element);
}
var paths = getSelectedPaths($element);
var toHide = filterContextMenu($menu, paths);
@ -558,10 +564,6 @@ define([
return true;
}
if (paths.length === 1) {
onElementClick(undefined, $element);
}
$menu.find('a').data('paths', paths);
//$menu.find('a').data('path', path);
//$menu.find('a').data('element', $element);
@ -1348,7 +1350,6 @@ define([
var idx = files[rootName].indexOf(href);
var $icon = getFileIcon(href);
var ro = filesOp.isReadOnlyFile(href);
console.log(ro);
// ro undefined mens it's an old hash which doesn't support read-only
var roClass = typeof(ro) === 'undefined' ? ' noreadonly' : ro ? ' readonly' : '';
var $element = $('<li>', {