commit 20260703
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Nav submenu iconfont helpers.
|
||||
* Registry: data/nav-icon-registry.json
|
||||
*
|
||||
* After uploading new glyphs to iconfont.cn and replacing iconfont.css:
|
||||
* window.aifoApplyNavIconTargets()
|
||||
* This swaps data-nav-icon-target classes onto each submenu icon.
|
||||
*/
|
||||
(function () {
|
||||
function applyNavIconTargets(root) {
|
||||
if (!root) return 0;
|
||||
var nodes = root.querySelectorAll("[data-nav-icon-target]");
|
||||
var count = 0;
|
||||
nodes.forEach(function (el) {
|
||||
var target = el.getAttribute("data-nav-icon-target");
|
||||
if (!target) return;
|
||||
el.className = "icon iconfont " + target;
|
||||
count += 1;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
window.aifoApplyNavIconTargets = function () {
|
||||
var nav = document.getElementById("nav");
|
||||
var container = document.getElementById("nav-container");
|
||||
var count = applyNavIconTargets(nav) + applyNavIconTargets(container);
|
||||
console.info("[nav-icons] Applied " + count + " target icon class(es).");
|
||||
return count;
|
||||
};
|
||||
|
||||
document.addEventListener("aifo:layout-ready", function () {
|
||||
if (window.AIFO_NAV_USE_TARGET_ICONS === true) {
|
||||
window.aifoApplyNavIconTargets();
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user