From a9f8fbb3f79eeb17dba693517f875022496f7fe5 Mon Sep 17 00:00:00 2001 From: Zach Date: Wed, 11 Apr 2012 15:09:06 -0500 Subject: [PATCH] Added two pieces to this little script, the previous and next controls as well as an option to turn off the automated height cropping if you needed to control the slide but did not want the image height to dictate the visible space. --- jquery.blueberry.js | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/jquery.blueberry.js b/jquery.blueberry.js index 7c0a032..8d4bd64 100644 --- a/jquery.blueberry.js +++ b/jquery.blueberry.js @@ -31,6 +31,7 @@ height: 'auto', //reserved hoverpause: false, pager: true, + setheight: true, nav: true, //reserved keynav: true } @@ -132,49 +133,52 @@ }); } - //calculate and set height based on image width/height ratio and specified line height - var setsize = function(){ - sliderWidth = $('.slides', obj).width(); - cropHeight = Math.floor(((sliderWidth/imgRatio)/o.lineheight))*o.lineheight; - - $('.slides', obj).css({height: cropHeight}); - }; - setsize(); - - //bind setsize function to window resize event - $(window).resize(function(){ - setsize(); - }); - - - - //Add keyboard navigation - + if(o.setheight) { + //calculate and set height based on image width/height ratio and specified line height + var setsize = function(){ + sliderWidth = $('.slides', obj).width(); + cropHeight = Math.floor(((sliderWidth/imgRatio)/o.lineheight))*o.lineheight; + $('.slides', obj).css({height: cropHeight}); + }; + setsize(); + + //bind setsize function to window resize event + $(window).resize(function(){ + setsize(); + }); + } + + //Add keyboard navigation if(o.keynav){ - $(document).keyup(function(e){ - - switch (e.which) { - - case 39: case 32: //right arrow & space - - clearTimeout(obj.play); - - rotate(); - - break; - + $(document).keyup(function(e){ + switch (e.which) { + case 39: case 32: //right arrow & space + clearTimeout(obj.play); + rotate(); + break; case 37: // left arrow clearTimeout(obj.play); next = current - 1; - rotate(); - + rotate(); break; - } - + } }); } + //Add previous and next nav controls + if(o.nav){ + $('#next').click(function(){ + clearTimeout(obj.play); + rotate(); + }); + + $('#back').click(function(){ + clearTimeout(obj.play); + next = current - 1; + rotate(); + }); + } }); }