36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
#include utility.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-toggles-' + baseId,
|
|
classList: ['sidebar__selector-mode', 'sidebar__selector-mode--' + baseId],
|
|
title: title,
|
|
},
|
|
});
|
|
|
|
for(const i in eventHandlers)
|
|
toggle.addEventListener(i, eventHandlers[i]);
|
|
|
|
const toggles = $i('umi-toggles');
|
|
toggles.insertBefore(toggle, toggles.firstChild);
|
|
}
|
|
},
|
|
Get: function(baseId, icon) {
|
|
const id = 'umi-toggles-' + baseId;
|
|
if(ids.indexOf(baseId) >= 0)
|
|
return $i(id);
|
|
return null;
|
|
},
|
|
Remove: function(baseId) {
|
|
$ri('umi-toggles-' + baseId);
|
|
},
|
|
};
|
|
})();
|