bootstrap/dist/js/bootstrap.esm.min.js

7 lines
68 KiB
JavaScript
Raw Permalink Normal View History

2019-03-11 23:13:30 +08:00
/*!
* Bootstrap v5.3.8 (https://getbootstrap.com/)
* Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2020-06-17 02:50:01 +08:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
2019-03-11 23:13:30 +08:00
*/
import*as Popper from"@popperjs/core";const elementMap=new Map,Data={set(e,t,i){elementMap.has(e)||elementMap.set(e,new Map);const n=elementMap.get(e);n.has(t)||0===n.size?n.set(t,i):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(n.keys())[0]}.`)},get:(e,t)=>elementMap.has(e)&&elementMap.get(e).get(t)||null,remove(e,t){if(!elementMap.has(e))return;const i=elementMap.get(e);i.delete(t),0===i.size&&elementMap.delete(e)}},namespaceRegex=/[^.]*(?=\..*)\.|.*/,stripNameRegex=/\..*/,stripUidRegex=/::\d+$/,eventRegistry={};let uidEvent=1;const customEvents={mouseenter:"mouseover",mouseleave:"mouseout"},nativeEvents=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function makeEventUid(e,t){return t&&`${t}::${uidEvent++}`||e.uidEvent||uidEvent++}function getElementEvents(e){const t=makeEventUid(e);return e.uidEvent=t,eventRegistry[t]=eventRegistry[t]||{},eventRegistry[t]}function bootstrapHandler(e,t){return function i(n){return hydrateObj(n,{delegateTarget:e}),i.oneOff&&EventHandler.off(e,n.type,t),t.apply(e,[n])}}function bootstrapDelegationHandler(e,t,i){return function n(s){const o=e.querySelectorAll(t);for(let{target:r}=s;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return hydrateObj(s,{delegateTarget:r}),n.oneOff&&EventHandler.off(e,s.type,t,i),i.apply(r,[s])}}function findHandler(e,t,i=null){return Object.values(e).find(e=>e.callable===t&&e.delegationSelector===i)}function normalizeParameters(e,t,i){const n="string"==typeof t,s=n?i:t||i;let o=getTypeEvent(e);return nativeEvents.has(o)||(o=e),[n,s,o]}function addHandler(e,t,i,n,s){if("string"!=typeof t||!e)return;let[o,r,a]=normalizeParameters(t,i,n);if(t in customEvents){const e=e=>function(t){if(!t.relatedTarget||t.relatedTarget!==t.delegateTarget&&!t.delegateTarget.contains(t.relatedTarget))return e.call(this,t)};r=e(r)}const l=getElementEvents(e),c=l[a]||(l[a]={}),_=findHandler(c,r,o?i:null);if(_)return void(_.oneOff=_.oneOff&&s);const E=makeEventUid(r,t.replace(namespaceRegex,"")),h=o?bootstrapDelegationHandler(e,i,r):bootstrapHandler(e,r);h.delegationSelector=o?i:null,h.callable=r,h.oneOff=s,h.uidEvent=E,c[E]=h,e.addEventListener(a,h,o)}function removeHandler(e,t,i,n,s){const o=findHandler(t[i],n,s);o&&(e.removeEventListener(i,o,Boolean(s)),delete t[i][o.uidEvent])}function removeNamespacedHandlers(e,t,i,n){const s=t[i]||{};for(const[o,r]of Object.entries(s))o.includes(n)&&removeHandler(e,t,i,r.callable,r.delegationSelector)}function getTypeEvent(e){return e=e.replace(stripNameRegex,""),customEvents[e]||e}const EventHandler={on(e,t,i,n){addHandler(e,t,i,n,!1)},one(e,t,i,n){addHandler(e,t,i,n,!0)},off(e,t,i,n){if("string"!=typeof t||!e)return;const[s,o,r]=normalizeParameters(t,i,n),a=r!==t,l=getElementEvents(e),c=l[r]||{},_=t.startsWith(".");if(void 0===o){if(_)for(const i of Object.keys(l))removeNamespacedHandlers(e,l,i,t.slice(1));for(const[i,n]of Object.entries(c)){const s=i.replace(stripUidRegex,"");a&&!t.includes(s)||removeHandler(e,l,r,n.callable,n.delegationSelector)}}else{if(!Object.keys(c).length)return;removeHandler(e,l,r,o,s?i:null)}},trigger(e,t,i){if("string"!=typeof t||!e)return null;const n=hydrateObj(new Event(t,{bubbles:!0,cancelable:!0}),i);return e.dispatchEvent(n),n}};function hydrateObj(e,t={}){for(const[i,n]of Object.entries(t))try{e[i]=n}catch(t){Object.defineProperty(e,i,{configurable:!0,get:()=>n})}return e}function normalizeData(e){if("true"===e)return!0;if("false"===e)return!1;if(e===Number(e).toString())return Number(e);if(""===e||"null"===e)return null;if("string"!=typeof e)return e
2019-03-11 23:13:30 +08:00
//# sourceMappingURL=bootstrap.esm.min.js.map