Make contextmenu separators hide for submenus too

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

@ -327,34 +327,56 @@ define([
'tabindex': '-1', 'tabindex': '-1',
'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-test.dropdown-item', {
// 'tabindex': '-1', 'tabindex': '-1',
// 'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
// }, "TEST"), }, "TEST"),
// h("ul.dropdown-menu", [ h("ul.dropdown-menu", [
// h('li', h('a.cp-app-drive-context-subtest1.dropdown-item', { h('li', h('a.cp-app-drive-context-subtest1.dropdown-item', {
// 'tabindex': '-1', 'tabindex': '-1',
// '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-test.dropdown-item', {
// 'tabindex': '-1', 'tabindex': '-1',
// 'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
// }, "TEST"), }, "TEST"),
// h("ul.dropdown-menu", [ h("ul.dropdown-menu", [
// h('li', h('a.cp-app-drive-context-subtest2.dropdown-item', { h('li', h('a.cp-app-drive-context-subtest2.dropdown-item', {
// 'tabindex': '-1', 'tabindex': '-1',
// 'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
// }, "Sub test 2")), }, "Sub test 2")),
// h('li', h('a.cp-app-drive-context-subtest3.dropdown-item', { h('li', h('a.cp-app-drive-context-subtest3.dropdown-item', {
// 'tabindex': '-1', 'tabindex': '-1',
// 'data-icon': faFolderOpen, 'data-icon': faFolderOpen,
// }, "Sub test 3")), }, "Sub test 3")),
// ]), ]),
// ]), ]),
// ]), $separator.clone()[0],
// ]), h('li', h('a.cp-app-drive-context-subtest4.dropdown-item', {
'tabindex': '-1',
'data-icon': faFolderOpen,
}, "Sub test 4")),
$separator.clone()[0],
h('li.dropdown-submenu', [
h('a.cp-app-drive-context-test.dropdown-item', {
'tabindex': '-1',
'data-icon': faFolderOpen,
}, "TEST"),
h("ul.dropdown-menu", [
h('li', h('a.cp-app-drive-context-subtest5.dropdown-item', {
'tabindex': '-1',
'data-icon': faFolderOpen,
}, "Sub test 5")),
h('li', h('a.cp-app-drive-context-subtest6.dropdown-item', {
'tabindex': '-1',
'data-icon': faFolderOpen,
}, "Sub test 6")),
]),
]),
]),
]),
h('li', h('a.cp-app-drive-context-download.dropdown-item', { h('li', h('a.cp-app-drive-context-download.dropdown-item', {
'tabindex': '-1', 'tabindex': '-1',
'data-icon': faDownload, 'data-icon': faDownload,
@ -1297,12 +1319,11 @@ define([
updateContextButton(); updateContextButton();
}; };
var displayMenu = function (e) { // show / hide dropdown separators
var $menu = $contextMenu; var hideSeparators = function ($menu) {
var showSep = false; var showSep = false;
var $lastVisibleSep = null; var $lastVisibleSep = null;
// show / hide drop-down divider $menu.children().each(function (i, el) {
$menu.find(".dropdown-menu").children().each(function (i, el) {
var $el = $(el); var $el = $(el);
if ($el.is(".dropdown-divider")) { if ($el.is(".dropdown-divider")) {
$el.css("display", showSep ? "list-item" : "none"); $el.css("display", showSep ? "list-item" : "none");
@ -1314,6 +1335,12 @@ 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 $menu = $contextMenu;
$menu.find(".dropdown-menu").each(function (i, menu) {
hideSeparators($(menu));
});
// show / hide submenus // show / hide submenus
$menu.find(".dropdown-submenu").each(function (i, el) { $menu.find(".dropdown-submenu").each(function (i, el) {
var $el = $(el); var $el = $(el);

Loading…
Cancel
Save