Merge pull request #4289 from jaredcobb/master

Make frontend scripts safe to run on non WC pages (check for objects)
This commit is contained in:
Coen Jacobs 2013-12-05 01:06:37 -08:00
commit bba10ae005
9 changed files with 44 additions and 7 deletions

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($){ jQuery(document).ready(function($){
// woocommerce_params is required to continue, ensure the object exists
if (typeof woocommerce_params === "undefined")
return false;
$('#add_payment_method') $('#add_payment_method')
/* Payment option selection */ /* Payment option selection */

View File

@ -415,6 +415,11 @@
}; };
$(function() { $(function() {
// wc_add_to_cart_variation_params is required to continue, ensure the object exists
if (typeof wc_add_to_cart_variation_params === "undefined")
return false;
$('.variations_form').wc_variation_form(); $('.variations_form').wc_variation_form();
$('.variations_form .variations select').change(); $('.variations_form .variations select').change();
}); });

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_add_to_cart_params is required to continue, ensure the object exists
if (typeof wc_add_to_cart_params === "undefined")
return false;
// Ajax add to cart // Ajax add to cart
$(document).on( 'click', '.add_to_cart_button', function() { $(document).on( 'click', '.add_to_cart_button', function() {

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_cart_fragments_params is required to continue, ensure the object exists
if (typeof wc_cart_fragments_params === "undefined")
return false;
/** Cart Handling */ /** Cart Handling */
$supports_html5_storage = ( 'sessionStorage' in window && window['sessionStorage'] !== null ); $supports_html5_storage = ( 'sessionStorage' in window && window['sessionStorage'] !== null );

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_cart_params is required to continue, ensure the object exists
if (typeof wc_cart_params === "undefined")
return false;
// Shipping calculator // Shipping calculator
$(document).on( 'click', '.shipping-calculator-button', function() { $(document).on( 'click', '.shipping-calculator-button', function() {
$('.shipping-calculator-form').slideToggle('slow'); $('.shipping-calculator-form').slideToggle('slow');

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_checkout_params is required to continue, ensure the object exists
if (typeof wc_checkout_params === "undefined")
return false;
var updateTimer; var updateTimer;
var dirtyInput = false; var dirtyInput = false;
var xhr; var xhr;

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_country_select_params is required to continue, ensure the object exists
if (typeof wc_country_select_params === "undefined")
return false;
/* State/Country select boxes */ /* State/Country select boxes */
var states_json = wc_country_select_params.countries.replace(/"/g, '"'); var states_json = wc_country_select_params.countries.replace(/"/g, '"');
var states = $.parseJSON( states_json ); var states = $.parseJSON( states_json );

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// woocommerce_price_slider_params is required to continue, ensure the object exists
if (typeof woocommerce_price_slider_params === "undefined")
return false;
// Get markup ready for slider // Get markup ready for slider
$('input#min_price, input#max_price').hide(); $('input#min_price, input#max_price').hide();
$('.price_slider, .price_label').show(); $('.price_slider, .price_label').show();

View File

@ -1,5 +1,9 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// wc_single_product_params is required to continue, ensure the object exists
if (typeof wc_single_product_params === "undefined")
return false;
// Tabs // Tabs
$('.woocommerce-tabs .panel').hide(); $('.woocommerce-tabs .panel').hide();