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.4 KiB

  1. (function(e,t,n,o){e.fn.dimmer=function(t){var n,i=e(this),a=e.isPlainObject(t)?e.extend(!0,{},e.fn.dimmer.settings,t):e.fn.dimmer.settings,r=("."+a.namespace,"module-"+a.namespace,i.selector||""),s=(i.size(),(new Date).getTime()),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),m=a.selector,f=a.namespace,g=a.className,p=a.error;return i.each(function(){var t,i=e(this),h=i.children(m.dimmer).first(),v="animationend msAnimationEnd oAnimationEnd webkitAnimationEnd",b=this,y=h.data("module-"+f);t={initialize:function(){t.is.dimmer()?(h=i,i=h.parent(),t.debug("Module initialized as dimmer",h)):(t.has.dimmer()?(h=i.find(m.dimmer),t.debug("Module initialized with found dimmer",h)):(h=a.template.dimmer(),h.appendTo(i),t.debug("Module initialized with created dimmer",h)),"hover"==a.on?i.on("mouseenter",t.show).on("mouseleave",t.hide):"click"==a.on&&i.on("click",t.toggle)),i.addClass(g.dimmable),a.closable&&h.on("click",t.event.click),t.instantiate()},instantiate:function(){t.verbose("Storing instance of module"),y=t,h.data("module-"+f,y)},destroy:function(){t.verbose("Destroying previous module for",i),i.off(f)},event:{click:function(n){t.verbose("Determining if event occured on dimmer",n),console.log(n.target,m.content,e(n.target).is(m.content)),(0===h.find(n.target).size()||e(n.target).is(m.content))&&t.hide()}},animate:{show:function(){t.set.dimmed(),"css"==a.animation.show?(t.verbose("Showing dimmer animation with css"),h.one(v,function(){t.set.active(),h.removeClass(g.show)}).addClass(g.show)):"fade"==a.animation.show&&(t.verbose("Showing dimmer animation with javascript"),h.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(a.duration,1,function(){h.removeAttr("style"),t.set.active()}))},hide:function(){t.remove.dimmed(),"css"==a.animation.hide?(t.verbose("Hiding dimmer with css"),h.one(v,function(){t.remove.active(),h.removeClass(g.hide)}).addClass(g.hide)):"fade"==a.animation.hide?(t.verbose("Hiding dimmer with javascript"),h.stop().fadeOut(.75*a.duration,function(){h.removeAttr("style"),t.remove.active()})):e.isFunction(a.animation.hide)&&e.proxy(a.animation.hide,h)()}},has:{dimmer:function(){return i.children(m.dimmer).size()>0}},is:{animating:function(){return h.hasClass(g.show)||h.hasClass(g.hide)||h.is(":animated")},dimmer:function(){return i.is(m.dimmer)},pageDimmer:function(){return i.is(m.pageDimmer)},dimmable:function(){return i.is(m.dimmable)},enabled:function(){return!i.hasClass(g.disabled)},disabled:function(){return i.hasClass(g.disabled)},active:function(){return h.hasClass(g.active)}},can:{show:function(){return!h.hasClass(g.disabled)}},set:{active:function(){h.addClass(g.active)},dimmed:function(){i.addClass(g.dimmed)},disabled:function(){h.addClass(g.disabled)}},remove:{active:function(){h.removeClass(g.active)},dimmed:function(){i.removeClass(g.dimmed)},disabled:function(){h.removeClass(g.disabled)}},show:function(){t.debug("Showing dimmer",h),t.is.active()&&!t.is.animating()||!t.is.enabled()?t.debug("Dimmer is already shown or disabled"):(t.animate.show(),e.proxy(a.onShow,b)(),e.proxy(a.onChange,b)())},hide:function(){t.is.active()||t.is.animating()?(t.debug("Hiding dimmer",h),t.animate.hide(),e.proxy(a.onHide,b)(),e.proxy(a.onChange,b)()):t.debug("Dimmer is not visible")},toggle:function(){t.verbose("Toggling dimmer visibility",h),t.is.hidden()?t.show():t.hide()},setting:function(t,n){return n===o?a[t]:(e.isPlainObject(t)?e.extend(!0,a,t):a[t]=n,o)},internal:function(n,i){return i===o?t[n]:(e.isPlainObject(n)?e.extend(!0,t,n):t[n]=i,o)},debug:function(){a.debug&&(a.performance?t.performance.log(arguments):t.debug=Function.prototype.bind.call(console.info,console,a.moduleName+":"))},verbose:function(){a.verbose&&a.debug&&(a.performance?t.performance.log(arguments):t.verbose=Function.prototype.bind.call(console.info,console,a.moduleName+":"))},error:function(){t.error=Function.prototype.bind.call(console.log,console,a.moduleName+":")},performance:{log:function(e){var n,o,i;a.performance&&(n=(new Date).getTime(),i=s||n,o=n-i,s=n,c.push({Element:b,Name:e[0],Arguments:e[1]||"",