Bilibili-Evolved/min/custom-navbar-component.min.js
2020-01-10 20:05:14 +08:00

1 line
1.4 KiB
JavaScript

(()=>{return(t,e)=>{class s{constructor(e="",s="",n="0 0 auto",i=false,a=false,o=null,l=null,r=null,c=0,u=t.touchNavBar,d=false){this.html=e;this.popupHtml=s;this.flex=n;this.disabled=i;this.requestedPopup=a;this.initialPopup=o;this.onPopup=l;this.href=r;this.notifyCount=c;this.touch=u;this.active=d;this.noPadding=false;this.transparent=false}get name(){return"blank1"}get order(){return t.customNavbarOrder[this.name]}get hidden(){return t.customNavbarHidden.includes(this.name)}get element(){return dq(`.custom-navbar li[data-name='${this.name}']`)}async setNotifyCount(t){const e=await SpinQuery.select(`.custom-navbar li[data-name='${this.name}'] .notify-count`);if(!e||!t){e.innerHTML="";return}e.innerHTML=t.toString()}async setNotifyStyle(t){const e=await SpinQuery.select(`.custom-navbar li[data-name='${this.name}'] .notify-count`);if(!e){return}const s={1:"number",2:"dot",3:"hidden"};e.classList.remove(...Object.values(s));e.classList.add(s[t])}async checkPosition(){const t=this.element;const e=t.querySelector(".main-content ~ .popup");if(e){console.log(e,e.childElementCount)}if(!e||e.childElementCount===0){return}const s=e.getBoundingClientRect();console.log(this.name,s);const n=document.documentElement.clientWidth;if(s.left<0){t.classList.remove("right-side");t.classList.add("left-side")}else if(s.right>n){t.classList.remove("left-side");t.classList.add("right-side")}else{t.classList.remove("left-side","right-side")}}}return{export:{NavbarComponent:s}}}})();