Skip to content

Commit

Permalink
Allow to create nodes with duplicate names.
Browse files Browse the repository at this point in the history
Simplification.
Removing control and restriction to create nodes with duplicate names.
Graphs containing nodes with duplicate names still cannot be saved.
This change of behavior will be uniform with importing wild DOT files.
  • Loading branch information
obermann authored Dec 14, 2021
1 parent 928a277 commit 51baf9b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 37 deletions.
26 changes: 2 additions & 24 deletions script/editor-node-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ var nodeLabel = (function () {
var separator = "P";
var data = null;
var ranges = [];
var observer = new MutationObserver(function(recordList, observer) {
observer.disconnect();
editorNodeLabel.className = "";
});

var padding = 72; // px
var fontSize = window.getComputedStyle(editorNodeLabel).getPropertyValue("font-size").match(/([+-]?[\d\.]+(?:e[+-]?\d+)?)(.*)/); //[string, number, unit]
Expand Down Expand Up @@ -72,7 +68,6 @@ var nodeLabel = (function () {
// New node.
data = [{
label: "",
group: "default",
x: e.pointer.canvas.x,
y: e.pointer.canvas.y
}];
Expand All @@ -81,8 +76,7 @@ var nodeLabel = (function () {
// Need to copy a node to follow implied read-only intent!
data = [{
id: n.id,
label: n.label,
group: n.group
label: n.label
}]
}
if (style.transition && style.transition.edit) {
Expand All @@ -94,10 +88,6 @@ var nodeLabel = (function () {
},
edit2: function () {
editorNodeLabel.innerHTML = (data[0].label === "")? "" : "<" + separator + ">" + data[0].label.split(labelSeparator).join("</" + separator + "><" + separator + ">") + "</" + separator + ">";
if (data[0].group === "error") {
editorNodeLabel.className = "error";
observer.observe(editorNodeLabel, { subtree: true, childList: true, characterData: true });
}
editor.style.display = "block";
resize();
// Focus.
Expand All @@ -108,17 +98,7 @@ var nodeLabel = (function () {
editorNodeLabel.focus(); // calls this.restoreSelection()
},
save1: function (e) {
var label = escForVis(nodeToLabel(editorNodeLabel));
var newName = labelToName(label);
//if (visDataViews.nodes.get({ filter: function (item) { return ((labelToName(item.label) === newName) && (item.id !== data[0].id)) } }).length) {
var a = cache.getIds(newName);
if (a && (a.length > 1 || a[0] !== data[0].id)) {
editorNodeLabel.className = "error";
observer.observe(editorNodeLabel, { subtree: true, childList: true, characterData: true });
return false;
}
data[0].label = label;
observer.disconnect();
data[0].label = escForVis(nodeToLabel(editorNodeLabel));
editor.style.display = "none";
if (style.transition && style.transition.save) {
style.transition.save(nodeLabel.save2, e);
Expand All @@ -132,9 +112,7 @@ var nodeLabel = (function () {
visDataSet.update(data, "evEdit");
},
quit: function (e) {
observer.disconnect();
editor.style.display = "none";
editorNodeLabel.className = "";
if (style.transition && style.transition.cancel) {
style.transition.cancel(function () {}, e);
}
Expand Down
4 changes: 0 additions & 4 deletions style/animated-default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
color: white;
}

.error::first-line {
background-color: fuchsia;
}

#sprite {
background-color: rgba(0, 0, 255, 0.5);
margin: 0;
Expand Down
4 changes: 0 additions & 4 deletions style/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@
background-color: #D2E5FF; /* = vis selected node background color */
color: white;
}

.error::first-line {
background-color: fuchsia;
}
5 changes: 0 additions & 5 deletions style/solarized-light/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
color: rgba(0, 43, 54, 1); /*base03 #002b36;*/
}

.error::first-line {
background-color: rgba(220, 50, 47, 0.99); /*red #dc322f;*/
color: rgba(186, 196, 196, 1); /*base1 Corrected!*/
}

#sprite {
background-color: rgba(0, 43, 54, 0.6);
margin: 0;
Expand Down

0 comments on commit 51baf9b

Please sign in to comment.