UNPKG

@n8d/htwoo-core

Version:

hTWOo is a Fluent Design Framework purely in HTML and CSS

2 lines (1 loc) 787 B
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).htwoo=t.htwoo||{},t.htwoo.pivot={}))}(this,(function(t){"use strict";const e=".hoo-pivotbar",o=".hoo-button-pivot",s=".hoo-navitem-text",i="is-active",n=t=>{t.preventDefault(),console.log(t.target);let n=t.target.classList.contains(o.substr(1))?t.target:t.target.closest(o);n||(n=t.target.classList.contains(s.substr(1))?t.target:t.target.closest(s));t.target.closest(e).querySelectorAll(o).forEach((t=>{t.classList.remove(i)})),n.classList.add(i)};t.initPivot=()=>{document.querySelectorAll(`${e} ${o}`).forEach((t=>{t.dataset.ref=t.textContent.trim(),t.addEventListener("click",n)}))}}));