UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

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