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