wishthis/semantic/dist/components/popup.min.js

11 lines
19 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-02-23 21:46:34 +00:00
!function(N,V,W,z){"use strict";N.isFunction=N.isFunction||function(t){return"function"==typeof t&&"number"!=typeof t.nodeType},V=void 0!==V&&V.Math==Math?V:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),N.fn.popup=function(x){var E,t=N(this),k=N(W),S=N(V),A=N("body"),F=t.selector||"",D="ontouchstart"in W.documentElement?"touchstart":"click",O=(new Date).getTime(),j=[],R=x,M="string"==typeof R,H=[].slice.call(arguments,1);return t.each(function(){var l,s,e,t,o,u=N.isPlainObject(x)?N.extend(!0,{},N.fn.popup.settings,x):N.extend({},N.fn.popup.settings),n=u.selector,c=u.className,v=u.error,d=u.metadata,i=u.namespace,r="."+u.namespace,a="module-"+i,f=N(this),p=N(u.context),b=N(u.scrollContext),w=N(u.boundary),h=u.target?N(u.target):f,y=0,P=!1,C=!1,g=this,T=f.data(a),m={initialize:function(){m.debug("Initializing",f),m.createID(),m.bind.events(),!m.exists()&&u.preserve&&m.create(),u.observeChanges&&m.observeChanges(),m.instantiate()},instantiate:function(){m.verbose("Storing instance",m),T=m,f.data(a,T)},observeChanges:function(){"MutationObserver"in V&&((e=new MutationObserver(m.event.documentChanged)).observe(W,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",e))},refresh:function(){u.popup?l=N(u.popup).eq(0):u.inline&&(l=h.nextAll(n.popup).eq(0),u.popup=l),u.popup?(l.addClass(c.loading),s=m.get.offsetParent(),l.removeClass(c.loading),u.movePopup&&m.has.popup()&&m.get.offsetParent(l)[0]!==s[0]&&(m.debug("Moving popup to the same offset parent as target"),l.detach().appendTo(s))):s=u.inline?m.get.offsetParent(h):m.has.popup()?m.get.offsetParent(l):A,s.is("html")&&s[0]!==A[0]&&(m.debug("Setting page as offset parent"),s=A),m.get.variation()&&m.set.variation()},reposition:function(){m.refresh(),m.set.position()},destroy:function(){m.debug("Destroying previous module"),e&&e.disconnect(),l&&!u.preserve&&m.removePopup(),clearTimeout(m.hideTimer),clearTimeout(m.showTimer),m.unbind.close(),m.unbind.events(),f.removeData(a)},event:{start:function(t){var e=N.isPlainObject(u.delay)?u.delay.show:u.delay;clearTimeout(m.hideTimer),C&&!u.addTouchEvents||(m.showTimer=setTimeout(m.show,e))},end:function(){var t=N.isPlainObject(u.delay)?u.delay.hide:u.delay;clearTimeout(m.showTimer),m.hideTimer=setTimeout(m.hide,t)},touchstart:function(t){C=!0,u.addTouchEvents&&m.show()},resize:function(){m.is.visible()&&m.set.position()},documentChanged:function(t){[].forEach.call(t,function(t){t.removedNodes&&[].forEach.call(t.removedNodes,function(t){(t==g||0<N(t).find(g).length)&&(m.debug("Element removed from DOM, tearing down events"),m.destroy())})})},hideGracefully:function(t){var e=N(t.target),o=N.contains(W.documentElement,t.target),e=0<e.closest(n.popup).length;t&&!e&&o?(m.debug("Click occurred outside popup hiding popup"),m.hide()):m.debug("Click was inside popup, keeping popup open")}},create:function(){var t=m.get.html(),e=m.get.title(),o=m.get.content();t||o||e?(m.debug("Creating pop-up html"),t=t||u.templates.popup({title:e,content:o}),l=N("<div/>").addClass(c.popup).data(d.activator,f).html(t),u.inline?(m.verbose("Inserting popup element inline",l),l.insertAfter(f)):(m.verbose("Appending popup element to body",l),l.appendTo(p)),m.refresh(),m.set.variation(),u.hoverable&&m.bind.popup(),u.onCreate.call(l,g)):u.popup?(N(u.popup).data(d.activator,f),m.verbose("Used popup specified in settings"),m.refresh(),u.hoverable&&m.bind.popup()):0!==h.next(n.popup).length?(m.verbose("Pre-existing popup found"),u.inline=!0,u.popup=h.next(n.popup).data(d.activator,f),m.refresh(),u.hoverable&&m.bind.popup()):m.debug("No content specified skipping display",g)},createID:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),t="."+o,m.verbose("Creating unique id for element",o)},toggle:function(){m.debug("Toggling pop-up"),m.is.hidden()?(m.debug("Popup is hidden, showing pop-up"),m.unbind.close(),m.show()):(m.debug("Popup is visible, hiding pop-up"),m.hide())},show:function(t){t=t||function(){},m.debug("Showing pop-up",u.transition),!m.is.hidden()||m.is.active()&&m.is.dropdown()||(m.exists()||m.create(),!1!=