!function(a,b,c,d){a.fn.sidebar=function(b){var e,f=a(this),g=a.isPlainObject(b)?a.extend(!0,{},a.fn.sidebar.settings,b):a.fn.sidebar.settings,h=(g.selector,g.className),i=g.namespace,j=g.error,k="."+i,l="module-"+i,m=f.selector||"",n=(new Date).getTime(),o=[],p=arguments[0],q="string"==typeof p,r=[].slice.call(arguments,1);return f.each(function(){var b,s=a(this),t=a("body"),u=a("head"),v=a("style[title="+i+"]"),w=this,x=s.data(l);b={initialize:function(){b.debug("Initializing sidebar",s),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),x=b,s.data(l,b)},destroy:function(){b.verbose("Destroying previous module for",s),s.off(k).removeData(l)},refresh:function(){b.verbose("Refreshing selector cache"),v=a("style[title="+i+"]")},attachEvents:function(c,d){var e=a(c);d=a.isFunction(b[d])?b[d]:b.toggle,e.size()>0?(b.debug("Attaching sidebar events to element",c,d),e.off(k).on("click"+k,d)):b.error(j.notFound)},show:function(){b.debug("Showing sidebar"),b.is.closed()?(g.overlay||b.pushPage(),b.set.active()):b.debug("Sidebar is already visible")},hide:function(){b.is.open()&&(g.overlay||(b.pullPage(),b.remove.pushed()),b.remove.active())},toggle:function(){b.is.closed()?b.show():b.hide()},pushPage:function(){var a=b.get.direction(),c=b.is.vertical()?s.outerHeight():s.outerWidth();g.useCSS?(b.debug("Using CSS to animate body"),b.add.bodyCSS(a,c),b.set.pushed()):b.animatePage(a,c,b.set.pushed)},pullPage:function(){var a=b.get.direction();g.useCSS?(b.debug("Resetting body position css"),b.remove.bodyCSS()):(b.debug("Resetting body position using javascript"),b.animatePage(a,0)),b.remove.pushed()},animatePage:function(a,c){var d={};d["padding-"+a]=c,b.debug("Using javascript to animate body",d),t.animate(d,g.duration,b.set.pushed)},add:{bodyCSS:function(a,c){var d;a!==h.bottom&&(d='"),u.append(d),b.debug("Adding body css to head",v)}},remove:{bodyCSS:function(){b.debug("Removing body css styles",v),b.refresh(),v.remove()},active:function(){s.removeClass(h.active)},pushed:function(){b.verbose("Removing body push state",b.get.direction()),t.removeClass(h[b.get.direction()]).removeClass(h.pushed)}},set:{active:function(){s.addClass(h.active)},pushed:function(){b.verbose("Adding body push state",b.get.direction()),t.addClass(h[b.get.direction()]).addClass(h.pushed)}},get:{direction:function(){return s.hasClass(h.top)?h.top:s.hasClass(h.right)?h.right:s.hasClass(h.bottom)?h.bottom:h.left},transitionEvent:function(){var a,b=c.createElement("element"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in e)if(b.style[a]!==d)return e[a]}},is:{open:function(){return s.is(":animated")||s.hasClass(h.active)},closed:function(){return!b.is.open()},vertical:function(){return s.hasClass(h.top)}},setting:function(b,c){return c===d?g[b]:(a.isPlainObject(b)?a.extend(!0,g,b):g[b]=c,void 0)},internal:function(c,e){return e===d?b[c]:(a.isPlainObject(c)?a.extend(!0,b,c):b[c]=e,void 0)},debug:function(){g.debug&&(g.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,g.name+":"),b.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,g.name+":"),b.error.apply(console,arguments)},performance:{log:function(a){var c,d,e;g.performance&&(c=(new Date).getTime(),e=n||c,d=c-e,n=c,o.push({Element:w,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":d})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var c=g.name+":",e=0;n=!1,clearTimeout(b.performance.timer),a.each(o,function(a,b){e+=b["Execution Time"]}),c+=" "+e+"ms",m&&(c+=" '"+m+"'"),f.size()>1&&(c+=" ("+f.size()+")"),(console.group!==d||console.table!==d)&&o.length>0&&(console.groupCollapsed(c),console.table?console.table(o):a.each(o,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),o=[]}},invoke:function(c,f,g){var h,i,k;return f=f||r,g=w||g,"string"==typeof c&&x!==d&&(c=c.split(/[\. ]/),h=c.length-1,a.each(c,function(e,f){var g=e!=h?f+c[e+1].charAt(0).toUpperCase()+c[e+1].slice(1):c;if(a.isPlainObject(x[f])&&e!=h)x=x[f];else{if(!a.isPlainObject(x[g])||e==h)return x[f]!==d?(i=x[f],!1):x[g]!==d?(i=x[g],!1):(b.error(j.method),!1);x=x[g]}})),a.isFunction(i)?k=i.apply(g,f):i!==d&&(k=i),a.isArray(e)?e.push(k):"string"==typeof e?e=[e,k]:k!==d&&(e=k),i}},q?(x===d&&b.initialize(),b.invoke(p)):(x!==d&&b.destroy(),b.initialize())}),e!==d?e:this},a.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",verbose:!0,debug:!0,performance:!0,useCSS:!0,overlay:!1,duration:300,side:"left",onChange:function(){},onShow:function(){},onHide:function(){},className:{active:"active",pushed:"pushed",top:"top",left:"left",right:"right",bottom:"bottom"},error:{method:"The method you called is not defined.",notFound:"There were no elements that matched the specified selector"}}}(jQuery,window,document);