UNPKG

basb-cli

Version:
3 lines (2 loc) 2.35 kB
import{s as t,i as e,e as s,a as i,p as n,b as a}from"../index.min.js";import{l as o,c,a as r}from"./echarts.min.js";import"../libs/resolve-pathname/index.js";const l=document.querySelector("article");let d=0;function h(e){return function(){e();const s=function(){const t=getComputedStyle(document.documentElement).fontSize;return Number.parseInt(t)}()+d+"px";l.style.fontSize=s,t(s)}}const m=h((()=>d+=1)),u=h((()=>d-=1)),b=(t,e)=>s("button",s("img","",{src:`./dist/imgs/fab-${t}.svg`,loading:"lazy",onerror(){this.src="./dist/imgs/broken-image.svg"}}),{title:e});class g extends HTMLElement{#t=null;#e={};constructor(){super(),this.style.opacity=String(0),e("./dist/chunks/fab.min.css").then((()=>this.style.opacity=String(1)));const t=this.#t=b("switch",o("切换浮动操作按钮","Switch The FAB"));this.#e.backToParent=b("back-to-parent",o("返回父级","Back to Parent")),this.#e.backToTop=b("back-to-top",o("返回顶部","Back to Top")),this.#e.enlargeText=b("zoom-in",o("放大文本","Enlarge Text")),this.#e.downsizeText=b("zoom-out",o("缩小文本","Downsize Text")),i(c.catalog)&&(this.#e.catalogSwitcher=b("catalog",o("开启/关闭菜单","Open/Close Catalog")));const s=c.fab.buttons.map((t=>this.#e[t])).filter((t=>void 0!==t));for(const[t,e]of Object.entries(s))e.style.setProperty("--fab-item-index",Number(t)+1);t.id="switcher",this.classList.add("hidden"),this.classList.add("unseen"),this.#s(),this.style.setProperty("--fab-item-count",s.length+1);const n=document.createDocumentFragment();for(const e of[t].concat(s))n.appendChild(e);this.appendChild(n),this.toggleCallback()}toggleCallback(){const t=!this.classList.contains("hidden")?0:-1;for(const e of Object.values(this.#e))e.tabIndex=t}#s(){this.#t.addEventListener("click",(()=>{this.classList.remove("unseen"),this.classList.toggle("hidden"),this.toggleCallback()})),this.#e.backToParent.addEventListener("click",(()=>{n.jumpTo(n.parent())})),this.#e.backToTop.addEventListener("click",a),this.#e.enlargeText.addEventListener("click",m),this.#e.downsizeText.addEventListener("click",u),this.#e.catalogSwitcher.addEventListener("click",(()=>{r.emit("catalog-toggle")}));const t=()=>{const t=this.#e.catalogSwitcher,e=n.isIn.article();t.disabled=!e};window.addEventListener("hashchange",t),t()}}customElements.define("fab-icon",g); //# sourceMappingURL=fab.min.js.map