芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/media.9/vendor/bootstrap/js/scrollspy.min.js
import{B as BaseComponent,E as EventHandler,S as SelectorEngine,e as getSelectorFromElement,M as Manipulator,j as isElement,o as getUID,a as typeCheckConfig,d as defineJQueryPlugin}from"./dom.min.js?1629745661";const NAME="scrollspy",DATA_KEY="bs.scrollspy",EVENT_KEY=`.${DATA_KEY}`,DATA_API_KEY=".data-api",Default={offset:10,method:"auto",target:""},DefaultType={offset:"number",method:"string",target:"(string|element)"},EVENT_ACTIVATE=`activate${EVENT_KEY}`,EVENT_SCROLL=`scroll${EVENT_KEY}`,EVENT_LOAD_DATA_API=`load${EVENT_KEY}.data-api`,CLASS_NAME_DROPDOWN_ITEM="dropdown-item",CLASS_NAME_ACTIVE="active",SELECTOR_DATA_SPY='[data-bs-spy="scroll"]',SELECTOR_NAV_LIST_GROUP=".nav, .list-group",SELECTOR_NAV_LINKS=".nav-link",SELECTOR_NAV_ITEMS=".nav-item",SELECTOR_LIST_ITEMS=".list-group-item",SELECTOR_DROPDOWN=".dropdown",SELECTOR_DROPDOWN_TOGGLE=".dropdown-toggle",METHOD_OFFSET="offset",METHOD_POSITION="position";class ScrollSpy extends BaseComponent{constructor(t,e){super(t),this._scrollElement="BODY"===this._element.tagName?window:this._element,this._config=this._getConfig(e),this._selector=`${this._config.target} .nav-link, ${this._config.target} .list-group-item, ${this._config.target} .dropdown-item`,this._offsets=[],this._targets=[],this._activeTarget=null,this._scrollHeight=0,EventHandler.on(this._scrollElement,EVENT_SCROLL,(()=>this._process())),this.refresh(),this._process()}static get Default(){return Default}static get NAME(){return NAME}refresh(){const t=this._scrollElement===this._scrollElement.window?"offset":"position",e="auto"===this._config.method?t:this._config.method,s="position"===e?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight();SelectorEngine.find(this._selector).map((t=>{const o=getSelectorFromElement(t),i=o?SelectorEngine.findOne(o):null;if(i){const t=i.getBoundingClientRect();if(t.width||t.height)return[Manipulator[e](i).top+s,o]}return null})).filter((t=>t)).sort(((t,e)=>t[0]-e[0])).forEach((t=>{this._offsets.push(t[0]),this._targets.push(t[1])}))}dispose(){EventHandler.off(this._scrollElement,EVENT_KEY),super.dispose()}_getConfig(t){if("string"!=typeof(t={...Default,...Manipulator.getDataAttributes(this._element),..."object"==typeof t&&t?t:{}}).target&&isElement(t.target)){let{id:e}=t.target;e||(e=getUID(NAME),t.target.id=e),t.target=`#${e}`}return typeCheckConfig(NAME,t,DefaultType),t}_getScrollTop(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop}_getScrollHeight(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}_getOffsetHeight(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height}_process(){const t=this._getScrollTop()+this._config.offset,e=this._getScrollHeight(),s=this._config.offset+e-this._getOffsetHeight();if(this._scrollHeight!==e&&this.refresh(),t>=s){const t=this._targets[this._targets.length-1];this._activeTarget!==t&&this._activate(t)}else{if(this._activeTarget&&t
0)return this._activeTarget=null,void this._clear();for(let e=this._offsets.length;e--;){this._activeTarget!==this._targets[e]&&t>=this._offsets[e]&&(void 0===this._offsets[e+1]||t
`${e}[data-bs-target="${t}"],${e}[href="${t}"]`)),s=SelectorEngine.findOne(e.join(","));s.classList.contains("dropdown-item")?(SelectorEngine.findOne(".dropdown-toggle",s.closest(".dropdown")).classList.add("active"),s.classList.add("active")):(s.classList.add("active"),SelectorEngine.parents(s,".nav, .list-group").forEach((t=>{SelectorEngine.prev(t,".nav-link, .list-group-item").forEach((t=>t.classList.add("active"))),SelectorEngine.prev(t,".nav-item").forEach((t=>{SelectorEngine.children(t,".nav-link").forEach((t=>t.classList.add("active")))}))}))),EventHandler.trigger(this._scrollElement,EVENT_ACTIVATE,{relatedTarget:t})}_clear(){SelectorEngine.find(this._selector).filter((t=>t.classList.contains("active"))).forEach((t=>t.classList.remove("active")))}static jQueryInterface(t){return this.each((function(){const e=ScrollSpy.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}if(EventHandler.on(window,EVENT_LOAD_DATA_API,(()=>{SelectorEngine.find(SELECTOR_DATA_SPY).forEach((t=>new ScrollSpy(t)))})),defineJQueryPlugin(ScrollSpy),window.bootstrap=window.bootstrap||{},window.bootstrap.Scrollspy=ScrollSpy,Joomla&&Joomla.getOptions){const t=Joomla.getOptions("bootstrap.scrollspy");"object"==typeof t&&null!==t&&Object.keys(t).forEach((e=>{const s=t[e],o={offset:s.offset?s.offset:10,method:s.method?s.method:"auto"};s.target&&(o.target=s.target);const i=Array.from(document.querySelectorAll(e));i.length&&i.map((t=>new window.bootstrap.Scrollspy(t,o)))}))}export{ScrollSpy as S};