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

  1. !function(a,b,c,d){a.dimScreen=function(b){var c="function"==typeof b?a.extend({},a.fn.modal.settings,{dim:b}):a.extend({},a.fn.modal.settings,b),d=a(c.context),e=d.children(c.selector.dimmer),f=e.size()>0,g=e.css("opacity");return f||(e=a("<div/>").attr("id","dimmer").html('<div class="content"></div>'),d.append(e)),g!=c.opacity&&(e.one("click",function(){c.unDim(),a.unDimScreen()}),0===c.duration?(e.css({visibility:"visible"}).find(".content").css({opacity:c.opacity,visibility:"visible"}),c.dim()):e.css({visibility:"visible"}).find(".content").css({opacity:0,visibility:"visible"}).fadeTo(c.duration,c.opacity,c.dim)),this},a.unDimScreen=function(b){var c="function"==typeof b?a.extend({},a.fn.modal.settings,{unDim:b}):a.extend({},a.fn.modal.settings,b),d=a(c.context),e=d.children(c.selector.dimmer),f=e.size()>0;return f&&(c.unDim(),0===c.duration?e.css({visibility:"hidden"}).remove():e.find(".content").fadeTo(c.duration,0,function(){e.remove()})),this},a.fn.modal=function(e){var f,g=a.extend(!0,{},a.fn.modal.settings,e),h=arguments[0],i=[].slice.call(arguments,1);return a(this).each(function(){var e,j=a(this),k=j.find(g.selector.closeButton),l=(a(g.context).find(g.selector.dimmer),a(g.context).children(g.selector.modal)),m=l.not(j),n=j.data("module-"+g.namespace),o="string"==typeof h,p=(g.className,g.namespace);e={initialize:function(){j.on("modalShow."+p,e.show).on("modalHide."+p,e.hide).data("module-"+p,e)},show:function(){var e,f,h,i,l=j.outerHeight(),n=a(b).height(),o=l>n,q=o?"absolute":"fixed";j.removeClass("absolute fixed").addClass(q),e=o?"0":"50%",f=o?n/8:-((l-g.closeSpacing)/2),h="absolute"==j.css("position")?f+a(b).prop("pageYOffset"):f,i=h+g.animationOffset,a.fn.popIn!==d?j.css({display:"block",opacity:0,top:e,marginTop:h+"px"}).popIn():j.css({display:"block",opacity:0,top:e,marginTop:i+"px"}).animate({opacity:1,marginTop:h+"px"},g.duration+300,g.easing),m.is(":visible")&&m.filter(":visible").hide(),a.dimScreen({context:g.context,duration:0,dim:function(){a(c).on("keyup."+p,function(a){var b=a.which,c=27;switch(b){case c:j.modal("hide"),a.preventDefault()}}),k.one("click",function(){j.modal("hide")}),g.dim()},unDim:function(){j.modal("hide"),k.unbind("click")}})},hide:function(){a(c).off("keyup."+p),a.unDimScreen({duration:0,unDim:function(){j.popOut(200),g.unDim()}})},setting:function(a,b){return b===d?g[a]:(g[a]=b,void 0)},debug:function(){var a=[],b=g.moduleName+": "+arguments[0],c=[].slice.call(arguments,1),d=console.info||console.log||function(){};g.debug&&(a.push(b),d.apply(console,a.concat(c)))},error:function(){var a=[],b=g.moduleName+": "+arguments[0],c=[].slice.call(arguments,1),d=console.warn||console.log||function(){};g.debug&&(a.push(b),a.concat(c),d.apply(console,a.concat(c)))},invoke:function(b,c,f){var h,i;return f=f||[].slice.call(arguments,2),"string"==typeof b&&n!==d&&(b=b.split(/[\. ]/),h=b.length-1,a.each(b,function(b,c){return a.isPlainObject(n[c])&&b!=h?(n=n[c],!0):n[c]!==d?(i=n[c],!0):(e.error(g.errors.method),!1)})),a.isFunction(i)?i.apply(c,f):i}},o?f=e.invoke(h,this,i):e.initialize()}),f?f:this},a.fn.modal.settings={moduleName:"Modal",debug:!1,namespace:"modal",errors:{method:"The method you called is not defined"},dim:function(){},unDim:function(){},hide:function(){},show:function(){},context:"body",opacity:.8,closeSpacing:25,animationOffset:15,duration:400,easing:"easeOutExpo",selector:{dimmer:"#dimmer",modal:".modal",closeButton:".close"}}}(jQuery,window,document);