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

10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
  1. /*
  2. * # Semantic UI - 1.6.4
  3. * https://github.com/Semantic-Org/Semantic-UI
  4. * http://www.semantic-ui.com/
  5. *
  6. * Copyright 2014 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(e,t,o,i){"use strict";e.fn.popup=function(n){var r,s=e(this),a=e(o),p=s.selector||"",l=("ontouchstart"in o.documentElement,(new Date).getTime()),u=[],c=arguments[0],d="string"==typeof c,f=[].slice.call(arguments,1);return s.each(function(){var o,s,g,h=e.isPlainObject(n)?e.extend(!0,{},e.fn.popup.settings,n):e.extend({},e.fn.popup.settings),m=h.selector,b=h.className,v=h.error,y=h.metadata,w=h.namespace,x="."+h.namespace,P="module-"+w,T=e(this),C=e(h.context),k=h.target?e(h.target):T,O=e(t),S=e("body"),j=0,A=!1,R=this,z=T.data(P);g={initialize:function(){g.debug("Initializing module",T),g.refresh(),"click"==h.on?T.on("click"+x,g.toggle):g.get.startEvent()&&T.on(g.get.startEvent()+x,g.event.start).on(g.get.endEvent()+x,g.event.end),h.target&&g.debug("Target set to element",k),O.on("resize"+x,g.event.resize),g.exists()?h.hoverable&&g.bind.popup():g.create(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),z=g,T.data(P,z)},refresh:function(){h.popup?o=e(h.popup):h.inline&&(o=k.next(h.selector.popup)),h.popup?(o.addClass(b.loading),s=T.offsetParent(),o.offsetParent()[0]!==s[0]&&(g.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s)),o.removeClass(b.loading)):s=h.inline?k.offsetParent():S,s.is("html")&&(g.debug("Page is popups offset parent"),s=S)},reposition:function(){g.refresh(),g.set.position()},destroy:function(){g.debug("Destroying previous module"),o&&!h.preserve&&g.removePopup(),clearTimeout(g.hideTimer),clearTimeout(g.showTimer),T.off(x).removeData(P)},event:{start:function(){var t=e.isPlainObject(h.delay)?h.delay.show:h.delay;clearTimeout(g.hideTimer),g.showTimer=setTimeout(function(){!g.is.hidden()||g.is.active()&&g.is.dropdown()||g.show()},t)},end:function(){var t=e.isPlainObject(h.delay)?h.delay.hide:h.delay;clearTimeout(g.showTimer),g.hideTimer=setTimeout(function(){g.is.visible()&&g.hide()},t)},resize:function(){g.is.visible()&&g.set.position()}},create:function(){var t=T.data(y.html)||h.html,i=T.data(y.variation)||h.variation,n=T.data(y.title)||h.title,r=T.data(y.content)||T.attr("title")||h.content;t||r||n?(g.debug("Creating pop-up html"),t||(t=h.templates.popup({title:n,content:r})),o=e("<div/>").addClass(b.popup).addClass(i).html(t),i&&o.addClass(i),h.inline?(g.verbose("Inserting popup element inline",o),o.insertAfter(T)):(g.verbose("Appending popup element to body",o),o.appendTo(C)),h.hoverable&&g.bind.popup(),e.proxy(h.onCreate,o)(R)):0!==k.next(h.selector.popup).size()?(g.verbose("Pre-existing popup found, reverting to inline"),h.inline=!0,g.refresh(),h.hoverable&&g.bind.popup()):g.debug("No content specified skipping display",R)},toggle:function(){g.debug("Toggling pop-up"),g.is.hidden()?(g.debug("Popup is hidden, showing pop-up"),g.unbind.close(),g.hideAll(),g.show()):(g.debug("Popup is visible, hiding pop-up"),g.hide())},show:function(t){t=e.isFunction(t)?t:function(){},g.debug("Showing pop-up",h.transition),h.preserve||h.popup||g.refresh(),g.exists()||g.create(),o&&g.set.position()&&(g.save.conditions(),g.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},g.remove.visible(),g.unbind.close(),g.is.visible()&&(g.restore.conditions(),g.animate.hide(t))},hideAll:function(){e(m.popup).filter(":visible").popup("hide")},hideGracefully:function(t){t&&0===e(t.target).closest(m.popup).size()?(g.debug("Click occurred outside popup hiding popup"),g.hide()):g.debug("Click was inside popup, keeping popup open")},exists:function(){return o?h.inline||h.popup?g.has.popup():o.closest(C).size()>1?!0:!1:!1},removePopup:function(){g.debug("Removing popup",o),g.has.popup()&&o.remove(),e.proxy(h.onRemove,o)(R)},save:{conditions:function(){g.cache={title:T.attr("title")},g.cache.title&&T.removeAttr("title"),g.verbose("Saving original attributes",g.cache.title)}},restore:{conditions:function(){return R.blur(),g.cache&&g.cache.title&&(T.attr("title",g.cache.title),g.verbose("Restoring original attributes",g.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},h.transition&&e.fn.transition!==i&&T.transit