From fc84aacd14774b048d2c53159508a9947e731e74 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 1 Feb 2013 15:04:10 +0000 Subject: [PATCH] Modify trigger. Closes #2324, #2323 --- assets/js/frontend/add-to-cart.js | 2 +- assets/js/frontend/add-to-cart.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/frontend/add-to-cart.js b/assets/js/frontend/add-to-cart.js index 5e9cca9546d68..84327338a8a06 100644 --- a/assets/js/frontend/add-to-cart.js +++ b/assets/js/frontend/add-to-cart.js @@ -21,7 +21,7 @@ jQuery(document).ready(function($) { }; // Trigger event - $('body').trigger('adding_to_cart'); + $('body').trigger( 'adding_to_cart', [ $thisbutton, data ] ); // Ajax action $.post( woocommerce_params.ajax_url, data, function( response ) { diff --git a/assets/js/frontend/add-to-cart.min.js b/assets/js/frontend/add-to-cart.min.js index 3fb17e1b41009..45689fb32b54a 100644 --- a/assets/js/frontend/add-to-cart.min.js +++ b/assets/js/frontend/add-to-cart.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart");e.post(woocommerce_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");t.removeClass("loading");if(n.error&&n.product_url){window.location=n.product_url;return}fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.parent().find(".added_to_cart").size()==0&&t.addClass("added").after(' '+woocommerce_params.i18n_view_cart+"");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})}); \ No newline at end of file +jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart",[t,n]);e.post(woocommerce_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");t.removeClass("loading");if(n.error&&n.product_url){window.location=n.product_url;return}fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.parent().find(".added_to_cart").size()==0&&t.addClass("added").after(' '+woocommerce_params.i18n_view_cart+"");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})}); \ No newline at end of file