Revize 5c33d5cb
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/src/main/webapp/css/main.css | ||
---|---|---|
411 | 411 |
border-bottom: 1px solid #c8cbcc; |
412 | 412 |
} |
413 | 413 |
|
414 |
.popover-content {
|
|
414 |
.popover-body {
|
|
415 | 415 |
max-height: 400px; |
416 | 416 |
overflow: auto; |
417 | 417 |
padding: 0 0.5em 0.5em 0.5em; |
sources/src/main/webapp/js/components/edge.js | ||
---|---|---|
262 | 262 |
* @param {Event} e Click event. |
263 | 263 |
*/ |
264 | 264 |
function click(e) { |
265 |
app.viewportComponent.edgePopoverComponent.setContent(props.subedgeInfo);
|
|
266 |
app.viewportComponent.edgePopoverComponent.setPosition(new Coordinates(e.clientX, e.clientY));
|
|
265 |
app.viewportComponent.edgePopoverComponent.body = props.subedgeInfo;
|
|
266 |
app.viewportComponent.edgePopoverComponent.position = new Coordinates(e.clientX, e.clientY);
|
|
267 | 267 |
app.viewportComponent.edgePopoverComponent.open(); |
268 | 268 |
|
269 | 269 |
// unhighlight other edges |
sources/src/main/webapp/js/components/edgePopover.js | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Class representing a popover revealed on edge click to display its compatibility information. |
3 | 3 |
* @see Edge |
4 |
* @constructor |
|
5 | 4 |
*/ |
6 |
function EdgePopover() { |
|
7 |
var rootElement; |
|
8 |
var detailsListElement; |
|
9 |
|
|
10 |
/** |
|
11 |
* Sets the contents of the popover. |
|
12 |
* @param {array} subedgeInfoList List of various edge information. |
|
13 |
*/ |
|
14 |
this.setContent = function(subedgeInfoList) { |
|
15 |
if (subedgeInfoList.length === 0) return; |
|
16 |
|
|
17 |
subedgeInfoList.filter(function(subedgeInfo) { |
|
18 |
return subedgeInfo.attributes.length > 0; |
|
19 |
}).forEach(function(subedgeInfo) { |
|
20 |
var listItem = DOM.createHtmlElement('li'); |
|
21 |
listItem.appendChild(DOM.createTextElement(app.archetype.edge[subedgeInfo.archetype].name)); |
|
22 |
|
|
23 |
var sublist = DOM.createHtmlElement('ul'); |
|
24 |
listItem.appendChild(sublist); |
|
25 |
|
|
26 |
detailsListElement.appendChild(listItem); |
|
27 |
|
|
28 |
subedgeInfo.attributes.forEach(function(attribute) { |
|
29 |
sublist.appendChild(new Attribute(attribute).render()); |
|
30 |
}); |
|
31 |
}); |
|
32 |
}; |
|
33 |
|
|
5 |
class EdgePopover extends Popover { |
|
34 | 6 |
/** |
35 |
* Moves the popover to the coordinates. |
|
36 |
* @param {Coordinates} coords Coordinates to display the popover at. |
|
7 |
* @inheritdoc |
|
37 | 8 |
*/ |
38 |
this.setPosition = function(coords) { |
|
39 |
rootElement.style.top = coords.y + 'px'; |
|
40 |
rootElement.style.left = coords.x + 'px'; |
|
41 |
}; |
|
9 |
render() { |
|
10 |
super.render(); |
|
42 | 11 |
|
43 |
/** |
|
44 |
* Opens the popover. |
|
45 |
*/ |
|
46 |
this.open = function() { |
|
47 |
rootElement.classList.remove('hidden'); |
|
48 |
}; |
|
12 |
this._titleElement.innerText = 'Edge details'; |
|
49 | 13 |
|
50 |
/** |
|
51 |
* Closes the popover. |
|
52 |
*/ |
|
53 |
this.close = function() { |
|
54 |
rootElement.classList.add('hidden'); |
|
14 |
this._detailsListElement = DOM.h('ul'); |
|
15 |
this._bodyElement.appendChild(this._detailsListElement); |
|
55 | 16 |
|
56 |
detailsListElement.innerHTML = '';
|
|
57 |
};
|
|
17 |
return this._rootElement;
|
|
18 |
} |
|
58 | 19 |
|
59 | 20 |
/** |
60 |
* Creates a new DOM element representing the popover in memory. Binds user interactions to local handler functions.
|
|
61 |
* @returns {Element} HTML DOM element.
|
|
21 |
* Sets the contents of the popover.
|
|
22 |
* @param {array} subedgeInfoList List of various edge information.
|
|
62 | 23 |
*/ |
63 |
this.render = function() { |
|
64 |
rootElement = DOM.createHtmlElement('div', { |
|
65 |
'class': 'popover edge-popover hidden', |
|
66 |
}); |
|
67 |
rootElement.addEventListener('wheel', Utils.stopPropagation); |
|
68 |
rootElement.addEventListener('mousedown', Utils.stopPropagation); |
|
69 |
rootElement.addEventListener('mouseleave', this.close.bind(this)); |
|
24 |
set body(subedgeInfoList) { |
|
25 |
if (subedgeInfoList.length === 0) return; |
|
70 | 26 |
|
71 |
var popoverTitle = DOM.createHtmlElement('span', { |
|
72 |
'class': 'popover-title', |
|
73 |
}); |
|
74 |
popoverTitle.appendChild(document.createTextNode('Edge details')); |
|
75 |
rootElement.appendChild(popoverTitle); |
|
27 |
subedgeInfoList.filter(subedgeInfo => { |
|
28 |
return subedgeInfo.attributes.length > 0; |
|
29 |
}).forEach(subedgeInfo => { |
|
30 |
const sublistElement = DOM.h('ul'); |
|
31 |
subedgeInfo.attributes.forEach(attribute => { |
|
32 |
sublistElement.appendChild(new Attribute(attribute).render()); |
|
33 |
}); |
|
76 | 34 |
|
77 |
var popoverContent = DOM.createHtmlElement('div', { |
|
78 |
'class': 'popover-content', |
|
35 |
this._detailsListElement.appendChild(DOM.h('li', { |
|
36 |
innerText: app.archetype.edge[subedgeInfo.archetype].name, |
|
37 |
}, [ |
|
38 |
sublistElement, |
|
39 |
])); |
|
79 | 40 |
}); |
80 |
rootElement.appendChild(popoverContent); |
|
81 |
|
|
82 |
detailsListElement = DOM.createHtmlElement('ul'); |
|
83 |
popoverContent.appendChild(detailsListElement); |
|
84 |
|
|
85 |
return rootElement; |
|
86 |
}; |
|
87 |
|
|
41 |
} |
|
88 | 42 |
} |
sources/src/main/webapp/js/components/vertex.js | ||
---|---|---|
731 | 731 |
function archetypeClick(e) { |
732 | 732 |
e.stopPropagation(); |
733 | 733 |
|
734 |
app.viewportComponent.vertexPopoverComponent.setContent(this.name + ` (${app.archetype.vertex[this.archetype].name})`, props.attributes); |
|
735 |
app.viewportComponent.vertexPopoverComponent.setPosition(new Coordinates(e.clientX, e.clientY)); |
|
734 |
app.viewportComponent.vertexPopoverComponent.title = this.name + ` (${app.archetype.vertex[this.archetype].name})`; |
|
735 |
app.viewportComponent.vertexPopoverComponent.body = props.attributes; |
|
736 |
app.viewportComponent.vertexPopoverComponent.position = new Coordinates(e.clientX, e.clientY); |
|
736 | 737 |
app.viewportComponent.vertexPopoverComponent.open(); |
737 | 738 |
} |
738 | 739 |
|
sources/src/main/webapp/js/components/vertexPopover.js | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Class representing a popover revealed on vertex interface symbol click to display its attributes. |
3 | 3 |
* @see Vertex |
4 |
* @constructor |
|
5 | 4 |
*/ |
6 |
function VertexPopover() { |
|
7 |
var rootElement; |
|
8 |
var popoverTitle; |
|
9 |
var detailsListElement; |
|
10 |
|
|
5 |
class VertexPopover extends Popover { |
|
11 | 6 |
/** |
12 |
* Sets the contents of the popover. |
|
13 |
* @param {string} name Title of the popover. |
|
14 |
* @param {array} attributeList List of attributes. |
|
7 |
* @inheritdoc |
|
15 | 8 |
*/ |
16 |
this.setContent = function(name, attributeList) { |
|
17 |
popoverTitle.innerText = name; |
|
18 |
|
|
19 |
if (attributeList.length === 0) return; |
|
20 |
|
|
21 |
attributeList.forEach(function(attribute) { |
|
22 |
detailsListElement.appendChild(new Attribute(attribute).render()); |
|
23 |
}); |
|
24 |
}; |
|
9 |
render() { |
|
10 |
super.render(); |
|
25 | 11 |
|
26 |
/** |
|
27 |
* Moves the popover to the coordinates. |
|
28 |
* @param {Coordinates} coords Coordinates to display the popover at. |
|
29 |
*/ |
|
30 |
this.setPosition = function(coords) { |
|
31 |
rootElement.style.top = coords.y + 'px'; |
|
32 |
rootElement.style.left = coords.x + 'px'; |
|
33 |
}; |
|
12 |
this._detailsListElement = DOM.h('ul'); |
|
13 |
this._bodyElement.appendChild(this._detailsListElement); |
|
34 | 14 |
|
35 |
/** |
|
36 |
* Opens the popover. |
|
37 |
*/ |
|
38 |
this.open = function() { |
|
39 |
rootElement.classList.remove('hidden'); |
|
40 |
}; |
|
15 |
return this._rootElement; |
|
16 |
} |
|
41 | 17 |
|
42 | 18 |
/** |
43 |
* Closes the popover. |
|
19 |
* Sets the title of the popover. |
|
20 |
* @public |
|
21 |
* @param {array} attributeList List of attributes. |
|
44 | 22 |
*/ |
45 |
this.close = function() { |
|
46 |
rootElement.classList.add('hidden'); |
|
47 |
|
|
48 |
detailsListElement.innerHTML = ''; |
|
49 |
}; |
|
23 |
set title(name) { |
|
24 |
this._titleElement.innerText = name; |
|
25 |
} |
|
50 | 26 |
|
51 | 27 |
/** |
52 |
* Creates a new DOM element representing the popover in memory. Binds user interactions to local handler functions. |
|
53 |
* @returns {Element} HTML DOM element. |
|
28 |
* Sets the body of the popover. |
|
29 |
* @public |
|
30 |
* @param {array} attributeList List of attributes. |
|
54 | 31 |
*/ |
55 |
this.render = function() { |
|
56 |
rootElement = DOM.createHtmlElement('div', { |
|
57 |
'class': 'popover vertex-popover hidden', |
|
58 |
}); |
|
59 |
rootElement.addEventListener('wheel', Utils.stopPropagation); |
|
60 |
rootElement.addEventListener('mousedown', Utils.stopPropagation); |
|
61 |
rootElement.addEventListener('mouseleave', this.close.bind(this)); |
|
62 |
|
|
63 |
popoverTitle = DOM.createHtmlElement('span', { |
|
64 |
'class': 'popover-title', |
|
65 |
}); |
|
66 |
rootElement.appendChild(popoverTitle); |
|
32 |
set body(attributeList) { |
|
33 |
if (attributeList.length === 0) return; |
|
67 | 34 |
|
68 |
var popoverContent = DOM.createHtmlElement('div', {
|
|
69 |
'class': 'popover-content',
|
|
35 |
attributeList.forEach(attribute => {
|
|
36 |
this._detailsListElement.appendChild(new Attribute(attribute).render());
|
|
70 | 37 |
}); |
71 |
rootElement.appendChild(popoverContent); |
|
72 |
|
|
73 |
detailsListElement = DOM.createHtmlElement('ul'); |
|
74 |
popoverContent.appendChild(detailsListElement); |
|
75 |
|
|
76 |
return rootElement; |
|
77 |
}; |
|
78 |
} |
|
38 |
} |
|
39 |
} |
Také k dispozici: Unified diff
reworked EdgePopover and VertexPopover to extend newly created Popover JS class