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.

10 lines
16 KiB

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