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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { InfoGroup } from "./info-group.mjs";
import { AboutCertificateItems } from "./about-certificate-items.mjs";
export class InfoGroupContainer extends HTMLElement {
constructor(isAboutCertificate = false) {
super();
this.infoGroupsContainers = [];
this.isAboutCertificate = isAboutCertificate;
}
connectedCallback() {
let infoGroupContainerTemplate = document.getElementById(
"info-groups-template"
);
this.attachShadow({ mode: "open" }).appendChild(
infoGroupContainerTemplate.content.cloneNode(true)
);
this.render();
}
render() {}
createInfoGroupsContainers(certArray, i, final, certData = []) {
this.infoGroupsContainers[i] = document.createElement("div");
this.infoGroupsContainers[i].setAttribute("id", "panel" + i);
this.infoGroupsContainers[i].setAttribute("role", "tabpanel");
this.infoGroupsContainers[i].setAttribute("tabindex", 0);
this.infoGroupsContainers[i].setAttribute("aria-labelledby", "tab" + i);
// Hiding all the certificzte contents except for the first tab that is
// selected and shown by default
if (i !== 0) {
this.infoGroupsContainers[i].hidden = true;
}
this.infoGroupsContainers[i].classList.add("info-groups");
if (this.isAboutCertificate) {
this.infoGroupsContainers[i].appendChild(
new AboutCertificateItems(certData.name, certData.data)
);
} else {
for (let j = 0; j < certArray.length; j++) {
this.infoGroupsContainers[i].appendChild(
new InfoGroup(certArray[j], final)
);
}
}
}
addClass(className, index) {
this.infoGroupsContainers[index].classList.add(className);
}
updateCertificateSource(index) {
for (let i = 0; i < this.infoGroupsContainers.length; i++) {
this.infoGroupsContainers[i].classList.remove("selected");
}
this.infoGroupsContainers[index].classList.add("selected");
}
}
customElements.define("info-group-container", InfoGroupContainer);
|