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

10 years ago
10 years ago
  1. /*
  2. * # Semantic UI
  3. * https://github.com/Semantic-Org/Semantic-UI
  4. * http://beta.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,n){"use strict";e.fn.popup=function(i){var r,s=e(this),a=e(o),p=s.selector||"",l=("ontouchstart"in o.documentElement,(new Date).getTime()),c=[],u=arguments[0],d="string"==typeof u,f=[].slice.call(arguments,1);return s.each(function(){var o,s,g,h=e.isPlainObject(i)?e.extend(!0,{},e.fn.popup.settings,i):e.extend({},e.fn.popup.settings),m=h.selector,b=h.className,v=h.error,y=h.metadata,w=h.namespace,k="."+h.namespace,x="module-"+w,C=e(this),P=e(h.context),T=h.target?e(h.target):C,O=e(t),S=e("body"),A=0,E=this,z=C.data(x);g={initialize:function(){g.debug("Initializing module",C),g.refresh(),"click"==h.on?C.on("click"+k,g.toggle):g.get.startEvent()&&C.on(g.get.startEvent()+k,g.event.start).on(g.get.endEvent()+k,g.event.end),h.target&&g.debug("Target set to element",T),O.on("resize"+k,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,C.data(x,z)},refresh:function(){o=h.popup?e(h.popup):h.inline?T.next(h.selector.popup):!1,s=h.popup?o.offsetParent():h.inline?T.offsetParent():S},destroy:function(){g.debug("Destroying previous module"),o&&!h.preserve&&g.remove(),C.off(k).removeData(x)},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=C.data(y.html)||h.html,n=C.data(y.variation)||h.variation,i=C.data(y.title)||h.title,r=C.data(y.content)||C.attr("title")||h.content;t||r||i?(g.debug("Creating pop-up html"),t||(t=h.templates.popup({title:i,content:r})),o=e("<div/>").addClass(b.popup).addClass(n).html(t),n&&o.addClass(n),h.inline?(g.verbose("Inserting popup element inline",o),o.insertAfter(C)):(g.verbose("Appending popup element to body",o),o.appendTo(P)),h.hoverable&&g.bind.popup(),e.proxy(h.onCreate,o)()):0!==T.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",E)},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(){},C.removeClass(b.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?0!==o.size():o.closest(P).size():!1},remove:function(){g.debug("Removing popup"),o.remove()},save:{conditions:function(){g.cache={title:C.attr("title")},g.cache.title&&C.removeAttr("title"),g.verbose("Saving original attributes",g.cache.title)}},restore:{conditions:function(){return E.blur(),g.cache&&g.cache.title&&(C.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!==n&&C.transition("is supported")?o.transition({animation:h.transition+" in",queue:!1,duration:h.duration,onStart:function(){C.addClass(b.visible)},onComplete:function(){g.bind.close(),e.proxy(t,E)()}}):(C.addClass(b.visible),o.stop().fadeIn(h.duration,h.easing,function(){g.bind.close(),e.proxy(t,E)()})),e.proxy(h.onShow,E)()},hide:function(t){t=e.isFunction(t)?t:function(){},g.debug("Hiding pop-up"),h.transition&