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

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