/*! sidr - v1.2.1 - 2013-11-06 * https://github.com/artberri/sidr * copyright (c) 2013 alberto varela; licensed mit */ (function(e){var t=!1,i=!1,n={isurl:function(e){var t=regexp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i");return t.test(e)?!0:!1},loadcontent:function(e,t){e.html(t)},addprefix:function(e){var t=e.attr("id"),i=e.attr("class");"string"==typeof t&&""!==t&&e.attr("id",t.replace(/([a-za-z0-9_.\-]+)/g,"sidr-id-$1")),"string"==typeof i&&""!==i&&"sidr-inner"!==i&&e.attr("class",i.replace(/([a-za-z0-9_.\-]+)/g,"sidr-class-$1")),e.removeattr("style")},execute:function(n,s,a){"function"==typeof s?(a=s,s="sidr"):s||(s="sidr");var r,d,l,c=e("#"+s),u=e(c.data("body")),f=e("html"),p=c.outerwidth(!0),g=c.data("speed"),h=c.data("side"),m=c.data("displace"),v=c.data("onopen"),y=c.data("onclose"),x="sidr"===s?"sidr-open":"sidr-open "+s+"-open";if("open"===n||"toggle"===n&&!c.is(":visible")){if(c.is(":visible")||t)return;if(i!==!1)return o.close(i,function(){o.open(s)}),void 0;t=!0,"left"===h?(r={left:p+"px"},d={left:"0px"}):(r={right:p+"px"},d={right:"0px"}),u.is("body")&&(l=f.scrolltop(),f.css("overflow-x","hidden").scrolltop(l)),m?u.addclass("sidr-animating").css({width:u.width(),position:"absolute"}).animate(r,g,function(){e(this).addclass(x)}):settimeout(function(){e(this).addclass(x)},g),c.css("display","block").animate(d,g,function(){t=!1,i=s,"function"==typeof a&&a(s),u.removeclass("sidr-animating")}),v()}else{if(!c.is(":visible")||t)return;t=!0,"left"===h?(r={left:0},d={left:"-"+p+"px"}):(r={right:0},d={right:"-"+p+"px"}),u.is("body")&&(l=f.scrolltop(),f.removeattr("style").scrolltop(l)),u.addclass("sidr-animating").animate(r,g).removeclass(x),c.animate(d,g,function(){c.removeattr("style").hide(),u.removeattr("style"),e("html").removeattr("style"),t=!1,i=!1,"function"==typeof a&&a(s),u.removeclass("sidr-animating")}),y()}}},o={open:function(e,t){n.execute("open",e,t)},close:function(e,t){n.execute("close",e,t)},toggle:function(e,t){n.execute("toggle",e,t)},toogle:function(e,t){n.execute("toggle",e,t)}};e.sidr=function(t){return o[t]?o[t].apply(this,array.prototype.slice.call(arguments,1)):"function"!=typeof t&&"string"!=typeof t&&t?(e.error("method "+t+" does not exist on jquery.sidr"),void 0):o.toggle.apply(this,arguments)},e.fn.sidr=function(t){var i=e.extend({name:"sidr",speed:200,side:"left",source:null,renaming:!0,body:"body",displace:!0,onopen:function(){},onclose:function(){}},t),s=i.name,a=e("#"+s);if(0===a.length&&(a=e("
").attr("id",s).appendto(e("body"))),a.addclass("sidr").addclass(i.side).data({speed:i.speed,side:i.side,body:i.body,displace:i.displace,onopen:i.onopen,onclose:i.onclose}),"function"==typeof i.source){var r=i.source(s);n.loadcontent(a,r)}else if("string"==typeof i.source&&n.isurl(i.source))e.get(i.source,function(e){n.loadcontent(a,e)});else if("string"==typeof i.source){var d="",l=i.source.split(",");if(e.each(l,function(t,i){d+='
'+e(i).html()+"
"}),i.renaming){var c=e("
").html(d);c.find("*").each(function(t,i){var o=e(i);n.addprefix(o)}),d=c.html()}n.loadcontent(a,d)}else null!==i.source&&e.error("invalid sidr source");return this.each(function(){var t=e(this),i=t.data("sidr");i||(t.data("sidr",s),"ontouchstart"in document.documentelement?(t.bind("touchstart",function(e){e.originalevent.touches[0],this.touched=e.timestamp}),t.bind("touchend",function(e){var t=math.abs(e.timestamp-this.touched);200>t&&(e.preventdefault(),o.toggle(s))})):t.click(function(e){e.preventdefault(),o.toggle(s)}))})}})(jquery);