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

9 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
  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(e,t,o,n){"use strict";e.fn.popup=function(i){var r,s=e(this),a=e(o),p=s.selector||"",l="ontouchstart"in o.documentElement,u=(new Date).getTime(),c=[],d=arguments[0],f="string"==typeof d,g=[].slice.call(arguments,1);return s.each(function(){var o,s,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,x="."+b.namespace,k="module-"+C,S=e(this),O=e(b.context),E=b.target?e(b.target):S,j=e(t),A=e("body"),R=0,F=!1,D=this,H=S.data(k);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(k,H)},refresh:function(){b.popup?o=e(b.popup).eq(0):b.inline&&(o=E.next(y.popup).eq(0),b.popup=o),b.popup?(o.addClass(w.loading),s=v.get.offsetParent(),o.removeClass(w.loading),b.movePopup&&v.has.popup()&&v.get.offsetParent(o)[0]!==s[0]&&(v.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s))):s=b.inline?v.get.offsetParent(E):v.has.popup()?v.get.offsetParent(o):A,s.is("html")&&(v.debug("Setting page as offset parent"),s=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(x).removeData(k)},event:{start:function(){var t=e.isPlainObject(b.delay)?b.delay.show:b.delay;clearTimeout(v.hideTimer),v.showTimer=setTimeout(function(){!v.is.hidden()||v.is.active()&&v.is.dropdown()||v.show()},t)},end:function(){var t=e.isPlainObject(b.delay)?b.delay.hide:b.delay;clearTimeout(v.showTimer),v.hideTimer=setTimeout(function(){v.is.visible()&&v.hide()},t)},resize:function(){v.is.visible()&&v.set.position()}},create:function(){var t=S.data(P.html)||b.html,n=S.data(P.variation)||b.variation,i=S.data(P.title)||b.title,r=S.data(P.content)||S.attr("title")||b.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(O)),v.refresh(),b.hoverable&&v.bind.popup(),b.onCreate.call(o,D)):0!==E.next(y.popup).length?(v.verbose("Pre-existing popup found"),b.inline=!0,b.popups=E.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",D)},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){t=e.isFunction(t)?t:function(){},v.debug("Showing pop-up",b.transition),v.exists()?b.preserve||b.popup||v.refresh():v.create(),o&&v.set.position()&&(v.save.conditions(),b.exclusive&&v.hideAll(),v.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},v.remove.visible(),v.unbind.close(),v.is.visible()&&(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(O).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,D)},save:{conditions:function(){v.cache={title:S.attr("title")},v.cache.title&&S.removeAttr("title"),v.verbose("Saving original attributes",v.cache.title)}},restore:{conditio