You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
18 KiB

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