mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Added dynamic category capability
This commit is contained in:
parent
e15de8cf37
commit
5959da2d37
@ -80,51 +80,7 @@
|
||||
<div id="main-container" class="sidebar-closed">
|
||||
<div id="palette">
|
||||
<img src="spin.svg" class="palette-spinner"/>
|
||||
<div 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 id="palette-container" class="palette-scroll">
|
||||
</div>
|
||||
<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>
|
||||
|
@ -13,15 +13,35 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
RED.palette = function() {
|
||||
|
||||
var exclusion = ['config','unknown'];
|
||||
var core = ['input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'];
|
||||
|
||||
function createCategoryContainer(category){
|
||||
console.log(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>\
|
||||
</div>');
|
||||
|
||||
}
|
||||
|
||||
core.forEach(createCategoryContainer);
|
||||
|
||||
function addNodeType(nt,def) {
|
||||
if (def.category != 'config') {
|
||||
if (exclusion.indexOf(def.category)===-1) {
|
||||
|
||||
var category = def.category.split("-");
|
||||
|
||||
var d = document.createElement("div");
|
||||
d.id = "pn_"+nt;
|
||||
d.type = nt;
|
||||
|
||||
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
|
||||
|
||||
d.innerHTML = '<div class="palette_label">'+label+"</div>";
|
||||
d.className="palette_node";
|
||||
if (def.icon) {
|
||||
@ -47,9 +67,16 @@ RED.palette = function() {
|
||||
d.appendChild(port);
|
||||
}
|
||||
|
||||
// TODO: add categories dynamically?
|
||||
$("#palette-"+def.category).append(d);
|
||||
if($("#palette-base-category-"+category[0]).length == 0){
|
||||
createCategoryContainer(category[0]);
|
||||
}
|
||||
|
||||
if($("#palette-"+def.category).length == 0){
|
||||
$("#palette-base-category-"+category[0]).append('\
|
||||
<div id="palette-'+def.category+'"></div>');
|
||||
}
|
||||
|
||||
$("#palette-"+def.category).append(d);
|
||||
d.onmousedown = function(e) { e.preventDefault(); }
|
||||
|
||||
$(d).popover({
|
||||
@ -71,14 +98,15 @@ RED.palette = function() {
|
||||
revert: true,
|
||||
revertDuration: 50
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".palette-header").click(function(e) {
|
||||
$("#header-"+category[0]).off('click').on('click', function(e) {
|
||||
$(this).next().slideToggle();
|
||||
$(this).children("i").toggleClass("expanded");
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function filterChange() {
|
||||
var val = $("#palette-search-input").val();
|
||||
if (val == "") {
|
||||
|
Loading…
Reference in New Issue
Block a user