@fancyapps/ui
Version:
Robust JavaScript UI Component Library
1 lines • 1.57 kB
JavaScript
!/*! 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=t=>"object"==typeof t&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t),n={btnTpl:'<button data-expand-action="toggle" class="f-button" title="{{TOGGLE_EXPAND}}"><svg><g><path d="M14.5 9.5 21 3m0 0h-6m6 0v6M3 21l6.5-6.5M3 21v-6m0 6h6"/></g><g><path d="m14 10 7-7m-7 7h6m-6 0V4M3 21l7-7m0 0v6m0-6H4"/></g></svg></button>'},o="in-expanded-mode",i="with-expanded-carousel";t.Expand=()=>{let t;function d(o){let i=t?.getOptions().Expand,d=(e(i)?{...n,...i}:n)[o];return d&&"function"==typeof d&&t?d(t):d}function c(){t?.getPlugins().Toolbar?.add("expand",{tpl:d("btnTpl")})}function l(t,e){let n=e.target;n&&!e.defaultPrevented&&"toggle"===n.dataset.expandAction&&u()}function s(t){"Escape"!==t.key||t.defaultPrevented||u()}function u(){let e=d("el")||t?.getContainer();e&&(e.classList.toggle(o),e.classList.contains(o)?(document.documentElement.classList.add(i),document.addEventListener("keydown",s,!0)):(document.documentElement.classList.remove(i),document.removeEventListener("keydown",s,!0)))}return{init:function(e){(t=e).on("initPlugins",c),t.on("click",l)},destroy:function(){t?.off("initPlugins",c),t?.off("click",l),t=void 0,document.documentElement.classList.remove(i),document.removeEventListener("keydown",s,!0)},toggle:u}}});