#include utility.js #include ui/elems.js Umi.UI.Toggles = (function() { const ids = []; return { Add: function(baseId, eventHandlers, title) { if(ids.indexOf(baseId) < 0) { ids.push(baseId); const toggle = $e({ attrs: { id: Umi.UI.Elements.Toggles.id + '-' + baseId, classList: ['sidebar__selector-mode', 'sidebar__selector-mode--' + baseId], title: title, }, }); for(const i in eventHandlers) toggle.addEventListener(i, eventHandlers[i]); Umi.UI.Elements.Toggles.insertBefore(toggle, Umi.UI.Elements.Toggles.firstChild); } }, Get: function(baseId, icon) { const id = Umi.UI.Elements.Toggles.id + '-' + baseId; if(ids.indexOf(baseId) >= 0) return $i(id); return null; }, Remove: function(baseId) { $ri(Umi.UI.Elements.Toggles.id + '-' + baseId); }, }; })();