mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
0a3c889cc6
commit
fae8b35961
@ -20,9 +20,9 @@ RED.palette = (function() {
|
|||||||
var core = ['input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'];
|
var core = ['input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'];
|
||||||
|
|
||||||
function createCategoryContainer(category){
|
function createCategoryContainer(category){
|
||||||
|
var escapedCategory = category.replace(" ","_");
|
||||||
$("#palette-container").append('<div class="palette-category">'+
|
$("#palette-container").append('<div class="palette-category">'+
|
||||||
'<div id="header-'+category+'" class="palette-header"><i class="expanded fa fa-caret-down"></i><span>'+category+'</span></div>'+
|
'<div id="header-'+category+'" class="palette-header"><i class="expanded fa fa-caret-down"></i><span>'+category.replace("_"," ")+'</span></div>'+
|
||||||
'<div class="palette-content" id="palette-base-category-'+category+'">'+
|
'<div class="palette-content" id="palette-base-category-'+category+'">'+
|
||||||
'<div id="palette-'+category+'-input"></div>'+
|
'<div id="palette-'+category+'-input"></div>'+
|
||||||
'<div id="palette-'+category+'-output"></div>'+
|
'<div id="palette-'+category+'-output"></div>'+
|
||||||
@ -41,76 +41,77 @@ RED.palette = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exclusion.indexOf(def.category)===-1) {
|
if (exclusion.indexOf(def.category)===-1) {
|
||||||
|
|
||||||
var category = def.category.split("-");
|
var category = def.category.replace(" ","_");
|
||||||
|
var rootCategory = category.split("-")[0];
|
||||||
var d = document.createElement("div");
|
|
||||||
d.id = "palette_node_"+nt;
|
var d = document.createElement("div");
|
||||||
d.type = nt;
|
d.id = "palette_node_"+nt;
|
||||||
|
d.type = nt;
|
||||||
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
|
||||||
|
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
||||||
d.innerHTML = '<div class="palette_label">'+label+"</div>";
|
|
||||||
d.className="palette_node";
|
d.innerHTML = '<div class="palette_label">'+label+"</div>";
|
||||||
if (def.icon) {
|
d.className="palette_node";
|
||||||
d.style.backgroundImage = "url(icons/"+def.icon+")";
|
if (def.icon) {
|
||||||
if (def.align == "right") {
|
d.style.backgroundImage = "url(icons/"+def.icon+")";
|
||||||
d.style.backgroundPosition = "95% 50%";
|
if (def.align == "right") {
|
||||||
} else if (def.inputs > 0) {
|
d.style.backgroundPosition = "95% 50%";
|
||||||
d.style.backgroundPosition = "10% 50%";
|
} else if (def.inputs > 0) {
|
||||||
}
|
d.style.backgroundPosition = "10% 50%";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
d.style.backgroundColor = def.color;
|
|
||||||
|
d.style.backgroundColor = def.color;
|
||||||
if (def.outputs > 0) {
|
|
||||||
var portOut = document.createElement("div");
|
if (def.outputs > 0) {
|
||||||
portOut.className = "palette_port palette_port_output";
|
var portOut = document.createElement("div");
|
||||||
d.appendChild(portOut);
|
portOut.className = "palette_port palette_port_output";
|
||||||
}
|
d.appendChild(portOut);
|
||||||
|
}
|
||||||
if (def.inputs > 0) {
|
|
||||||
var portIn = document.createElement("div");
|
if (def.inputs > 0) {
|
||||||
portIn.className = "palette_port";
|
var portIn = document.createElement("div");
|
||||||
d.appendChild(portIn);
|
portIn.className = "palette_port";
|
||||||
}
|
d.appendChild(portIn);
|
||||||
|
}
|
||||||
if ($("#palette-base-category-"+category[0]).length === 0){
|
|
||||||
createCategoryContainer(category[0]);
|
if ($("#palette-base-category-"+rootCategory).length === 0) {
|
||||||
}
|
createCategoryContainer(rootCategory);
|
||||||
|
}
|
||||||
if ($("#palette-"+def.category).length === 0) {
|
|
||||||
$("#palette-base-category-"+category[0]).append('<div id="palette-'+def.category+'"></div>');
|
if ($("#palette-"+category).length === 0) {
|
||||||
}
|
$("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>');
|
||||||
|
}
|
||||||
$("#palette-"+def.category).append(d);
|
|
||||||
d.onmousedown = function(e) { e.preventDefault(); }
|
$("#palette-"+category).append(d);
|
||||||
|
d.onmousedown = function(e) { e.preventDefault(); }
|
||||||
$(d).popover({
|
|
||||||
title:d.type,
|
$(d).popover({
|
||||||
placement:"right",
|
title:d.type,
|
||||||
trigger: "hover",
|
placement:"right",
|
||||||
delay: { show: 750, hide: 50 },
|
trigger: "hover",
|
||||||
html: true,
|
delay: { show: 750, hide: 50 },
|
||||||
container:'body',
|
html: true,
|
||||||
content: $(($("script[data-help-name|='"+nt+"']").html()||"<p>no information available</p>").trim())[0]
|
container:'body',
|
||||||
});
|
content: $(($("script[data-help-name|='"+nt+"']").html()||"<p>no information available</p>").trim())[0]
|
||||||
$(d).click(function() {
|
});
|
||||||
var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>";
|
$(d).click(function() {
|
||||||
$("#tab-info").html(help);
|
var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>";
|
||||||
});
|
$("#tab-info").html(help);
|
||||||
$(d).draggable({
|
});
|
||||||
helper: 'clone',
|
$(d).draggable({
|
||||||
appendTo: 'body',
|
helper: 'clone',
|
||||||
revert: true,
|
appendTo: 'body',
|
||||||
revertDuration: 50
|
revert: true,
|
||||||
});
|
revertDuration: 50
|
||||||
|
});
|
||||||
$("#header-"+category[0]).off('click').on('click', function(e) {
|
|
||||||
$(this).next().slideToggle();
|
$("#header-"+category[0]).off('click').on('click', function(e) {
|
||||||
$(this).children("i").toggleClass("expanded");
|
$(this).next().slideToggle();
|
||||||
});
|
$(this).children("i").toggleClass("expanded");
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user