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