mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #254 from TJKoury/master
Added dynamic category capability
This commit is contained in:
commit
6e956ef03a
@ -80,51 +80,7 @@
|
|||||||
<div id="main-container" class="sidebar-closed">
|
<div id="main-container" class="sidebar-closed">
|
||||||
<div id="palette">
|
<div id="palette">
|
||||||
<img src="spin.svg" class="palette-spinner"/>
|
<img src="spin.svg" class="palette-spinner"/>
|
||||||
<div class="palette-scroll">
|
<div id="palette-container" class="palette-scroll">
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>inputs</span></div>
|
|
||||||
<div class="palette-content" id="palette-input"></div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>outputs</span></div>
|
|
||||||
<div class="palette-content" id="palette-output"></div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>functions</span></div>
|
|
||||||
<div class="palette-content" id="palette-function"></div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>social</span></div>
|
|
||||||
<div class="palette-content">
|
|
||||||
<div id="palette-social-input"></div>
|
|
||||||
<div id="palette-social-output"></div>
|
|
||||||
<div id="palette-social-function"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>storage</span></div>
|
|
||||||
<div class="palette-content">
|
|
||||||
<div id="palette-storage-input"></div>
|
|
||||||
<div id="palette-storage-output"></div>
|
|
||||||
<div id="palette-storage-function"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>analysis</span></div>
|
|
||||||
<div class="palette-content">
|
|
||||||
<div id="palette-analysis-input"></div>
|
|
||||||
<div id="palette-analysis-output"></div>
|
|
||||||
<div id="palette-analysis-function"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="palette-category">
|
|
||||||
<div class="palette-header"><i class="expanded icon-chevron-down"></i><span>advanced</span></div>
|
|
||||||
<div class="palette-content">
|
|
||||||
<div id="palette-advanced-input"></div>
|
|
||||||
<div id="palette-advanced-output"></div>
|
|
||||||
<div id="palette-advanced-function"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="palette-search">
|
<div id="palette-search">
|
||||||
<i class="icon-search"></i><input id="palette-search-input" type="text" placeholder="filter"><a href="#" id="palette-search-clear"><i class="icon-remove"></i></a></input>
|
<i class="icon-search"></i><input id="palette-search-input" type="text" placeholder="filter"><a href="#" id="palette-search-clear"><i class="icon-remove"></i></a></input>
|
||||||
|
@ -12,73 +12,105 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
RED.palette = function() {
|
|
||||||
|
RED.palette = function() {
|
||||||
|
|
||||||
|
var exclusion = ['config','unknown','deprecated'];
|
||||||
|
var core = ['input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'];
|
||||||
|
|
||||||
|
function createCategoryContainer(category){
|
||||||
|
|
||||||
|
$("#palette-container").append('\
|
||||||
|
<div class="palette-category">\
|
||||||
|
<div id="header-'+category+'" class="palette-header"><i class="expanded icon-chevron-down"></i><span>'+category+'</span></div>\
|
||||||
|
<div class="palette-content" id="palette-base-category-'+category+'">\
|
||||||
|
<div id="palette-'+category+'-input"></div>\
|
||||||
|
<div id="palette-'+category+'-output"></div>\
|
||||||
|
<div id="palette-'+category+'-function"></div>\
|
||||||
|
</div>\
|
||||||
|
</div>');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
core.forEach(createCategoryContainer);
|
||||||
|
|
||||||
function addNodeType(nt,def) {
|
function addNodeType(nt,def) {
|
||||||
if (def.category != 'config') {
|
if (exclusion.indexOf(def.category)===-1) {
|
||||||
var d = document.createElement("div");
|
|
||||||
d.id = "pn_"+nt;
|
var category = def.category.split("-");
|
||||||
d.type = nt;
|
|
||||||
|
var d = document.createElement("div");
|
||||||
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
d.id = "pn_"+nt;
|
||||||
d.innerHTML = '<div class="palette_label">'+label+"</div>";
|
d.type = nt;
|
||||||
d.className="palette_node";
|
|
||||||
if (def.icon) {
|
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
||||||
d.style.backgroundImage = "url(icons/"+def.icon+")";
|
|
||||||
if (def.align == "right") {
|
d.innerHTML = '<div class="palette_label">'+label+"</div>";
|
||||||
d.style.backgroundPosition = "95% 50%";
|
d.className="palette_node";
|
||||||
} else if (def.inputs > 0) {
|
if (def.icon) {
|
||||||
d.style.backgroundPosition = "10% 50%";
|
d.style.backgroundImage = "url(icons/"+def.icon+")";
|
||||||
}
|
if (def.align == "right") {
|
||||||
}
|
d.style.backgroundPosition = "95% 50%";
|
||||||
|
} else if (def.inputs > 0) {
|
||||||
d.style.backgroundColor = def.color;
|
d.style.backgroundPosition = "10% 50%";
|
||||||
|
}
|
||||||
if (def.outputs > 0) {
|
}
|
||||||
var port = document.createElement("div");
|
|
||||||
port.className = "palette_port palette_port_output";
|
d.style.backgroundColor = def.color;
|
||||||
d.appendChild(port);
|
|
||||||
}
|
if (def.outputs > 0) {
|
||||||
|
var port = document.createElement("div");
|
||||||
if (def.inputs > 0) {
|
port.className = "palette_port palette_port_output";
|
||||||
var port = document.createElement("div");
|
d.appendChild(port);
|
||||||
port.className = "palette_port";
|
}
|
||||||
d.appendChild(port);
|
|
||||||
}
|
if (def.inputs > 0) {
|
||||||
|
var port = document.createElement("div");
|
||||||
// TODO: add categories dynamically?
|
port.className = "palette_port";
|
||||||
$("#palette-"+def.category).append(d);
|
d.appendChild(port);
|
||||||
|
}
|
||||||
d.onmousedown = function(e) { e.preventDefault(); }
|
|
||||||
|
if($("#palette-base-category-"+category[0]).length == 0){
|
||||||
$(d).popover({
|
createCategoryContainer(category[0]);
|
||||||
title:d.type,
|
}
|
||||||
placement:"right",
|
|
||||||
trigger: "hover",
|
if($("#palette-"+def.category).length == 0){
|
||||||
delay: { show: 750, hide: 50 },
|
$("#palette-base-category-"+category[0]).append('\
|
||||||
html: true,
|
<div id="palette-'+def.category+'"></div>');
|
||||||
container:'body',
|
}
|
||||||
content: $(($("script[data-help-name|='"+nt+"']").html()||"<p>no information available</p>").trim())[0]
|
|
||||||
});
|
$("#palette-"+def.category).append(d);
|
||||||
$(d).click(function() {
|
d.onmousedown = function(e) { e.preventDefault(); }
|
||||||
var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>";
|
|
||||||
$("#tab-info").html(help);
|
$(d).popover({
|
||||||
});
|
title:d.type,
|
||||||
$(d).draggable({
|
placement:"right",
|
||||||
helper: 'clone',
|
trigger: "hover",
|
||||||
appendTo: 'body',
|
delay: { show: 750, hide: 50 },
|
||||||
revert: true,
|
html: true,
|
||||||
revertDuration: 50
|
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>";
|
||||||
|
$("#tab-info").html(help);
|
||||||
|
});
|
||||||
|
$(d).draggable({
|
||||||
|
helper: 'clone',
|
||||||
|
appendTo: 'body',
|
||||||
|
revert: true,
|
||||||
|
revertDuration: 50
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#header-"+category[0]).off('click').on('click', function(e) {
|
||||||
|
$(this).next().slideToggle();
|
||||||
|
$(this).children("i").toggleClass("expanded");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".palette-header").click(function(e) {
|
|
||||||
$(this).next().slideToggle();
|
|
||||||
$(this).children("i").toggleClass("expanded");
|
|
||||||
});
|
|
||||||
|
|
||||||
function filterChange() {
|
function filterChange() {
|
||||||
var val = $("#palette-search-input").val();
|
var val = $("#palette-search-input").val();
|
||||||
if (val == "") {
|
if (val == "") {
|
||||||
|
Loading…
Reference in New Issue
Block a user