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.

0 lines
6.0 KiB

  1. !function(a,b,c,d){a.fn.dimmer=function(b){var e,f=a(this),g=a.isPlainObject(b)?a.extend(!0,{},a.fn.dimmer.settings,b):a.fn.dimmer.settings,h=g.selector,i=g.namespace,j=g.className,k=g.error,l="."+i,m="module-"+i,n=f.selector||"",o=(new Date).getTime(),p=[],q=arguments[0],r="string"==typeof q,s=[].slice.call(arguments,1),t="ontouchstart"in c.documentElement?"touchstart":"click";return f.each(function(){var b,c,i,u=a(this),v=this,w=u.data(m);i={preinitialize:function(){i.is.dimmer()?(c=u.parent(),b=u):(c=u,i.has.dimmer()?b=c.children(h.dimmer).first():i.create())},initialize:function(){i.debug("Initializing dimmer",g),"hover"==g.on?c.on("mouseenter"+l,i.show).on("mouseleave"+l,i.hide):"click"==g.on&&c.on(t+l,i.toggle),i.is.page()&&(i.debug("Setting as a page dimmer",c),i.set.pageDimmer()),g.closable&&(i.verbose("Adding dimmer close event",b),b.on(t+l,i.event.click)),i.set.dimmable(),i.instantiate()},instantiate:function(){i.verbose("Storing instance of module",i),w=i,u.data(m,w)},destroy:function(){i.verbose("Destroying previous module",b),c.off(l),b.off(l)},event:{click:function(c){i.verbose("Determining if event occured on dimmer",c),(0===b.find(c.target).size()||a(c.target).is(h.content))&&(i.hide(),c.stopImmediatePropagation())}},addContent:function(c){var d=a(c).detach();i.debug("Add content to dimmer",d),d.parent()[0]!==b[0]&&b.append(d)},create:function(){return b=a(g.template.dimmer()),b.appendTo(c)},animate:{show:function(c){c=c||function(){},i.set.dimmed(),a.fn.transition!==d?b.transition(g.transition+" in",g.duration,function(){i.set.active(),c()}):(i.verbose("Showing dimmer animation with javascript"),b.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(g.duration,1,function(){b.removeAttr("style"),i.set.active(),c()}))},hide:function(c){c=c||function(){},i.remove.dimmed(),a.fn.transition!==d?(i.verbose("Hiding dimmer with css"),b.transition(g.transition+" out",g.duration,function(){i.remove.active(),c()})):(i.verbose("Hiding dimmer with javascript"),b.stop().fadeOut(g.duration,function(){b.removeAttr("style"),i.remove.active(),c()}))}},get:{dimmer:function(){return b}},has:{dimmer:function(){return u.children(h.dimmer).size()>0}},is:{dimmer:function(){return u.is(h.dimmer)},dimmable:function(){return u.is(h.dimmable)},active:function(){return b.hasClass(j.active)},animating:function(){return b.is(":animated")||b.hasClass(j.transition)},page:function(){return c.is("body")},enabled:function(){return!c.hasClass(j.disabled)},disabled:function(){return c.hasClass(j.disabled)},pageDimmer:function(){return b.hasClass(j.pageDimmer)}},can:{show:function(){return!b.hasClass(j.disabled)}},set:{active:function(){b.removeClass(j.transition).addClass(j.active)},dimmable:function(){c.addClass(j.dimmable)},dimmed:function(){c.addClass(j.dimmed)},pageDimmer:function(){b.addClass(j.pageDimmer)},disabled:function(){b.addClass(j.disabled)}},remove:{active:function(){b.removeClass(j.transition).removeClass(j.active)},dimmed:function(){c.removeClass(j.dimmed)},disabled:function(){b.removeClass(j.disabled)}},show:function(c){i.debug("Showing dimmer",b,g),i.is.active()||i.is.animating()||!i.is.enabled()?i.debug("Dimmer is already shown or disabled"):(i.animate.show(c),a.proxy(g.onShow,v)(),a.proxy(g.onChange,v)())},hide:function(c){i.is.active()&&!i.is.animating()?(i.debug("Hiding dimmer",b),i.animate.hide(c),a.proxy(g.onHide,v)(),a.proxy(g.onChange,v)()):i.debug("Dimmer is not visible")},toggle:function(){i.verbose("Toggling dimmer visibility",b),i.is.active()?i.hide():i.show()},setting:function(b,c){return c===d?g[b]:(a.isPlainObject(b)?a.extend(!0,g,b):g[b]=c,void 0)},internal:function(b,c){return c===d?i[b]:(a.isPlainObject(b)?a.extend(!0,i,b):i[b]=c,void 0)},debug:function(){g.debug&&(g.performance?i.performance.log(arguments):(i.debug=Function.prototype.bind.call(console.info,console,g.name+":"),i.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?i.performance.log(arguments):(i.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),i.verbose.apply(console,arguments))