Index: branches/1.0.x/inc/js/jquery.scripts.js =================================================================== diff -u -N -r14890 -r14907 --- branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 14890) +++ branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 14907) @@ -86,6 +86,36 @@ return $sorted_object; } +function compare_product($product_id, $compare_event, $callback) { + if ( $compare_event === undefined || $compare_event === true ) { + $compare_event = 'OnAddToCompare'; + } + else if ( $compare_event === false ) { + $compare_event = 'OnRemoveFromCompare'; + } + + var $url = FormManager.getURL('p', 'elements/side_boxes/compare.elm', $compare_event); + + $.get( + $url, + {'p_id': $product_id}, + function ($data) { + $('#compare-products-sidebox').replaceWith($data); + + if ( $callback !== undefined && $.isFunction($callback) ) { + $callback($data); + } + } + ); + + return false; +} + +function redirect($url) +{ + window.location.href = $url; +} + /* === DBlocks class === */ function DBlocks() { var $me = this; @@ -171,63 +201,62 @@ ) } -/* === Startup === */ -$(document).ready( - function() { - watch_anchor(); +function add_to_cart_handler() { + var $me = $(this), + $qty = $me.attr('qty_id') !== undefined ? parseInt($('#' + $me.attr('qty_id')).val()) : 1; - $('#change-password').click( - function($e) { - $('#password-show').hide(); - $('#password-block').fadeIn(); - return false; - } - ); + if ( $me.hasClass('addedtocart') ) { + // disabled button + return false; + } + if ( isNaN($qty) ) { + $qty = 1; + } - $('.addtocart, .button-addtocart').click( - function () { - var $me = $(this), - $qty = $me.attr('qty_id') !== undefined ? parseInt($('#' + $me.attr('qty_id')).val()) : 1; + var $bubble = $('.basketStatus'), + $timer_id = $bubble.data('hide_timer'); + clearTimeout($timer_id); - if ( $me.hasClass('addedtocart') ) { - // disabled button - return false; + $.get( + $me.attr('href') + '&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); } + ); - if ( isNaN($qty) ) { - $qty = 1; - } + if ( $me.hasClass('addtocart') ) { + $me.removeClass('addtocart').addClass('addedtocart').html('Added to Cart'); + } + } + ); - var $bubble = $('.basketStatus'), - $timer_id = $bubble.data('hide_timer'); + return false; +} - clearTimeout($timer_id); +/* === Startup === */ +$(document).ready( + function() { + watch_anchor(); - $.get( - $me.attr('href') + '&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); - } - ); + $('#change-password').click( + function($e) { + $('#password-show').hide(); + $('#password-block').fadeIn(); - if ( $me.hasClass('addtocart') ) { - $me.removeClass('addtocart').addClass('addedtocart').html('Added to Cart'); - } - } - ); - return false; } ); + + $('.addtocart, .button-addtocart').click(add_to_cart_handler); } ); \ No newline at end of file