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.
 
 
 

1 lines
5.5 KiB

!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+":"))},verbose:function(){g.verbose&&g.debug&&(g.performance?b.performance.log(arguments):b.verbose=Function.prototype.bind.call(console.info,console,g.moduleName+":"))},error:function(){b.error=Function.prototype.bind.call(console.log,console,g.moduleName+":")},performance:{log:function(a){var c,d,e;g.performance&&(c=(new Date).getTime(),e=o||c,d=c-e,o=c,p.push({Element:u,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":d})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var c=g.moduleName+":",e=0;o=!1,clearTimeout(b.performance.timer),a.each(p,function(a,b){e+=b["Execution Time"]}),c+=" "+e+"ms",n&&(c+=" '"+n+"'"),(console.group!==d||console.table!==d)&&p.length>0&&(console.groupCollapsed(c),console.table?console.table(p):a.each(p,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),p=[]}},invoke:function(c,e,f){var g,h;return e=e||s,f=u||f,"string"==typeof c&&v!==d&&(c=c.split(/[\. ]/),g=c.length-1,a.each(c,function(c,e){a.isPlainObject(v[e])&&c!=g?v=v[e]:v[e]!==d?h=v[e]:b.error(k.method)})),a.isFunction(h)?h.apply(f,e):h||!1}},r?(v===d&&b.initialize(),e=b.invoke(q)):(v!==d&&b.destroy(),b.initialize())}),e?e:this},a.fn.dimmer.settings={moduleName:"Dimmer",namespace:"dimmer",verbose:!0,debug:!0,performance:!0,animation:{show:"css",hide:"css"},on:!1,closable:!0,duration:500,onChange:function(){},onShow:function(){},onHide:function(){},error:{method:"The method you called is not defined."},selector:{dimmable:".ui.dimmable",dimmer:".ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return a("<div />").attr("class","ui dimmer")}},className:{active:"active",animating:"animating",dimmable:"ui dimmable",dimmed:"dimmed",disabled:"disabled",hide:"hide",show:"show"}}}(jQuery,window,document);