var slidebars;!function(i){slidebars=function(){var e=i("[canvas]"),t={},r=!1,n=!1,s=["top","right","bottom","left"],a=["reveal","push","overlay","shift"],o=function(r){var n=i(),s="0px, 0px",a=1e3*parseFloat(t[r].element.css("transitionDuration"),10);return"reveal"!==t[r].style&&"push"!==t[r].style&&"shift"!==t[r].style||(n=n.add(e)),"push"!==t[r].style&&"overlay"!==t[r].style&&"shift"!==t[r].style||(n=n.add(t[r].element)),t[r].active&&("top"===t[r].side?s="0px, "+t[r].element.css("height"):"right"===t[r].side?s="-"+t[r].element.css("width")+", 0px":"bottom"===t[r].side?s="0px, -"+t[r].element.css("height"):"left"===t[r].side&&(s=t[r].element.css("width")+", 0px")),{elements:n,amount:s,duration:a}},l=function(i,e,r,n){if(d(i))throw"Error registering Slidebar, a Slidebar with id '"+i+"' already exists.";t[i]={id:i,side:e,style:r,element:n,active:!1}},d=function(i){return!!t.hasOwnProperty(i)};this.init=function(e){if(r)throw"Slidebars has already been initialized.";n||(i("[off-canvas]").each(function(){var e=i(this).attr("off-canvas").split(" ",3);if(!e||!e[0]||-1===s.indexOf(e[1])||-1===a.indexOf(e[2]))throw"Error registering Slidebar, please specifiy a valid id, side and style'.";l(e[0],e[1],e[2],i(this))}),n=!0),r=!0,this.css(),i(h).trigger("init"),"function"==typeof e&&e()},this.exit=function(e){if(!r)throw"Slidebars hasn't been initialized.";var t=function(){r=!1,i(h).trigger("exit"),"function"==typeof e&&e()};this.getActiveSlidebar()?this.close(t):t()},this.css=function(e){if(!r)throw"Slidebars hasn't been initialized.";for(var n in t)if(d(n)){var s;s="top"===t[n].side||"bottom"===t[n].side?t[n].element.css("height"):t[n].element.css("width"),"push"!==t[n].style&&"overlay"!==t[n].style&&"shift"!==t[n].style||t[n].element.css("margin-"+t[n].side,"-"+s)}this.getActiveSlidebar()&&this.open(this.getActiveSlidebar()),i(h).trigger("css"),"function"==typeof e&&e()},this.open=function(e,n){if(!r)throw"Slidebars hasn't been initialized.";if(!e)throw"You must pass a Slidebar id.";if(!d(e))throw"Error opening Slidebar, there is no Slidebar with id '"+e+"'.";var s=function(){t[e].active=!0,t[e].element.css("display","block"),i(h).trigger("opening",[t[e].id]);var r=o(e);r.elements.css({"transition-duration":r.duration+"ms",transform:"translate("+r.amount+")"}),setTimeout(function(){i(h).trigger("opened",[t[e].id]),"function"==typeof n&&n()},r.duration)};this.getActiveSlidebar()&&this.getActiveSlidebar()!==e?this.close(s):s()},this.close=function(e,n){if("function"==typeof e&&(n=e,e=null),!r)throw"Slidebars hasn't been initialized.";if(e&&!d(e))throw"Error closing Slidebar, there is no Slidebar with id '"+e+"'.";if(e||(e=this.getActiveSlidebar()),e&&t[e].active){t[e].active=!1,i(h).trigger("closing",[t[e].id]);var s=o(e);s.elements.css("transform",""),setTimeout(function(){s.elements.css("transition-duration",""),t[e].element.css("display",""),i(h).trigger("closed",[t[e].id]),"function"==typeof n&&n()},s.duration)}},this.toggle=function(i,e){if(!r)throw"Slidebars hasn't been initialized.";if(!i)throw"You must pass a Slidebar id.";if(!d(i))throw"Error toggling Slidebar, there is no Slidebar with id '"+i+"'.";t[i].active?this.close(i,function(){"function"==typeof e&&e()}):this.open(i,function(){"function"==typeof e&&e()})},this.isActive=function(){return r},this.isActiveSlidebar=function(i){if(!r)throw"Slidebars hasn't been initialized.";if(!i)throw"You must provide a Slidebar id.";if(!d(i))throw"Error retrieving Slidebar, there is no Slidebar with id '"+i+"'.";return t[i].active},this.getActiveSlidebar=function(){if(!r)throw"Slidebars hasn't been initialized.";var i=!1;for(var e in t)if(d(e)&&t[e].active){i=t[e].id;break}return i},this.getSlidebars=function(){if(!r)throw"Slidebars hasn't been initialized.";var i=[];for(var e in t)d(e)&&i.push(t[e].id);return i},this.getSlidebar=function(i){if(!r)throw"Slidebars hasn't been initialized.";if(!i)throw"You must pass a Slidebar id.";if(!d(i))throw"Error retrieving Slidebar, there is no Slidebar with id '"+i+"'.";return t[i]},this.events={};var h=this.events;i(window).on("resize",this.css.bind(this))}}(jQuery);