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
10 years ago
10 years ago
9 years ago
  1. /*
  2. * # Semantic UI - 1.7.2
  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,P="."+h.namespace,T="module-"+w,C=e(this),k=e(h.context),x=h.target?e(h.target):C,S=e(t),O=e("body"),j=0,A=!1,R=this,E=C.data(T);g={initialize:function(){g.debug("Initializing module",C),"click"==h.on?C.on("click"+P,g.toggle):g.get.startEvent()&&C.on(g.get.startEvent()+P,g.event.start).on(g.get.endEvent()+P,g.event.end),h.target&&g.debug("Target set to element",x),S.on("resize"+P,g.event.resize),!g.exists()&&h.preserve&&g.create(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),E=g,C.data(T,E)},refresh:function(){h.popup?o=e(h.popup):h.inline&&(o=x.next(m.popup)),h.popup?(o.addClass(b.loading),r=g.get.offsetParent(),o.removeClass(b.loading),g.has.popup()&&g.get.offsetParent(o)[0]!==r[0]&&(g.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(r))):r=h.inline?g.get.offsetParent(x):g.has.popup()?g.get.offsetParent(o):O,r.is("html")&&(g.debug("Setting page as offset parent"),r=O)},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),C.off(P).removeData(T)},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(k)),g.refresh(),h.hoverable&&g.bind.popup(),h.onCreate.call(o,R)):0!==x.next(m.popup).length?(g.verbose("Pre-existing popup found"),h.inline=!0,h.popup=x.next(m.popup),g.refresh(),h.hoverable&&g.bind.popup()):h.popup?(g.verbose("Used popup specified in settings"),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),g.exists()?h.preserve||h.popup||g.refresh():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").transition("hide")},hideGracefully:function(t){t&&0===e(t.target).closest(m.popup).length?(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(k).length>=1?!0:!1:!1},removePopup:function(){g.debug("Removing popup",o),g.has.popup()&&!h.popup&&(o.remove(),o=n),h.onRemove.call(o,R)},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 g.cache&&g.cache.title&&(C.attr("title",g.cache.title),g.verbose("Restoring original