!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(o,e){return void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(o)),n(e),e}:n(jQuery)}(function(n){n.fn.simplerSidebar=function(o){var e=n.extend(!0,{attr:"simplersidebar",top:0,gap:64,zIndex:3e3,sidebar:{width:300},animation:{duration:500,easing:"swing"},events:{on:{animation:{open:function(){},close:function(){},both:function(){}}},callbacks:{animation:{open:function(){},close:function(){},both:function(){},freezePage:!0}}},mask:{display:!0,css:{backgroundColor:"black",opacity:.5,filter:"Alpha(opacity=50)"}}},o);return this.each(function(){var o,t,i,a="data-"+e.attr,s="opened"===e.init?"opened":"closed",c=e.overflow?e.overflow:n("html").css("overflow"),d=e.overflow?e.overflow:n("body").css("overflow"),r="left"===e.align?"left":"right",l=e.animation.duration,f=e.animation.easing,u={},p=!0===e.events.callbacks.animation.freezePage,m=function(){n("body, html").css("overflow","hidden")},b=n(this),h=function(n){return n<e.sidebar.width+e.gap?n-e.gap:e.sidebar.width},w=function(){return b.attr(a)},v=function(n){b.attr(a,n)},y=n("<div>").attr(a,"mask"),k=n(e.selectors.trigger),g=e.selectors.quitter?e.selectors.quitter:"a",x=n(window).width(),z={animation:{open:function(){y.fadeIn(l),v("opened"),e.events.on.animation.open()},close:function(){y.fadeOut(l),v("closed"),e.events.on.animation.close()},both:function(){e.events.on.animation.both()}}},I={animation:{open:function(){p&&m(),e.events.callbacks.animation.open()},close:function(){p&&(n("html").css("overflow",c),n("body").css("overflow",d)),e.events.callbacks.animation.close()},both:function(){e.events.callbacks.animation.both()}}},q=function(){u[r]=-b.width(),b.animate(u,l,f,function(){I.animation.close(),I.animation.both()}),z.animation.close(),z.animation.both()};(o={position:"fixed",top:parseInt(e.top),bottom:0,width:h(x),zIndex:e.zIndex})[r]="closed"===s?-h(x):0,p&&"opened"===s&&m(),b.css(o).attr(a,s),(t={position:"fixed",top:parseInt(e.top),right:0,bottom:0,left:0,zIndex:e.zIndex-1,display:"none"}).display="opened"===s?"block":"none",i=n.extend(!0,t,e.mask.css),e.mask.display&&y.appendTo("body").css(i),k.click(function(){switch(w()){case"opened":q();break;case"closed":u[r]=0,b.animate(u,l,f,function(){I.animation.open(),I.animation.both()}),z.animation.open(),z.animation.both()}}),y.click(q),b.on("click",g,q),n(window).resize(function(){var o=n(window).width();b.css("width",h(o)),"closed"===w()&&b.css(r,-b.width())})})}});