-
Notifications
You must be signed in to change notification settings - Fork 2
/
chart-remove.html
71 lines (60 loc) · 2.66 KB
/
chart-remove.html
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
<!-- External Polymer Styles/elements dependency -->
<link rel="import" href="bower_components/iron-icons/iron-icons.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<!-- Epiviz element dependency -->
<script>
/**
* `ChartRemoveBehavior` object manages the `<epiviz-chart-remove>` element for each chart.
* All charts inherit this behavior to remove itself from DOM.
*
* @polymerBehavior
**/
EpivizChartRemoveBehavior = function (superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() {
return {};
}
/**
* Shows the remove element
*/
_showRemoveDialog() {
var self = this;
if (self._parentContainer) {
self._parentContainer.removeChild(self);
let navChildren =
Polymer.FlattenedNodesObserver.getFlattenedNodes(self._parentContainer).filter(n => n.nodeType === Node.ELEMENT_NODE)
for (var nindex = 0; nindex < navChildren.length; nindex++) {
var child = navChildren[nindex];
if (child.plotId == self.plotId) {
this.shadowRoot.querySelector(child).remove();
this.shadowRoot.querySelector("[plot-id=" + self.plotId + "]").remove();
}
}
}
else {
this.shadowRoot.querySelector(self.root).remove();
this.shadowRoot.querySelector("[plot-id=" + self.plotId + "]").remove();
}
}
/**
* Initializes the `<epiviz-chart-remove>` element
*/
_initializeRemoveDialog() {
var chartSettingsContainer = this.shadowRoot.querySelector('#chartSettingsContainer');
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currSettingIcon = this.shadowRoot.querySelector('#chartRemoveIcon');
if (currSettingIcon == null) {
var iconElem = document.createElement('paper-icon-button');
iconElem.id = "chartRemoveIcon";
iconElem.icon = "icons:remove-circle";
iconElem.title = "remove chart";
iconElem.addEventListener("click", this._showRemoveDialog.bind(this));
chartSettingsContainer.appendChild(iconElem);
}
}
}
}
</script>