bazarr/static/semantic/components/popup.min.js

1 line
18 KiB
JavaScript
Raw Normal View History

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