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

View File

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

View File

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

View File

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