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
5.7 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);return f.each(function(){var b,f=a(this),t=f.children(h.dimmer).first(),u=this,v=t.data(m);b={initialize:function(){b.is.dimmer()?(t=f,f=t.parent(),b.debug("Module initialized as dimmer")):(b.has.dimmer()?(t=f.find(h.dimmer),b.debug("Module initialized with found dimmer")):(t=g.template.dimmer(),t.appendTo(f),b.debug("Module initialized with created dimmer")),"hover"==g.on?f.on("mouseenter"+l,b.show).on("mouseleave"+l,b.hide):"click"==g.on&&f.on("click"+l,b.toggle)),f.addClass(j.dimmable),g.closable&&t.on("click",b.event.click),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module"),v=b,t.data(m,v)},destroy:function(){b.verbose("Destroying previous module"),f.off(i)},event:{click:function(c){b.verbose("Determining if event occured on dimmer",c),(0===t.find(c.target).size()||a(c.target).is(h.content))&&b.hide()}},animate:{show:function(){b.set.dimmed(),"css"==g.animation.show?(b.verbose("Showing dimmer animation with css"),t.one(b.get.animationEndEvent(),function(){b.set.active(),t.removeClass(j.show)}).addClass(j.show)):"fade"==g.animation.show&&(b.verbose("Showing dimmer animation with javascript"),t.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(g.duration,1,function(){t.removeAttr("style"),b.set.active()}))},hide:function(){b.remove.dimmed(),"css"==g.animation.hide?(b.verbose("Hiding dimmer with css"),t.one(b.get.animationEndEvent(),function(){b.remove.active(),t.removeClass(j.hide)}).addClass(j.hide)):"fade"==g.animation.hide?(b.verbose("Hiding dimmer with javascript"),t.stop().fadeOut(.75*g.duration,function(){t.removeAttr("style"),b.remove.active()})):a.isFunction(g.animation.hide)&&a.proxy(g.animation.hide,t)()}},get:{animationEndEvent:function(){var a,b=c.createElement("element"),e={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(a in e)if(b.style[a]!==d)return e[a]}},has:{dimmer:function(){return f.children(h.dimmer).size()>0}},is:{animating:function(){return t.hasClass(j.show)||t.hasClass(j.hide)||t.is(":animated")},dimmer:function(){return f.is(h.dimmer)},pageDimmer:function(){return f.is(h.pageDimmer)},dimmable:function(){return f.is(h.dimmable)},enabled:function(){return!f.hasClass(j.disabled)},disabled:function(){return f.hasClass(j.disabled)},active:function(){return t.hasClass(j.active)}},can:{show:function(){return!t.hasClass(j.disabled)}},set:{active:function(){t.addClass(j.active)},dimmed:function(){f.addClass(j.dimmed)},disabled:function(){t.addClass(j.disabled)}},remove:{active:function(){t.removeClass(j.active)},dimmed:function(){f.removeClass(j.dimmed)},disabled:function(){t.removeClass(j.disabled)}},show:function(){b.debug("Showing dimmer",t),b.is.active()&&!b.is.animating()||!b.is.enabled()?b.debug("Dimmer is already shown or disabled"):(b.animate.show(),a.proxy(g.onShow,u)(),a.proxy(g.onChange,u)())},hide:function(){b.is.active()||b.is.animating()?(b.debug("Hiding dimmer",t),b.animate.hide(),a.proxy(g.onHide,u)(),a.proxy(g.onChange,u)()):b.debug("Dimmer is not visible")},toggle:function(){b.verbose("Toggling dimmer visibility",t),b.is.hidden()?b.show():b.hide()},setting:function(b,c){return c===d?g[b]:(a.isPlainObject(b)?a.extend(!0,g,b):g[b]=c,void 0)},internal:function(c,e){return e===d?b[c]:(a.isPlainObject(c)?a.extend(!0,b,c):b[c]=e,void 0)},debug:function(){g.debug&&(g.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,g.moduleName+":"),b.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,g.moduleName+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.c