Adapt code style.

This commit is contained in:
Bruno Feurer 2022-08-28 21:25:40 +02:00
parent bcb1163d59
commit c20ff8efd5
4 changed files with 66 additions and 61 deletions

View File

@ -86,6 +86,7 @@
"rtl": "Von rechts nach links",
"auto": "Kontextabhängig",
"language": "Sprache",
"nodeQuickAdd": "Zeige Schnellauswahl beim Verbinden ins Leere",
"browserDefault": "Browservorgabe"
},
"sidebar": {
@ -124,7 +125,6 @@
"projects-open": "Öffnen",
"projects-settings": "Einstellungen",
"showNodeLabelDefault": "Zeige Namen von neu hinzugefügten Nodes",
"nodeQuickAddLabel": "Zeige Schnellauswahl beim Verbinden ins Leere",
"codeEditor": "Code-Editor",
"groups": "Gruppen",
"groupSelection": "Auswahl gruppieren",

View File

@ -86,7 +86,7 @@
"rtl": "Right-to-left",
"auto": "Contextual",
"language": "Language",
"nodeQuickAdd": "Quick-add node when joining to empty space",
"nodeQuickAdd": "Quick-add node when joining to empty space",
"browserDefault": "Browser default"
},
"sidebar": {

View File

@ -65,14 +65,14 @@ RED.palette = (function() {
catDiv.addClass("red-ui-palette-closed");
$("#red-ui-palette-base-category-"+category).slideUp();
$("#red-ui-palette-header-"+category+" i").removeClass("expanded");
rememberCategoryState(category, false)
rememberCategoryState(category, false);
},
open: function() {
catDiv.addClass("red-ui-palette-open");
catDiv.removeClass("red-ui-palette-closed");
$("#red-ui-palette-base-category-"+category).slideDown();
$("#red-ui-palette-header-"+category+" i").addClass("expanded");
rememberCategoryState(category, true)
rememberCategoryState(category, true);
},
toggle: function() {
if (catDiv.hasClass("red-ui-palette-open")) {
@ -87,22 +87,26 @@ RED.palette = (function() {
categoryContainers[category].toggle();
});
}
function rememberCategoryState(cat, open) {
const stateStr = localStorage.getItem('closedCategories');
if (!stateStr && open) return;
const state = stateStr ? JSON.parse(stateStr) : [];
const idx = state.indexOf(cat);
if (open && idx >= 0)
state.splice(idx, 1);
else if (!open && idx < 0)
state.push(cat);
else
return;
if (state.length <= 0)
localStorage.removeItem('closedCategories');
else
localStorage.setItem('closedCategories', JSON.stringify(state));
}
function rememberCategoryState(cat, open) {
const stateStr = localStorage.getItem('closedCategories');
if (!stateStr && open) {
return;
}
const state = stateStr ? JSON.parse(stateStr) : [];
const idx = state.indexOf(cat);
if (open && idx >= 0) {
state.splice(idx, 1);
} else if (!open && idx < 0) {
state.push(cat);
} else {
return;
}
if (state.length <= 0) {
localStorage.removeItem('closedCategories');
} else {
localStorage.setItem('closedCategories', JSON.stringify(state));
}
}
function setLabel(type, el,label, info) {
var nodeWidth = 82;
@ -423,15 +427,16 @@ RED.palette = (function() {
}
setLabel(nt,d,label,nodeInfo);
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
if (categoryNode.find(".red-ui-palette-node").length === 1) {
const closedCategoriesStr = localStorage.getItem('closedCategories');
const closedCategories = closedCategoriesStr ? JSON.parse(closedCategoriesStr) : [];
if (closedCategories.indexOf(rootCategory) < 0)
categoryContainers[rootCategory].open();
else
categoryContainers[rootCategory].close();
}
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
if (categoryNode.find(".red-ui-palette-node").length === 1) {
const closedCategoriesStr = localStorage.getItem('closedCategories');
const closedCategories = closedCategoriesStr ? JSON.parse(closedCategoriesStr) : [];
if (closedCategories.indexOf(rootCategory) < 0) {
categoryContainers[rootCategory].open();
} else {
categoryContainers[rootCategory].close();
}
}
}
}
@ -675,7 +680,7 @@ RED.palette = (function() {
});
RED.popover.tooltip(paletteExpandAll,RED._('palette.actions.expand-all'));
RED.actions.add("core:toggle-palette", function(state) {
RED.actions.add("core:toggle-palette", function(state) {
if (state === undefined) {
RED.menu.toggleSelected("menu-item-palette");
} else {

View File

@ -1801,34 +1801,34 @@ RED.view = (function() {
return;
}
if (mousedown_node && mouse_mode == RED.state.JOINING) {
if (RED.settings.get("editor.view.node-quick-add")) {
// Trigger quick add dialog
d3.event.stopPropagation();
clearSelection();
const point = d3.mouse(this);
var clickedGroup = getGroupAt(point[0], point[1]);
if (drag_lines.length > 0) {
clickedGroup = clickedGroup || RED.nodes.group(drag_lines[0].node.g)
}
showQuickAddDialog({ position: point, group: clickedGroup });
} else {
var removedLinks = [];
for (i=0;i<drag_lines.length;i++) {
if (drag_lines[i].link) {
removedLinks.push(drag_lines[i].link)
}
}
if (removedLinks.length > 0) {
historyEvent = {
t:"delete",
links: removedLinks,
dirty:RED.nodes.dirty()
};
RED.history.push(historyEvent);
RED.nodes.dirty(true);
}
hideDragLines();
}
if (RED.settings.get("editor.view.node-quick-add")) {
// Trigger quick add dialog
d3.event.stopPropagation();
clearSelection();
const point = d3.mouse(this);
var clickedGroup = getGroupAt(point[0], point[1]);
if (drag_lines.length > 0) {
clickedGroup = clickedGroup || RED.nodes.group(drag_lines[0].node.g)
}
showQuickAddDialog({ position: point, group: clickedGroup });
} else {
var removedLinks = [];
for (i=0;i<drag_lines.length;i++) {
if (drag_lines[i].link) {
removedLinks.push(drag_lines[i].link)
}
}
if (removedLinks.length > 0) {
historyEvent = {
t:"delete",
links: removedLinks,
dirty:RED.nodes.dirty()
};
RED.history.push(historyEvent);
RED.nodes.dirty(true);
}
hideDragLines();
}
}
if (lasso) {
var x = parseInt(lasso.attr("x"));
@ -4892,9 +4892,9 @@ RED.view = (function() {
icon.attr("y",function(){return (d.h-d3.select(this).attr("height"))/2;});
const rightAlign = "right" === d._def.align
if (d.inputs && !rightAlign) icon.attr("x",3);
if (d.outputs && rightAlign) icon.attr("x",-3);
const rightAlign = "right" === d._def.align
if (d.inputs && !rightAlign) icon.attr("x",3);
if (d.outputs && rightAlign) icon.attr("x",-3);
const iconShadeHeight = d.h
const iconShadeWidth = d.inputs && d.outputs ? 33 : 30