mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
@@ -133,6 +133,8 @@ RED.menu = (function() {
|
||||
if (opt.options) {
|
||||
item.addClass("red-ui-menu-dropdown-submenu"+(opt.direction!=='right'?" pull-left":""));
|
||||
var submenu = $('<ul id="'+opt.id+'-submenu" class="red-ui-menu-dropdown"></ul>').appendTo(item);
|
||||
var hasIcons = false
|
||||
var hasSubmenus = false
|
||||
|
||||
for (var i=0;i<opt.options.length;i++) {
|
||||
|
||||
@@ -144,6 +146,8 @@ RED.menu = (function() {
|
||||
opt.options[i].onpostselect = opt.onpostselect
|
||||
}
|
||||
opt.options[i].direction = opt.direction
|
||||
hasIcons = hasIcons || (opt.options[i].icon);
|
||||
hasSubmenus = hasSubmenus || (opt.options[i].options);
|
||||
}
|
||||
|
||||
var li = createMenuItem(opt.options[i]);
|
||||
@@ -151,6 +155,14 @@ RED.menu = (function() {
|
||||
li.appendTo(submenu);
|
||||
}
|
||||
}
|
||||
if (!hasIcons) {
|
||||
submenu.addClass("red-ui-menu-dropdown-noicons")
|
||||
}
|
||||
if (hasSubmenus) {
|
||||
submenu.addClass("red-ui-menu-dropdown-submenus")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (opt.disabled) {
|
||||
item.addClass("disabled");
|
||||
@@ -191,6 +203,8 @@ RED.menu = (function() {
|
||||
}
|
||||
|
||||
var lastAddedSeparator = false;
|
||||
var hasSubmenus = false;
|
||||
var hasIcons = false;
|
||||
for (var i=0;i<options.options.length;i++) {
|
||||
var opt = options.options[i];
|
||||
if (opt) {
|
||||
@@ -203,6 +217,8 @@ RED.menu = (function() {
|
||||
opt.direction = options.direction || 'left'
|
||||
}
|
||||
if (opt !== null || !lastAddedSeparator) {
|
||||
hasIcons = hasIcons || (opt && opt.icon);
|
||||
hasSubmenus = hasSubmenus || (opt && opt.options);
|
||||
var li = createMenuItem(opt);
|
||||
if (li) {
|
||||
li.appendTo(topMenu);
|
||||
@@ -210,7 +226,12 @@ RED.menu = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasIcons) {
|
||||
topMenu.addClass("red-ui-menu-dropdown-noicons")
|
||||
}
|
||||
if (hasSubmenus) {
|
||||
topMenu.addClass("red-ui-menu-dropdown-submenus")
|
||||
}
|
||||
return topMenu;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user