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
7.7 KiB

7 years ago
  1. !function(e,i,n,t){"use strict";i=void 0!==i&&i.Math==Math?i:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.dimmer=function(i){var t,o=e(this),a=(new Date).getTime(),r=[],s=arguments[0],d="string"==typeof s,m=[].slice.call(arguments,1);return o.each(function(){var c,u,l,f=e.isPlainObject(i)?e.extend(!0,{},e.fn.dimmer.settings,i):e.extend({},e.fn.dimmer.settings),g=f.selector,v=f.namespace,p=f.className,h=f.error,b="."+v,y="module-"+v,C=o.selector||"",w="ontouchstart"in n.documentElement?"touchstart":"click",S=e(this),D=this,T=S.data(y);l={preinitialize:function(){l.is.dimmer()?(u=S.parent(),c=S):(u=S,c=l.has.dimmer()?f.dimmerName?u.find(g.dimmer).filter("."+f.dimmerName):u.find(g.dimmer):l.create(),l.set.variation())},initialize:function(){l.debug("Initializing dimmer",f),l.bind.events(),l.set.dimmable(),l.instantiate()},instantiate:function(){l.verbose("Storing instance of module",l),T=l,S.data(y,T)},destroy:function(){l.verbose("Destroying previous module",c),l.unbind.events(),l.remove.variation(),u.off(b)},bind:{events:function(){"hover"==f.on?u.on("mouseenter"+b,l.show).on("mouseleave"+b,l.hide):"click"==f.on&&u.on(w+b,l.toggle),l.is.page()&&(l.debug("Setting as a page dimmer",u),l.set.pageDimmer()),l.is.closable()&&(l.verbose("Adding dimmer close event",c),u.on(w+b,g.dimmer,l.event.click))}},unbind:{events:function(){S.removeData(y),u.off(b)}},event:{click:function(i){l.verbose("Determining if event occured on dimmer",i),(0===c.find(i.target).length||e(i.target).is(g.content))&&(l.hide(),i.stopImmediatePropagation())}},addContent:function(i){var n=e(i);l.debug("Add content to dimmer",n),n.parent()[0]!==c[0]&&n.detach().appendTo(c)},create:function(){var i=e(f.template.dimmer());return f.dimmerName&&(l.debug("Creating named dimmer",f.dimmerName),i.addClass(f.dimmerName)),i.appendTo(u),i},show:function(i){i=e.isFunction(i)?i:function(){},l.debug("Showing dimmer",c,f),l.is.dimmed()&&!l.is.animating()||!l.is.enabled()?l.debug("Dimmer is already shown or disabled"):(l.animate.show(i),f.onShow.call(D),f.onChange.call(D))},hide:function(i){i=e.isFunction(i)?i:function(){},l.is.dimmed()||l.is.animating()?(l.debug("Hiding dimmer",c),l.animate.hide(i),f.onHide.call(D),f.onChange.call(D)):l.debug("Dimmer is not visible")},toggle:function(){l.verbose("Toggling dimmer visibility",c),l.is.dimmed()?l.hide():l.show()},animate:{show:function(i){i=e.isFunction(i)?i:function(){},f.useCSS&&void 0!==e.fn.transition&&c.transition("is supported")?("auto"!==f.opacity&&l.set.opacity(),c.transition({animation:f.transition+" in",queue:!1,duration:l.get.duration(),useFailSafe:!0,onStart:function(){l.set.dimmed()},onComplete:function(){l.set.active(),i()}})):(l.verbose("Showing dimmer animation with javascript"),l.set.dimmed(),"auto"==f.opacity&&(f.opacity=.8),c.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(l.get.duration(),f.opacity,function(){c.removeAttr("style"),l.set.active(),i()}))},hide:function(i){i=e.isFunction(i)?i:function(){},f.useCSS&&void 0!==e.fn.transition&&c.transition("is supported")?(l.verbose("Hiding dimmer with css"),c.transition({animation:f.transition+" out",queue:!1,duration:l.get.duration(),useFailSafe:!0,onStart:function(){l.remove.dimmed()},onComplete:function(){l.remove.active(),i()}})):(l.verbose("Hiding dimmer with javascript"),l.remove.dimmed(),c.stop().fadeOut(l.get.duration(),function(){l.remove.active(),c.removeAttr("style"),i()}))}},get:{dimmer:function(){return c},duration:function(){return"object"==typeof f.duration?l.is.active()?f.duration.hide:f.duration.show:f.duration}},has:{dimmer:function(){return f.dimmerName?S.find(g.dimmer).filter("."+f.dimmerName).length>0:S.find(g.dimmer).length>0}},is:{active:function(){return c.hasClass(p.active)},animating:function(){return c.is(":animated")||c.hasClass(p.animating)},closable:function(){return"auto"==f.closable?"hover"!=f.on:f.closable},dimmer:function(){return S.hasClass(p.dimmer)},dimmable:function(){return S.hasClass(p.dimmable)},dimmed:function(){return u.hasClass(p.dimmed)},disabled:function(){return u.hasClass(p