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

10 years ago
10 years ago
  1. /*
  2. * # Semantic UI
  3. * git://github.com/Semantic-Org/Semantic-UI.git#1.0
  4. *
  5. *
  6. * Copyright 2014 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(e,i,n,t){e.fn.dimmer=function(i){var o,a=e(this),r=(new Date).getTime(),m=[],s=arguments[0],d="string"==typeof s,c=[].slice.call(arguments,1);return a.each(function(){var u,l,f,g=e.isPlainObject(i)?e.extend(!0,{},e.fn.dimmer.settings,i):e.extend({},e.fn.dimmer.settings),p=g.selector,b=g.namespace,h=g.className,v=(g.error,"."+b),y="module-"+b,C=a.selector||"",w="ontouchstart"in n.documentElement?"touchstart":"click",D=e(this),T=this,N=D.data(y);f={preinitialize:function(){f.is.dimmer()?(l=D.parent(),u=D):(l=D,u=f.has.dimmer()?g.dimmerName?l.children(p.dimmer).filter("."+g.dimmerName):l.children(p.dimmer):f.create())},initialize:function(){f.debug("Initializing dimmer",g),"hover"==g.on?l.on("mouseenter"+v,f.show).on("mouseleave"+v,f.hide):"click"==g.on&&l.on(w+v,f.toggle),f.is.page()&&(f.debug("Setting as a page dimmer",l),f.set.pageDimmer()),f.is.closable()&&(f.verbose("Adding dimmer close event",u),u.on(w+v,f.event.click)),f.set.dimmable(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),N=f,D.data(y,N)},destroy:function(){f.verbose("Destroying previous module",u),D.removeData(y),l.off(v),u.off(v)},event:{click:function(i){f.verbose("Determining if event occured on dimmer",i),(0===u.find(i.target).size()||e(i.target).is(p.content))&&(f.hide(),i.stopImmediatePropagation())}},addContent:function(i){var n=e(i);f.debug("Add content to dimmer",n),n.parent()[0]!==u[0]&&n.detach().appendTo(u)},create:function(){var i=e(g.template.dimmer());return g.variation&&(f.debug("Creating dimmer with variation",g.variation),i.addClass(h.variation)),g.dimmerName&&(f.debug("Creating named dimmer",g.dimmerName),i.addClass(g.dimmerName)),i.appendTo(l),i},show:function(i){i=e.isFunction(i)?i:function(){},f.debug("Showing dimmer",u,g),f.is.dimmed()&&!f.is.animating()||!f.is.enabled()?f.debug("Dimmer is already shown or disabled"):(f.animate.show(i),e.proxy(g.onShow,T)(),e.proxy(g.onChange,T)())},hide:function(i){i=e.isFunction(i)?i:function(){},f.is.dimmed()||f.is.animating()?(f.debug("Hiding dimmer",u),f.animate.hide(i),e.proxy(g.onHide,T)(),e.proxy(g.onChange,T)()):f.debug("Dimmer is not visible")},toggle:function(){f.verbose("Toggling dimmer visibility",u),f.is.dimmed()?f.hide():f.show()},animate:{show:function(i){i=e.isFunction(i)?i:function(){},g.useCSS&&e.fn.transition!==t&&u.transition("is supported")?u.transition({animation:g.transition+" in",queue:!1,duration:f.get.duration(),start:function(){f.set.dimmed()},complete:function(){f.set.active(),i()}}):(f.verbose("Showing dimmer animation with javascript"),f.set.dimmed(),u.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(f.get.duration(),1,function(){u.removeAttr("style"),f.set.active(),i()}))},hide:function(i){i=e.isFunction(i)?i:function(){},g.useCSS&&e.fn.transition!==t&&u.transition("is supported")?(f.verbose("Hiding dimmer with css"),u.transition({animation:g.transition+" out",queue:!1,duration:f.get.duration(),start:function(){f.remove.dimmed()},complete:function(){f.remove.active(),i()}})):(f.verbose("Hiding dimmer with javascript"),f.remove.dimmed(),u.stop().fadeOut(f.get.duration(),function(){f.remove.active(),u.removeAttr("style"),i()}))}},get:{dimmer:function(){return u},duration:function(){return"object"==typeof g.duration?f.is.active()?g.duration.hide:g.duration.show:g.duration}},has:{dimmer:function(){return g.dimmerName?D.children(p.dimmer).filter("."+g.dimmerName).size()>0:D.children(p.dimmer).size()>0}},is:{active:function(){return u.hasClass(h.active)},animating:function(){return u.is(":animated")||u.hasClass(h.animating)},closable:function(){return"auto"==g.closable?"hover"==g.on?!1:!0:g.closable},dimmer:function(){return D.is(p.dimmer)},dimmable:function(){return D.is(p.dimmable)},dimmed:function(){return l.hasClass(h.dimmed)},disabled:function(){return l.hasClass(h.disabled)},enabled:function(){return!f.is.disabled()},page:function(){return l.is("body")},pageDimmer:function(){return u.hasClass(h.pageDimmer)}},can:{show:function(){return!u.hasClass(h.disabled)}},set:{active:function(){u.addClass(h.active)},dimmable:f