mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Keep sidebar tab menu in alphabetical order
This commit is contained in:
parent
fde9d40098
commit
e5a0f25d94
@ -53,6 +53,10 @@ RED.menu = (function() {
|
||||
} else {
|
||||
item = $('<li></li>');
|
||||
|
||||
if (opt.group) {
|
||||
item.addClass("menu-group-"+opt.group);
|
||||
|
||||
}
|
||||
var linkContent = '<a '+(opt.id?'id="'+opt.id+'" ':'')+'tabindex="-1" href="#">';
|
||||
if (opt.toggle) {
|
||||
linkContent += '<i class="fa fa-square pull-left"></i>';
|
||||
@ -208,7 +212,27 @@ RED.menu = (function() {
|
||||
}
|
||||
|
||||
function addItem(id,opt) {
|
||||
createMenuItem(opt).appendTo("#"+id+"-submenu");
|
||||
var item = createMenuItem(opt);
|
||||
if (opt.group) {
|
||||
var groupItems = $("#"+id+"-submenu").children(".menu-group-"+opt.group);
|
||||
if (groupItems.length === 0) {
|
||||
item.appendTo("#"+id+"-submenu");
|
||||
} else {
|
||||
for (var i=0;i<groupItems.length;i++) {
|
||||
var groupItem = groupItems[i];
|
||||
var label = $(groupItem).find(".menu-label").html();
|
||||
if (opt.label < label) {
|
||||
$(groupItem).before(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === groupItems.length) {
|
||||
item.appendTo("#"+id+"-submenu");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.appendTo("#"+id+"-submenu");
|
||||
}
|
||||
}
|
||||
function removeItem(id) {
|
||||
$("#"+id).parent().remove();
|
||||
|
@ -64,7 +64,8 @@ RED.sidebar = (function() {
|
||||
label:options.name,
|
||||
onselect:function() {
|
||||
showSidebar(options.id);
|
||||
}
|
||||
},
|
||||
group: "sidebar-tabs"
|
||||
});
|
||||
|
||||
knownTabs[options.id] = options;
|
||||
|
@ -178,7 +178,7 @@
|
||||
},
|
||||
"sidebar": {
|
||||
"info": {
|
||||
"name": "Node Information",
|
||||
"name": "Information",
|
||||
"label": "info",
|
||||
"node": "Node",
|
||||
"type": "Type",
|
||||
|
Loading…
Reference in New Issue
Block a user