3 if (!window.dbx) return;
4 const dbx = window.dbx;
6 function init(el, cfg) {
8 // --------------------------------------------
9 // Sprite laden (einmal global)
10 // --------------------------------------------
11 if (!window._dbxIconSpriteLoaded) {
13 const spritePath = dbx.config.rootPath + 'design/' + dbx.config.design + '/icons/sprite.svg';
15 dbx.log("icons → load sprite:", spritePath);
17 if (!dbx.ajax || typeof dbx.ajax.request !== 'function') {
18 dbx.error("icons → ajax.js not loaded");
30 const div = document.createElement('div');
31 div.style.display = 'none';
34 document.body.prepend(div);
36 window._dbxIconSpriteLoaded = true;
38 dbx.log("icons → sprite loaded");
43 dbx.error("icons → sprite load failed:", err);
51 function renderIcons(el) {
53 $(el).find('.dbx-icon').each(function () {
55 const icon = this.getAttribute('data-icon');
58 const size = this.getAttribute('data-size');
59 const color = this.getAttribute('data-color');
62 const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
63 svg.classList.add('dbx-icon');
67 svg.classList.add('dbx-icon-' + size);
72 svg.style.color = color;
76 const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
77 use.setAttribute('href', '#' + icon);
82 this.replaceWith(svg);
86 // --------------------------------------------
87 // FEATURE REGISTER (WICHTIG!)
88 // --------------------------------------------
89 dbx.feature.register("icons", {
91 scope: "element", // 🔥 FIX
94 ['css', 'design', 'c-icons.css']
98 ['js', 'lib', 'ajax.js']