diff --git a/dist/jquery.sidr.js b/dist/jquery.sidr.js index 1271f14..9ce9514 100644 --- a/dist/jquery.sidr.js +++ b/dist/jquery.sidr.js @@ -63,6 +63,7 @@ speed = $menu.data('speed'), side = $menu.data('side'), displace = $menu.data('displace'), + closeOthers = $menu.data('closeOthers'), onOpen = $menu.data('onOpen'), onClose = $menu.data('onClose'), bodyAnimation, @@ -78,7 +79,7 @@ } // If another menu opened close first - if(sidrOpened !== false) { + if(sidrOpened !== false && closeOthers === true) { methods.close(sidrOpened, function() { methods.open(name); }); @@ -217,7 +218,8 @@ source : null, // Override the source of the content. renaming : true, // The ids and classes will be prepended with a prefix when loading existent content body : 'body', // Page container selector, - displace: true, // Displace the body content or not + displace : true, // Displace the body content or not + closeOthers : true, // If true, others menus will be closed when sidr opened onOpen : function() {}, // Callback when sidr opened onClose : function() {} // Callback when sidr closed }, options); @@ -240,7 +242,8 @@ speed : settings.speed, side : settings.side, body : settings.body, - displace : settings.displace, + displace : settings.displace, + closeOthers : settings.closeOthers, onOpen : settings.onOpen, onClose : settings.onClose }); diff --git a/package.json b/package.json index e0f288e..980b0d6 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,10 @@ }, "devDependencies": { "grunt": "~0.4.0", + "grunt-contrib-compass": "^0.8.0", + "grunt-contrib-concat": "~0.1.3", "grunt-contrib-jshint": "~0.1.1", "grunt-contrib-uglify": "~0.1.2", - "grunt-contrib-concat": "~0.1.3", - "grunt-contrib-compass": "~0.1.3", "grunt-contrib-watch": "~0.3.1" } } diff --git a/package/jquery.sidr.min.js b/package/jquery.sidr.min.js new file mode 100644 index 0000000..38ec185 --- /dev/null +++ b/package/jquery.sidr.min.js @@ -0,0 +1,4 @@ +/*! Sidr - v1.2.1 - 2014-06-24 + * https://github.com/artberri/sidr + * Copyright (c) 2014 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,r){"function"==typeof s?(r=s,s="sidr"):s||(s="sidr");var a,d,l,c=e("#"+s),u=e(c.data("body")),f=e("html"),p=c.outerWidth(!0),h=c.data("speed"),g=c.data("side"),m=c.data("displace"),v=c.data("closeOthers"),y=c.data("onOpen"),x=c.data("onClose"),C="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&&v===!0)return o.close(i,function(){o.open(s)}),void 0;t=!0,"left"===g?(a={left:p+"px"},d={left:"0px"}):(a={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(a,h,function(){e(this).addClass(C)}):setTimeout(function(){e(this).addClass(C)},h),c.css("display","block").animate(d,h,function(){t=!1,i=s,"function"==typeof r&&r(s),u.removeClass("sidr-animating")}),y()}else{if(!c.is(":visible")||t)return;t=!0,"left"===g?(a={left:0},d={left:"-"+p+"px"}):(a={right:0},d={right:"-"+p+"px"}),u.is("body")&&(l=f.scrollTop(),f.removeAttr("style").scrollTop(l)),u.addClass("sidr-animating").animate(a,h).removeClass(C),c.animate(d,h,function(){c.removeAttr("style").hide(),u.removeAttr("style"),e("html").removeAttr("style"),t=!1,i=!1,"function"==typeof r&&r(s),u.removeClass("sidr-animating")}),x()}}},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,closeOthers:!0,onOpen:function(){},onClose:function(){}},t),s=i.name,r=e("#"+s);if(0===r.length&&(r=e("
").attr("id",s).appendTo(e("body"))),r.addClass("sidr").addClass(i.side).data({speed:i.speed,side:i.side,body:i.body,displace:i.displace,closeOthers:i.closeOthers,onOpen:i.onOpen,onClose:i.onClose}),"function"==typeof i.source){var a=i.source(s);n.loadContent(r,a)}else if("string"==typeof i.source&&n.isUrl(i.source))e.get(i.source,function(e){n.loadContent(r,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(r,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); \ No newline at end of file diff --git a/src/jquery.sidr.js b/src/jquery.sidr.js index 1271f14..9ce9514 100644 --- a/src/jquery.sidr.js +++ b/src/jquery.sidr.js @@ -63,6 +63,7 @@ speed = $menu.data('speed'), side = $menu.data('side'), displace = $menu.data('displace'), + closeOthers = $menu.data('closeOthers'), onOpen = $menu.data('onOpen'), onClose = $menu.data('onClose'), bodyAnimation, @@ -78,7 +79,7 @@ } // If another menu opened close first - if(sidrOpened !== false) { + if(sidrOpened !== false && closeOthers === true) { methods.close(sidrOpened, function() { methods.open(name); }); @@ -217,7 +218,8 @@ source : null, // Override the source of the content. renaming : true, // The ids and classes will be prepended with a prefix when loading existent content body : 'body', // Page container selector, - displace: true, // Displace the body content or not + displace : true, // Displace the body content or not + closeOthers : true, // If true, others menus will be closed when sidr opened onOpen : function() {}, // Callback when sidr opened onClose : function() {} // Callback when sidr closed }, options); @@ -240,7 +242,8 @@ speed : settings.speed, side : settings.side, body : settings.body, - displace : settings.displace, + displace : settings.displace, + closeOthers : settings.closeOthers, onOpen : settings.onOpen, onClose : settings.onClose });