wishthis/node_modules/fomantic-ui/dist/components/flyout.min.js

11 lines
22 KiB
JavaScript
Raw Normal View History

2022-09-30 13:48:25 +00:00
/*
2023-08-17 09:47:40 +00:00
* # Fomantic UI - 2.9.2
2022-09-30 13:48:25 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-09-30 13:48:25 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-09-30 13:48:25 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-09-30 13:48:25 +00:00
*
*/
2023-08-17 09:47:40 +00:00
!function(Q,W,U){"use strict";function X(e){return"function"==typeof e&&"number"!=typeof e.nodeType}W=void 0!==W&&W.Math===Math?W:globalThis,Q.fn.flyout=function(M){var O,e=Q(this),D=Q(W),N=Q(U),L=Q("html"),B=Q("head"),z=Q("body"),I=e.selector||"",j=Date.now(),R=[],q=M,K="string"==typeof q,V=[].slice.call(arguments,1);return e.each(function(){var n,e,o,s,t,i,r,a=Q.isPlainObject(M)?Q.extend(!0,{},Q.fn.flyout.settings,M):Q.extend({},Q.fn.flyout.settings),l=a.selector,c=a.className,u=a.namespace,d=a.fields,f=a.regExp,h=a.error,g="."+u,p="module-"+u,v=Q(this),b=[W,U].indexOf(a.context)<0?N.find(a.context):z,m=v.find(l.close),y=v.children(l.flyout),k=b.children(l.pusher),x=v.hasClass("flyout"),S=this,A=x?v.data(p):void 0,C=!1,w=b[0]===z[0],T="",F="",H=!1,P=!1,E={initialize:function(){var s;E.debug("Initializing flyout",M),E.create.id(),x||(E.create.flyout(),X(a.onHidden)||(a.onHidden=function(){E.destroy(),v.remove()}),a.autoShow||(a.autoShow=!0)),v.addClass(a.class),""!==a.title&&v.find(l.header).html(E.helpers.escape(a.title,a.preserveHTML)).addClass(a.classTitle),""!==a.content&&v.find(l.content).html(E.helpers.escape(a.content,a.preserveHTML)).addClass(a.classContent),E.has.configActions()&&(0===(s=v.find(l.actions).addClass(a.classActions)).length?s=Q("<div/>",{class:c.actions+" "+(a.classActions||"")}).appendTo(v):s.empty(),a.actions.forEach(function(e){var t=e[d.icon]?"<i "+(e[d.text]?'aria-hidden="true"':"")+' class="'+E.helpers.deQuote(e[d.icon])+' icon"></i>':"",n=E.helpers.escape(e[d.text]||"",a.preserveHTML),i=E.helpers.deQuote(e[d.class]||""),o=e[d.click]&&X(e[d.click])?e[d.click]:function(){};s.append(Q("<button/>",{html:t+n,"aria-label":(e[d.text]||e[d.icon]||"").replace(/<[^>]+(>|$)/g,""),class:c.button+" "+i,on:{click:function(){!1!==o.call(S,v)&&E.hide()}}}))})),a.delaySetup?requestAnimationFrame(E.setup.layout):E.setup.layout(),requestAnimationFrame(function(){E.setup.cache()}),"left"!==E.get.direction()&&"right"!==E.get.direction()||(E.setup.heights(),E.bind.resize()),E.bind.events(),E.observeChanges(),E.instantiate(),a.autoShow&&E.show()},instantiate:function(){E.verbose("Storing instance of module",E),A=E,v.data(p,A)},create:{flyout:function(){var e;E.verbose("Programmaticaly create flyout",b),v=Q("<div/>",{class:c.flyout,role:"dialog","aria-modal":a.dimPage}),a.closeIcon&&(m=Q("<i/>",{class:c.close,role:"button",tabindex:0,"aria-label":a.text.close}),v.append(m)),""!==a.title&&(e="_"+E.get.id()+"title",v.attr("aria-labelledby",e),Q("<div/>",{class:c.header,id:e}).appendTo(v)),""!==a.content&&(e="_"+E.get.id()+"desc",v.attr("aria-describedby",e),Q("<div/>",{class:c.content,id:e}).appendTo(v)),E.has.configActions()&&Q("<div/>",{class:c.actions}).appendTo(v),v.prependTo(b),S=v[0]},id:function(){t=(Math.random().toString(16)+"000000000").slice(2,10),s="."+t,E.verbose("Creating unique id for element",t)}},destroy:function(){i&&i.disconnect(),E.verbose("Destroying previous module for",v),v.off(g).removeData(p),E.is.ios()&&E.remove.ios(),m.off(s),n&&n.off(s),b.off(s),D.off(s),N.off(s)},event:{keyboard:function(e){e.which===a.keys.escape&&(a.closable?(E.debug("Escape key pressed hiding flyout"),E.hide()):E.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){E.setup.heights()},focus:function(){E.is.visible()&&a.autofocus&&a.dimPage&&requestAnimationFrame(E.set.autofocus)},clickaway:function(e){var t;a.closable&&(t=0<k.find(e.target).length||k.is(e.target),e=b.is(e.target),t&&(E.verbose("User clicked on dimmed page"),E.hide()),e&&(E.verbose("User clicked on dimmable context (scaled out page)"),E.hide()))},close:function(e){E.hide()},closeKeyUp:function(e){e=e.which;e!==a.keys.enter&&e!==a.keys.space||E.hide()},inputKeyDown:{first:function(e){e.which===a.keys.tab&&e.shiftKey&&(n.last().trigger("focus"),e.preventDefault())},last:function(e){e.which!==a.keys.tab||e.shiftKey||(n.first().trigger("focus"),e.preventDefault())}},approve:function(e){C||!1===a.onApprove.call(E.element,Q(this))?E.verbose("Approve callback returned false cancelling close"):(C=!0,E.hide(function()