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

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