JavaScript UI component library, includes the latest Fancybox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
65 KiB

1 year ago
const t=t=>"object"==typeof t&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t),e=(i,...s)=>{const n=s.length;for(let o=0;o<n;o++){const n=s[o]||{};Object.entries(n).forEach((([s,n])=>{const o=Array.isArray(n)?[]:{};i[s]||Object.assign(i,{[s]:o}),t(n)?Object.assign(i[s],e(o,n)):Array.isArray(n)?Object.assign(i,{[s]:[...n]}):Object.assign(i,{[s]:n})}))}return i},i=function(t,e){let i=!0;return(...s)=>{i&&(i=!1,t(...s),setTimeout((()=>{i=!0}),e))}},s=(t,e)=>{let i=[];return t.childNodes.forEach((t=>{t.nodeType!==Node.ELEMENT_NODE||e&&!t.matches(e)||i.push(t)})),i},n=function(t){return(new DOMParser).parseFromString(t,"text/html").body.firstChild},o=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),a=t=>`${t||""}`.split(" ").filter((t=>!!t)),r=(t,e)=>{a(e).forEach((e=>{t&&t.classList.add(e)}))},h=(t,e)=>{a(e).forEach((e=>{t&&t.classList.remove(e)}))},l=(t,e,i)=>{a(e).forEach((e=>{t&&t.classList.toggle(e,i||!1)}))},c='<div class="f-spinner"><svg viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle><circle cx="25" cy="25" r="20"></circle></svg></div>',d=function(t,e){return t.split(".").reduce(((t,e)=>"object"==typeof t?t[e]:void 0),e)};class u{constructor(t={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(t);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith("on")&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}setOptions(t){this.options=t?e({},this.constructor.defaults,t):{};for(const[t,e]of Object.entries(this.option("on")||{}))this.on(t,e)}option(t,...e){let i=d(t,this.options);return i&&"function"==typeof i&&(i=i.call(this,this,...e)),i}optionFor(t,e,i,...s){let n=d(e,t);var o;"string"!=typeof(o=n)||isNaN(o)||isNaN(parseFloat(o))||(n=parseFloat(n)),"true"===n&&(n=!0),"false"===n&&(n=!1),n&&"function"==typeof n&&(n=n.call(this,this,t,...s));let a=d(e,this.options);return a&&"function"==typeof a?n=a.call(this,this,t,...s,n):void 0===n&&(n=a),void 0===n?i:n}cn(t){const e=this.options.classes;return e&&e[t]||""}localize(t,e=[]){t=String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,((t,e,i)=>{let s="";return i?s=this.option(`${e[0]+e.toLowerCase().substring(1)}.l10n.${i}`):e&&(s=this.option(`l10n.${e}`)),s||(s=t),s}));for(let i=0;i<e.length;i++)t=t.split(e[i][0]).join(e[i][1]);return t=t.replace(/\{\{(.*)\}\}/,((t,e)=>e))}on(t,e){let i=[];"string"==typeof t?i=t.split(" "):Array.isArray(t)&&(i=t),this.events||(this.events=new Map),i.forEach((t=>{let i=this.events.get(t);i||(this.events.set(t,[]),i=[]),i.includes(e)||i.push(e),this.events.set(t,i)}))}off(t,e){let i=[];"string"==typeof t?i=t.split(" "):Array.isArray(t)&&(i=t),i.forEach((t=>{const i=this.events.get(t);if(Array.isArray(i)){const t=i.indexOf(e);t>-1&&i.splice(t,1)}}))}emit(t,...e){[...this.events.get(t)||[]].forEach((t=>t(this,...e))),"*"!==t&&this.emit("*",t,...e)}}Object.defineProperty(u,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.2"}),Object.defineProperty(u,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class g extends u{constructor(t={}){super(t),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(t={}){const e=new Map;for(const[i,s]of Object.entries(t)){const t=this.option(i),n=this.plugins[i];n||!1===t?n&&!1===t&&(n.detach(),delete this.plugins[i]):e.set(i,new s(this,t||{}))}for(const[t,i]of e)this.plugins[t]=i,i.attach();this.emit("attachPlugins")}detachPlugins(){for(const t of Object.values(this.plugins))t.detach();return this.plugins={},this.emit("detachPlugins"),this}}const p=function(t,e){return!(!t||t===document.body||e&&t===e)&&(function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,i=window.getComputedStyle(t).overflowY,s=-1!==i.indexOf("hidden"),n=-1!==i.indexOf("visible");return e&&!s&&!n}(t)?t:p(t.parentElement,e))};class f{constructor(t){Object.definePrope