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
10 years ago
10 years ago
  1. /*
  2. * # Semantic UI
  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,n){"use strict";e.fn.popup=function(i){var s,r=e(this),a=e(o),l=r.selector||"",p=("ontouchstart"in o.documentElement,(new Date).getTime()),u=[],c=arguments[0],d="string"==typeof c,f=[].slice.call(arguments,1);return r.each(function(){var o,r,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,x="."+h.namespace,k="module-"+w,C=e(this),P=e(h.context),T=h.target?e(h.target):C,O=e(t),S=e("body"),z=0,A=this,E=C.data(k);g={initialize:function(){g.debug("Initializing module",C),g.refresh(),"click"==h.on?C.on("click"+x,g.toggle):g.get.startEvent()&&C.on(g.get.startEvent()+x,g.event.start).on(g.get.endEvent()+x,g.event.end),h.target&&g.debug("Target set to element",T),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),E=g,C.data(k,E)},refresh:function(){h.popup?o=e(h.popup):h.inline&&(o=T.next(h.selector.popup)),h.popup?(o.addClass(b.loading),r=o.offsetParent(),o.removeClass(b.loading)):r=h.inline?T.offsetParent():S,r.is("html")&&(g.debug("Page is popups offset parent"),r=S)},reposition:function(){g.refresh(),g.set.position()},destroy:function(){g.debug("Destroying previous module"),o&&!h.preserve&&g.removePopup(),C.off(x).removeData(k)},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,s=C.data(y.content)||C.attr("title")||h.content;t||s||i?(g.debug("Creating pop-up html"),t||(t=h.templates.popup({title:i,content:s})),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)(A)):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",A)},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?0!==o.size():o.closest(P).size():!1},removePopup:function(){g.debug("Removing popup"),e.proxy(h.onRemove,o)(A),o.removePopup()},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 A.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")?(g.set.visible(),o.transition({animation:h.transition+" in",queue:!1,debug:h.debug,verbose:h.verbose,duration:h.duration,onComplete:function(){g.bind.close(),e.proxy(t,o)(A),e.proxy(h