Skip to content

Commit 4bcb8b5

Browse files
Update index.js
1 parent 0212883 commit 4bcb8b5

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

icons/index.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
if (typeof SurveyCreatorCore !== "undefined") {
2-
new SurveyCreatorCore.SurveyCreatorModel({}); // Register Survey Creator icons
3-
}
4-
5-
function renderIcons() {
6-
let iconsDiv = document.createElement("div");
7-
iconsDiv.id = "sv-icon-holder-global-container";
8-
iconsDiv.innerHTML = "<svg>" + Survey.SvgRegistry.iconsRenderedHtml() + "</svg>";
9-
iconsDiv.style.display = "none";
10-
document.head.appendChild(iconsDiv);
11-
}
12-
renderIcons();
13-
14-
Object.keys(Survey.SvgRegistry.icons).map(name => {
15-
if (name.indexOf("pg-v1") > -1) return;
16-
const element = document.createElement("div");
17-
element.classList.add("container")
18-
element.innerHTML = `
19-
<svg>
20-
<use xlink:href="#icon-` + name + `\"></use>
21-
</svg>
22-
<span class="icon-name">icon-` + name + `</span>`;
23-
document.getElementById("icons").appendChild(element);
1+
document.addEventListener("DOMContentLoaded", (event) => {
2+
if (typeof SurveyCreatorCore !== "undefined") {
3+
new SurveyCreatorCore.SurveyCreatorModel({}); // Register Survey Creator icons
4+
}
5+
6+
function renderIcons() {
7+
let iconsDiv = document.createElement("div");
8+
iconsDiv.id = "sv-icon-holder-global-container";
9+
iconsDiv.innerHTML = "<svg>" + Survey.SvgRegistry.iconsRenderedHtml() + "</svg>";
10+
iconsDiv.style.display = "none";
11+
document.head.appendChild(iconsDiv);
12+
}
13+
renderIcons();
14+
15+
Object.keys(Survey.SvgRegistry.icons).map(name => {
16+
if (name.indexOf("pg-v1") > -1) return;
17+
const element = document.createElement("div");
18+
element.classList.add("container")
19+
element.innerHTML = `
20+
<svg>
21+
<use xlink:href="#icon-` + name + `\"></use>
22+
</svg>
23+
<span class="icon-name">icon-` + name + `</span>`;
24+
document.getElementById("icons").appendChild(element);
25+
});
2426
});

0 commit comments

Comments
 (0)