Index: branches/1.0.x/inc/js/jquery.scripts.js =================================================================== diff -u -N -r15015 -r15019 --- branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 15015) +++ branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 15019) @@ -234,36 +234,27 @@ function add_to_cart_handler() { var $me = $(this), - $qty = $me.attr('qty_id') !== undefined ? parseInt($('#' + $me.attr('qty_id')).val()) : 1; + $qty = $me.attr('qty_id') !== undefined ? get_cart_qty('#' + $me.attr('qty_id')) : 1, + $url = $me.attr('href'); + if ( $url.indexOf('bubble') == -1 ) { + // proceed with regular redirect + return true; + } if ( $me.hasClass('addedtocart') ) { // disabled button return false; } - if ( isNaN($qty) ) { - $qty = 1; - } + var $timer_id = $('.basketStatus').data('hide_timer'); - var $bubble = $('.basketStatus'), - $timer_id = $bubble.data('hide_timer'); - clearTimeout($timer_id); $.get( - $me.attr('href') + '&qty=' + $qty, + $url + '&qty=' + $qty, function ($bubble_content) { - $('.basketContent', $bubble).html( $bubble_content.replace(/#QTY#/g, $qty) ); - $bubble - .stop(true, true) - .fadeIn( - 'slow', - function () { - var $timer = setTimeout(function(){ $bubble.fadeOut('slow'); }, 2000); - $bubble.data('hide_timer', $timer); - } - ); + display_cart_bubble($bubble_content, $qty); if ( $me.hasClass('addtocart') ) { $me.removeClass('addtocart').addClass('addedtocart').html('Added to Cart'); @@ -274,6 +265,31 @@ return false; } +function get_cart_qty ($qty_selector) { + var $ret = parseInt( $($qty_selector).val() ); + + if ( isNaN($ret) ) { + $ret = 1; + } + + return $ret; +} + +function display_cart_bubble ($bubble_content, $qty) { + var $bubble = $('.basketStatus'); + + $('.basketContent', $bubble).html( $bubble_content.replace(/#QTY#/g, $qty) ); + $bubble + .stop(true, true) + .fadeIn( + 'slow', + function () { + var $timer = setTimeout(function(){ $bubble.fadeOut('slow'); }, 2000); + $bubble.data('hide_timer', $timer); + } + ); +} + /* === Startup === */ $(document).ready( function() { @@ -288,6 +304,6 @@ } ); - $('.addtocart, .button-addtocart').click(add_to_cart_handler); + $('.addtocart').click(add_to_cart_handler); } ); \ No newline at end of file