ConLite/conlite/plugins/pluginmanager/scripts/jquery.plainmodal.min.js

1 zeile
2.6 KiB
JavaScript

!function(o,e){"use strict";function t(e,t){var n=o.extend(!0,{duration:200,effect:{open:o.fn.fadeIn,close:o.fn.fadeOut},overlay:{opacity:.6,zIndex:9e3},closeClass:m+"-close"},t);return n.overlay.fillColor=n.overlay.fillColor||n.overlay.color||"#888",n.zIndex=n.zIndex||n.overlay.zIndex+1,r||(r=o(window),f=o('<div class="'+m+'-overlay" />').css({position:"fixed",left:0,top:0,width:"100%",height:"150%",display:"none"}).appendTo(c=o("body")).click(l).on("touchmove",function(){return!1}),o(document).focusin(function(e){C&&!C.has(e.target).length&&(s?s.focus():o(document.activeElement).blur())}).keydown(function(o){return C&&27===o.keyCode?l(o):void 0})),e.each(function(){var e=o(this),t={position:"fixed",display:"none",zIndex:n.zIndex};n.offset?("function"!=typeof n.offset&&(t.left=n.offset.left,t.top=n.offset.top),t.marginLeft=t.marginTop=""):(t.left=t.top="50%",t.marginLeft="-"+e.outerWidth()/2+"px",t.marginTop="-"+e.outerHeight()/2+"px"),n.closeClass&&e.find("."+n.closeClass).off("click",l).click(l),"function"==typeof n.open&&e.off(y,n.open).on(y,n.open),"function"==typeof n.close&&e.off(x,n.close).on(x,n.close),e.css(t).data(h,n).appendTo(c).on("touchmove",function(){return!1})})}function n(e,n){var l,m,x,I,w,z;return null===C&&e.length&&(l=e.eq(0),(n||!(m=l.data(h)))&&(m=t(l,n).data(h)),x=c.get(0).style,u=x.overflow,I=c.prop("clientWidth"),w=c.prop("clientHeight"),c.css("overflow","hidden"),I-=c.prop("clientWidth"),w-=c.prop("clientHeight"),d=x.marginRight,p=x.marginBottom,0>I&&c.css("marginRight","+="+-I),0>w&&c.css("marginBottom","+="+-w),a=o(document.activeElement).blur(),s=null,v=r.scrollLeft(),g=r.scrollTop(),r.scroll(i),"function"==typeof m.offset&&(z=m.offset.call(l),l.css({left:z.left,top:z.top})),m.effect.open.call(l,m.duration||1,function(){l.find("a,input,select,textarea,button,object,area,img,map").each(function(){var e=o(this);return e.focus().get(0)===document.activeElement?(s=e,!1):void 0}),C=l.trigger(y)}),f.css({backgroundColor:m.overlay.fillColor,zIndex:m.overlay.zIndex}).fadeTo(m.duration,m.overlay.opacity),C=0),e}function l(t){var n,l,s=t instanceof o.Event;return C&&(n=s?C:function(){var o=t.index(C);return o>-1?t.eq(o):e}(),n&&(l=n.data(h),l.effect.close.call(n,l.duration||1,function(){c.css({overflow:u,marginRight:d,marginBottom:p}),a&&a.length&&a.focus(),r.off("scroll",i).scrollLeft(v).scrollTop(g),n.trigger(x),C=null}),f.fadeOut(l.duration),C=0)),s?(t.preventDefault(),!1):t}function i(o){return r.scrollLeft(v).scrollTop(g),o.preventDefault(),!1}var r,c,f,a,s,u,d,p,v,g,h="plainModal",m=h.toLowerCase(),y=m+"open",x=m+"close",C=null;o.fn[h]=function(o,e){return"open"===o?n(this,e):"close"===o?l(this):t(this,o)}}(jQuery);