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
18 KiB

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