1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Collapse palette category when emptied

This commit is contained in:
Nick O'Leary 2015-03-20 23:12:52 +00:00
parent 18a3d71024
commit 78cf310c58

View File

@ -98,7 +98,6 @@ RED.palette = (function() {
} }
function addNodeType(nt,def) { function addNodeType(nt,def) {
var nodeTypeId = escapeNodeType(nt); var nodeTypeId = escapeNodeType(nt);
if ($("#palette_node_"+nodeTypeId).length) { if ($("#palette_node_"+nodeTypeId).length) {
return; return;
@ -192,7 +191,15 @@ RED.palette = (function() {
function removeNodeType(nt) { function removeNodeType(nt) {
var nodeTypeId = escapeNodeType(nt); var nodeTypeId = escapeNodeType(nt);
$("#palette_node_"+nodeTypeId).remove(); var paletteNode = $("#palette_node_"+nodeTypeId);
var categoryNode = paletteNode.closest(".palette-category");
paletteNode.remove();
if (categoryNode.find(".palette_node").length === 0) {
if (categoryNode.find("i").hasClass("expanded")) {
categoryNode.find(".palette-content").slideToggle();
categoryNode.find("i").toggleClass("expanded");
}
}
} }
function hideNodeType(nt) { function hideNodeType(nt) {
var nodeTypeId = escapeNodeType(nt); var nodeTypeId = escapeNodeType(nt);