UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

1 lines 1.96 kB
!/*! License details at fancyapps.com/license */function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).window=e.window||{})}(this,function(e){"use strict";let t=function(e){var t=new DOMParser().parseFromString(e,"text/html").body;if(t.childElementCount>1){for(var n=document.createElement("div");t.firstChild;)n.appendChild(t.firstChild);return n}let o=t.firstChild;if(o&&!(o instanceof HTMLElement)){var n=document.createElement("div");return n.appendChild(o),n}return o},n={prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"></path></svg>',nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"></path></svg>'};e.Arrows=()=>{let e,o,r;function i(o){if(!e)return;let r=`<button data-carousel-go-${o} tabindex="0" class="f-button is-arrow is-${o}" title="{{${o.toUpperCase()}}}">`+function(){let t=e?.getOptions().Arrows;return"object"==typeof t&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t)?{...n,...t}:n}()[`${o}Tpl`]+"</button";return t(e.localize(r))||void 0}function s(){o?.remove(),o=void 0,r?.remove(),r=void 0,e?.getContainer()?.classList.remove("has-arrows")}function a(){e&&!1!==e.getOptions().Arrows&&e.getPages().length>1?(!function(){if(!e)return;let t=e.getViewport();t&&(!o&&(o=i("prev"))&&t.insertAdjacentElement("beforebegin",o),!r&&(r=i("next"))&&t.insertAdjacentElement("afterend",r),((e,t="",n)=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.toggle(t,n||!1)})})(e.getContainer(),"has-arrows",!!(o||r)))}(),e&&(o?.toggleAttribute("aria-disabled",!e.canGoPrev()),r?.toggleAttribute("aria-disabled",!e.canGoNext()))):s()}return{init:function(t){e=t.on(["change","refresh"],a)},destroy:function(){s(),e?.off(["change","refresh"],a),e=void 0}}}});