Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import jQuery from "jquery";
import { NodeNeighborOverlay } from "./neighbors";
import * as Helpers from "../helpers";
import * as Config from "../../config";
export { NodeInfoOverlay };
/**
* An overlay displaying the information which is connected with each node.
*/
class NodeInfoOverlay {
/**
* Constructs a new info overlay for the given graph object.
* @param {Graph} graph
*/
constructor(graph) {
this.graph = graph;
this.bottomMenu = null;
}
/**
* Creates the visible elements of the overlay.
* Must be called after the graph has been initialized.
*/
create() {
const overlayDiv = this.createOverlayMainDiv();
this.createOverlayElements(overlayDiv);
this.bottomMenu = new NodeNeighborOverlay(this.graph, overlayDiv, this);
this.bottomMenu.create();
jQuery("#infoOverlayCloseButton").click(function () {
jQuery("#infoOverlay").slideUp("fast");
});
}
createOverlayMainDiv() {
const sceneNode = Helpers.getCanvasDivNode();
const overlayNode = document.createElement("div");
overlayNode.id = "infoOverlay";
overlayNode.className = "detail-view";
sceneNode.insertBefore(overlayNode, sceneNode.childNodes[2]);
return overlayNode;
}
createOverlayElements(overlayNode) {
const close = document.createElement("div");
close.innerHTML = "<p>✖</p>";
close.id = "infoOverlayCloseButton";
close.className = "close-button";
overlayNode.appendChild(close);
const infoArea = document.createElement("div");
infoArea.className = "detail-view-info-area";
overlayNode.appendChild(infoArea);
const topArea = document.createElement("div");
topArea.className = "detail-view-top-area";
infoArea.appendChild(topArea);
const nodeImage = document.createElement("img");
nodeImage.id = "infoOverlayImage";
nodeImage.src = Config.PLUGIN_PATH + "datasets/images/default.jpg";
nodeImage.className = "detail-view-image";
topArea.appendChild(nodeImage);
const headline = document.createElement("h2");
headline.id = "infoOverlayHeadline";
headline.innerText = "Default Text";
headline.className = "detail-view-headline";
topArea.appendChild(headline);
const textArea = document.createElement("div");
textArea.className = "detail-view-text-area";
infoArea.appendChild(textArea);
const description = document.createElement("p");
description.id = "infoOverlayDescription";
description.innerText = "Default Text";
description.setAttribute("overflow-y", "scroll");
textArea.appendChild(description);
}
/**
* Updates the overlay (and its children) to display information on the given node.
* @param node
*/
updateInfoOverlay(node) {
jQuery("#infoOverlayHeadline").text(node.name);
if ("image" in node) {
jQuery("#infoOverlayImage").attr(
"src",
Config.PLUGIN_PATH + "datasets/images/" + node.image
);
} else {
jQuery("#infoOverlayImage").attr(
"src",
Config.PLUGIN_PATH + "datasets/images/default.jpg"
);
}
if ("description" in node) {
jQuery("#infoOverlayDescription").text(node.description);
} else {
jQuery("#infoOverlayDescription").text("Default Text");
}
this.bottomMenu.updateTabs(node);
jQuery("#infoOverlay").slideDown("fast");
}
}