Context submenu now respond to click event

pull/1/head
ClemDee 5 years ago
parent 5e1257e630
commit b63354532c

@ -328,7 +328,7 @@ define([
'data-icon': faColor, 'data-icon': faColor,
}, Messages.fc_color)), }, Messages.fc_color)),
h('li.dropdown-submenu', [ h('li.dropdown-submenu', [
h('a.cp-app-drive-context-test.dropdown-item', { h('a.cp-app-drive-context-test1.dropdown-item', {
'tabindex': '-1', 'tabindex': '-1',
'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
}, "TEST"), }, "TEST"),
@ -338,7 +338,7 @@ define([
'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
}, "Sub test 1")), }, "Sub test 1")),
h('li.dropdown-submenu', [ h('li.dropdown-submenu', [
h('a.cp-app-drive-context-test.dropdown-item', { h('a.cp-app-drive-context-test2.dropdown-item', {
'tabindex': '-1', 'tabindex': '-1',
'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
}, "TEST"), }, "TEST"),
@ -360,7 +360,7 @@ define([
}, "Sub test 4")), }, "Sub test 4")),
$separator.clone()[0], $separator.clone()[0],
h('li.dropdown-submenu', [ h('li.dropdown-submenu', [
h('a.cp-app-drive-context-test.dropdown-item', { h('a.cp-app-drive-context-test3.dropdown-item', {
'tabindex': '-1', 'tabindex': '-1',
'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
}, "TEST"), }, "TEST"),
@ -477,17 +477,34 @@ define([
var $el = $(el); var $el = $(el);
var $a = $el.children().filter("a"); var $a = $el.children().filter("a");
var $sub = $el.find(".dropdown-menu").first(); var $sub = $el.find(".dropdown-menu").first();
var showSubmenu = function () {
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
$sub.show();
};
var hideSubmenu = function () {
$sub.hide();
$sub.removeClass("left");
};
// Add submenu expand icon // Add submenu expand icon
$a.append(h("span.dropdown-toggle")); $a.append(h("span.dropdown-toggle"));
// Show / hide submenu // Show / hide submenu
$el.hover(function () { $el.hover(function () {
setTimeout(function () { // wait for dom to update showSubmenu();
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
$sub.show();
});
}, function () { }, function () {
$sub.hide(); hideSubmenu();
$sub.removeClass("left"); });
$el.click(function (e) {
e.stopPropagation();
if ($el.children().filter(".dropdown-menu:visible").length !== 0) {
console.log("leave", $a[0]);
$el.find(".dropdown-menu").hide();
hideSubmenu();
}
else {
console.log("enter", $a[0]);
$el.siblings().find(".dropdown-menu").hide();
showSubmenu();
}
}); });
}); });
return $(menu); return $(menu);
@ -1137,7 +1154,7 @@ define([
show = ['newfolder', 'newsharedfolder', 'newdoc']; show = ['newfolder', 'newsharedfolder', 'newdoc'];
break; break;
case 'tree': case 'tree':
show = ['open', 'openro', 'expandall', 'collapseall', 'color', 'download', 'share', 'rename', 'delete', 'deleteowned', 'removesf', 'properties', 'hashtag', 'subtest1', 'subtest2', 'subtest3']; show = ['open', 'openro', 'expandall', 'collapseall', 'color', 'download', 'share', 'rename', 'delete', 'deleteowned', 'removesf', 'properties', 'hashtag', 'subtest1', 'subtest2', 'subtest3', 'subtest4', 'subtest5', 'subtest6'];
break; break;
case 'default': case 'default':
show = ['open', 'openro', 'share', 'openparent', 'delete', 'deleteowned', 'properties', 'hashtag']; show = ['open', 'openro', 'share', 'openparent', 'delete', 'deleteowned', 'properties', 'hashtag'];
@ -1335,7 +1352,7 @@ define([
} }
}); });
if (!showSep && $lastVisibleSep) { $lastVisibleSep.css("display", "none"); } // remove last divider if no options after if (!showSep && $lastVisibleSep) { $lastVisibleSep.css("display", "none"); } // remove last divider if no options after
} };
var displayMenu = function (e) { var displayMenu = function (e) {
var $menu = $contextMenu; var $menu = $contextMenu;
$menu.find(".dropdown-menu").each(function (i, menu) { $menu.find(".dropdown-menu").each(function (i, menu) {
@ -1454,7 +1471,7 @@ define([
}); });
cb(); cb();
}; };
if (paths.some(function (p) { return manager.comparePath(newPath, p) })) { return void cb(); } if (paths.some(function (p) { return manager.comparePath(newPath, p); })) { return void cb(); }
manager.move(paths, newPath, newCb, copy); manager.move(paths, newPath, newCb, copy);
}; };
// Delete paths from the drive and/or shared folders (without moving them to the trash) // Delete paths from the drive and/or shared folders (without moving them to the trash)
@ -3423,6 +3440,7 @@ define([
}; };
APP.hideMenu = function (e) { APP.hideMenu = function (e) {
console.error("HIDEMENU", e ? e.target : "e is undefined");
$contextMenu.hide(); $contextMenu.hide();
$trashTreeContextMenu.hide(); $trashTreeContextMenu.hide();
$trashContextMenu.hide(); $trashContextMenu.hide();
@ -3525,7 +3543,7 @@ define([
if (paths.length !== 1) { return; } if (paths.length !== 1) { return; }
displayRenameInput(paths[0].element, paths[0].path); displayRenameInput(paths[0].element, paths[0].path);
} }
if ($(this).hasClass("cp-app-drive-context-color")) { else if ($(this).hasClass("cp-app-drive-context-color")) {
var currentColor = getFolderColor(paths[0].path); var currentColor = getFolderColor(paths[0].path);
pickFolderColor(paths[0].element, currentColor, function (color) { pickFolderColor(paths[0].element, currentColor, function (color) {
paths.forEach(function (p) { paths.forEach(function (p) {
@ -3770,6 +3788,7 @@ define([
$appContainer.on('mouseup', function (e) { $appContainer.on('mouseup', function (e) {
//if (sel.down) { return; } //if (sel.down) { return; }
if (e.which !== 1) { return ; } if (e.which !== 1) { return ; }
if ($(e.target).is(".dropdown-submenu a, .dropdown-submenu a span")) { return; } // if we click on dropdown-submenu, don't close menu
APP.hideMenu(e); APP.hideMenu(e);
//removeSelected(e); //removeSelected(e);
}); });

Loading…
Cancel
Save