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
10 years ago
  1. /*!
  2. * # Semantic UI 1.11.4 - Popup
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2014 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,b,v=e.isPlainObject(i)?e.extend(!0,{},e.fn.popup.settings,i):e.extend({},e.fn.popup.settings),y=v.selector,w=v.className,P=v.error,T=v.metadata,C=v.namespace,x="."+v.namespace,k="module-"+C,S=e(this),O=e(v.context),E=v.target?e(v.target):S,j=e(t),A=e("body"),R=0,F=!1,D=this,H=S.data(k);b={initialize:function(){b.debug("Initializing",S),b.createID(),b.bind.events(),!b.exists()&&v.preserve&&b.create(),b.instantiate()},instantiate:function(){b.verbose("Storing instance",b),H=b,S.data(k,H)},refresh:function(){v.popup?o=e(v.popup).eq(0):v.inline&&(o=E.next(y.popup).eq(0)),v.popup?(o.addClass(w.loading),s=b.get.offsetParent(),o.removeClass(w.loading),v.movePopup&&b.has.popup()&&b.get.offsetParent(o)[0]!==s[0]&&(b.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s))):s=v.inline?b.get.offsetParent(E):b.has.popup()?b.get.offsetParent(o):A,s.is("html")&&(b.debug("Setting page as offset parent"),s=A)},reposition:function(){b.refresh(),b.set.position()},destroy:function(){b.debug("Destroying previous module"),o&&!v.preserve&&b.removePopup(),clearTimeout(b.hideTimer),clearTimeout(b.showTimer),j.off(h),S.off(x).removeData(k)},event:{start:function(){var t=e.isPlainObject(v.delay)?v.delay.show:v.delay;clearTimeout(b.hideTimer),b.showTimer=setTimeout(function(){!b.is.hidden()||b.is.active()&&b.is.dropdown()||b.show()},t)},end:function(){var t=e.isPlainObject(v.delay)?v.delay.hide:v.delay;clearTimeout(b.showTimer),b.hideTimer=setTimeout(function(){b.is.visible()&&b.hide()},t)},resize:function(){b.is.visible()&&b.set.position()}},create:function(){var t=S.data(T.html)||v.html,n=S.data(T.variation)||v.variation,i=S.data(T.title)||v.title,r=S.data(T.content)||S.attr("title")||v.content;t||r||i?(b.debug("Creating pop-up html"),t||(t=v.templates.popup({title:i,content:r})),o=e("<div/>").addClass(w.popup).addClass(n).data(T.activator,S).html(t),n&&o.addClass(n),v.inline?(b.verbose("Inserting popup element inline",o),o.insertAfter(S)):(b.verbose("Appending popup element to body",o),o.appendTo(O)),b.refresh(),v.hoverable&&b.bind.popup(),v.onCreate.call(o,D)):0!==E.next(y.popup).length?(b.verbose("Pre-existing popup found"),v.inline=!0,v.popup=E.next(y.popup).data(T.activator,S),b.refresh(),v.hoverable&&b.bind.popup()):v.popup?(v.popup.data(T.activator,S),b.verbose("Used popup specified in settings"),b.refresh(),v.hoverable&&b.bind.popup()):b.debug("No content specified skipping display",D)},createID:function(){m=(Math.random().toString(16)+"000000000").substr(2,8),h="."+m,b.verbose("Creating unique id for element",m)},toggle:function(){b.debug("Toggling pop-up"),b.is.hidden()?(b.debug("Popup is hidden, showing pop-up"),b.unbind.close(),b.show()):(b.debug("Popup is visible, hiding pop-up"),b.hide())},show:function(t){t=e.isFunction(t)?t:function(){},b.debug("Showing pop-up",v.transition),b.exists()?v.preserve||v.popup||b.refresh():b.create(),o&&b.set.position()&&(b.save.conditions(),v.exclusive&&b.hideAll(),b.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},b.remove.visible(),b.unbind.close(),b.is.visible()&&(b.restore.conditions(),b.animate.hide(t))},hideAll:function(){e(y.popup).filter("."+w.visible).each(function(){e(this).data(T.activator).popup("hide")})},hideGracefully:function(t){t&&0===e(t.target).closest(y.popup).length?(b.debug("Click occurred outside popup hiding popup"),b.hide()):b.debug("Click was inside popup, keeping popup open")},exists:function(){return o?v.inline||v.popup?b.has.popup():o.closest(O).length>=1?!0:!1:!1},removePopup:function(){b.debug("Removing popup",o),b.has.popup()&&!v.popup&&(o.remove(),o=n),v.onRemove.call(o,D)},save:{conditions:function(){b.cache={title:S.attr("title")},b.cache.title&&S.removeAttr("title"),b.verbose("Saving original attributes",b.cache.title)}},restore:{conditions:function(){