@n8d/htwoo-core
Version:
hTWOo is a Fluent Design Framework purely in HTML and CSS
2 lines (1 loc) • 801 B
JavaScript
!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",n="is-active",i=t=>{t.preventDefault();const i=t.target;let c;if(console.log(i),c=i.classList.contains(o.substr(1))?i:i.closest(o),c||(c=i.classList.contains(s.substr(1))?i:i.closest(s)),!c)return;const l=i.closest(e);if(!l)return;l.querySelectorAll(o).forEach((t=>{t.classList.remove(n)})),c.classList.add(n)};t.initPivot=()=>{document.querySelectorAll(`${e} ${o}`).forEach((t=>{const e=t;e.dataset.ref=e.textContent?.trim()||"",e.addEventListener("click",i)}))}}));