password-strength-meter.js000064400000007330150732340420011715 0ustar00/* global wp, pwsL10n, wc_password_strength_meter_params */ jQuery( function( $ ) { 'use strict'; /** * Password Strength Meter class. */ var wc_password_strength_meter = { /** * Initialize strength meter actions. */ init: function() { $( document.body ) .on( 'keyup change', 'form.register #reg_password, form.checkout #account_password, ' + 'form.edit-account #password_1, form.lost_reset_password #password_1', this.strengthMeter ); $( 'form.checkout #createaccount' ).trigger( 'change' ); }, /** * Strength Meter. */ strengthMeter: function() { var wrapper = $( 'form.register, form.checkout, form.edit-account, form.lost_reset_password' ), submit = $( 'button[type="submit"]', wrapper ), field = $( '#reg_password, #account_password, #password_1', wrapper ), strength = 1, fieldValue = field.val(), stop_checkout = ! wrapper.is( 'form.checkout' ); // By default is disabled on checkout. wc_password_strength_meter.includeMeter( wrapper, field ); strength = wc_password_strength_meter.checkPasswordStrength( wrapper, field ); // Allow password strength meter stop checkout. if ( wc_password_strength_meter_params.stop_checkout ) { stop_checkout = true; } if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && -1 !== strength && stop_checkout ) { submit.attr( 'disabled', 'disabled' ).addClass( 'disabled' ); } else { submit.prop( 'disabled', false ).removeClass( 'disabled' ); } }, /** * Include meter HTML. * * @param {Object} wrapper * @param {Object} field */ includeMeter: function( wrapper, field ) { var meter = wrapper.find( '.woocommerce-password-strength' ); if ( '' === field.val() ) { meter.hide(); $( document.body ).trigger( 'wc-password-strength-hide' ); } else if ( 0 === meter.length ) { field.after( '
' ); $( document.body ).trigger( 'wc-password-strength-added' ); } else { meter.show(); $( document.body ).trigger( 'wc-password-strength-show' ); } }, /** * Check password strength. * * @param {Object} field * * @return {Int} */ checkPasswordStrength: function( wrapper, field ) { var meter = wrapper.find( '.woocommerce-password-strength' ), hint = wrapper.find( '.woocommerce-password-hint' ), hint_html = '' + wc_password_strength_meter_params.i18n_password_hint + '', strength = wp.passwordStrength.meter( field.val(), wp.passwordStrength.userInputDisallowedList() ), error = ''; // Reset. meter.removeClass( 'short bad good strong' ); hint.remove(); if ( meter.is( ':hidden' ) ) { return strength; } // Error to append if ( strength < wc_password_strength_meter_params.min_password_strength ) { error = ' - ' + wc_password_strength_meter_params.i18n_password_error; } switch ( strength ) { case 0 : meter.addClass( 'short' ).html( pwsL10n['short'] + error ); meter.after( hint_html ); break; case 1 : meter.addClass( 'bad' ).html( pwsL10n.bad + error ); meter.after( hint_html ); break; case 2 : meter.addClass( 'bad' ).html( pwsL10n.bad + error ); meter.after( hint_html ); break; case 3 : meter.addClass( 'good' ).html( pwsL10n.good + error ); break; case 4 : meter.addClass( 'strong' ).html( pwsL10n.strong + error ); break; case 5 : meter.addClass( 'short' ).html( pwsL10n.mismatch ); break; } return strength; } }; wc_password_strength_meter.init(); } ); add-to-cart-variation.js000064400000067633150732340420011212 0ustar00/*global wc_add_to_cart_variation_params */ ;(function ( $, window, document, undefined ) { /** * VariationForm class which handles variation forms and attributes. */ var VariationForm = function( $form ) { var self = this; self.$form = $form; self.$attributeFields = $form.find( '.variations select' ); self.$singleVariation = $form.find( '.single_variation' ); self.$singleVariationWrap = $form.find( '.single_variation_wrap' ); self.$resetVariations = $form.find( '.reset_variations' ); self.$product = $form.closest( '.product' ); self.variationData = $form.data( 'product_variations' ); self.useAjax = false === self.variationData; self.xhr = false; self.loading = true; // Initial state. self.$singleVariationWrap.show(); self.$form.off( '.wc-variation-form' ); // Methods. self.getChosenAttributes = self.getChosenAttributes.bind( self ); self.findMatchingVariations = self.findMatchingVariations.bind( self ); self.isMatch = self.isMatch.bind( self ); self.toggleResetLink = self.toggleResetLink.bind( self ); // Events. $form.on( 'click.wc-variation-form', '.reset_variations', { variationForm: self }, self.onReset ); $form.on( 'reload_product_variations', { variationForm: self }, self.onReload ); $form.on( 'hide_variation', { variationForm: self }, self.onHide ); $form.on( 'show_variation', { variationForm: self }, self.onShow ); $form.on( 'click', '.single_add_to_cart_button', { variationForm: self }, self.onAddToCart ); $form.on( 'reset_data', { variationForm: self }, self.onResetDisplayedVariation ); $form.on( 'reset_image', { variationForm: self }, self.onResetImage ); $form.on( 'change.wc-variation-form', '.variations select', { variationForm: self }, self.onChange ); $form.on( 'found_variation.wc-variation-form', { variationForm: self }, self.onFoundVariation ); $form.on( 'check_variations.wc-variation-form', { variationForm: self }, self.onFindVariation ); $form.on( 'update_variation_values.wc-variation-form', { variationForm: self }, self.onUpdateAttributes ); // Init after gallery. setTimeout( function() { $form.trigger( 'check_variations' ); $form.trigger( 'wc_variation_form', self ); self.loading = false; }, 100 ); }; /** * Reset all fields. */ VariationForm.prototype.onReset = function( event ) { event.preventDefault(); event.data.variationForm.$attributeFields.val( '' ).trigger( 'change' ); event.data.variationForm.$form.trigger( 'reset_data' ); }; /** * Reload variation data from the DOM. */ VariationForm.prototype.onReload = function( event ) { var form = event.data.variationForm; form.variationData = form.$form.data( 'product_variations' ); form.useAjax = false === form.variationData; form.$form.trigger( 'check_variations' ); }; /** * When a variation is hidden. */ VariationForm.prototype.onHide = function( event ) { event.preventDefault(); event.data.variationForm.$form .find( '.single_add_to_cart_button' ) .removeClass( 'wc-variation-is-unavailable' ) .addClass( 'disabled wc-variation-selection-needed' ); event.data.variationForm.$form .find( '.woocommerce-variation-add-to-cart' ) .removeClass( 'woocommerce-variation-add-to-cart-enabled' ) .addClass( 'woocommerce-variation-add-to-cart-disabled' ); }; /** * When a variation is shown. */ VariationForm.prototype.onShow = function( event, variation, purchasable ) { event.preventDefault(); if ( purchasable ) { event.data.variationForm.$form .find( '.single_add_to_cart_button' ) .removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' ); event.data.variationForm.$form .find( '.woocommerce-variation-add-to-cart' ) .removeClass( 'woocommerce-variation-add-to-cart-disabled' ) .addClass( 'woocommerce-variation-add-to-cart-enabled' ); } else { event.data.variationForm.$form .find( '.single_add_to_cart_button' ) .removeClass( 'wc-variation-selection-needed' ) .addClass( 'disabled wc-variation-is-unavailable' ); event.data.variationForm.$form .find( '.woocommerce-variation-add-to-cart' ) .removeClass( 'woocommerce-variation-add-to-cart-enabled' ) .addClass( 'woocommerce-variation-add-to-cart-disabled' ); } // If present, the media element library needs initialized on the variation description. if ( wp.mediaelement ) { event.data.variationForm.$form.find( '.wp-audio-shortcode, .wp-video-shortcode' ) .not( '.mejs-container' ) .filter( function () { return ! $( this ).parent().hasClass( 'mejs-mediaelement' ); } ) .mediaelementplayer( wp.mediaelement.settings ); } }; /** * When the cart button is pressed. */ VariationForm.prototype.onAddToCart = function( event ) { if ( $( this ).is('.disabled') ) { event.preventDefault(); if ( $( this ).is('.wc-variation-is-unavailable') ) { window.alert( wc_add_to_cart_variation_params.i18n_unavailable_text ); } else if ( $( this ).is('.wc-variation-selection-needed') ) { window.alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text ); } } }; /** * When displayed variation data is reset. */ VariationForm.prototype.onResetDisplayedVariation = function( event ) { var form = event.data.variationForm; form.$product.find( '.product_meta' ).find( '.sku' ).wc_reset_content(); form.$product .find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ) .wc_reset_content(); form.$product .find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ) .wc_reset_content(); form.$form.trigger( 'reset_image' ); form.$singleVariation.slideUp( 200 ).trigger( 'hide_variation' ); }; /** * When the product image is reset. */ VariationForm.prototype.onResetImage = function( event ) { event.data.variationForm.$form.wc_variations_image_update( false ); }; /** * Looks for matching variations for current selected attributes. */ VariationForm.prototype.onFindVariation = function( event, chosenAttributes ) { var form = event.data.variationForm, attributes = 'undefined' !== typeof chosenAttributes ? chosenAttributes : form.getChosenAttributes(), currentAttributes = attributes.data; if ( attributes.count && attributes.count === attributes.chosenCount ) { if ( form.useAjax ) { if ( form.xhr ) { form.xhr.abort(); } form.$form.block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } ); currentAttributes.product_id = parseInt( form.$form.data( 'product_id' ), 10 ); currentAttributes.custom_data = form.$form.data( 'custom_data' ); form.xhr = $.ajax( { url: wc_add_to_cart_variation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_variation' ), type: 'POST', data: currentAttributes, success: function( variation ) { if ( variation ) { form.$form.trigger( 'found_variation', [ variation ] ); } else { form.$form.trigger( 'reset_data' ); attributes.chosenCount = 0; if ( ! form.loading ) { form.$form .find( '.single_variation' ) .after( '

' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '

' ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); } } }, complete: function() { form.$form.unblock(); } } ); } else { form.$form.trigger( 'update_variation_values' ); var matching_variations = form.findMatchingVariations( form.variationData, currentAttributes ), variation = matching_variations.shift(); if ( variation ) { form.$form.trigger( 'found_variation', [ variation ] ); } else { form.$form.trigger( 'reset_data' ); attributes.chosenCount = 0; if ( ! form.loading ) { form.$form .find( '.single_variation' ) .after( '

' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '

' ); form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 ); } } } } else { form.$form.trigger( 'update_variation_values' ); form.$form.trigger( 'reset_data' ); } // Show reset link. form.toggleResetLink( attributes.chosenCount > 0 ); }; /** * Triggered when a variation has been found which matches all attributes. */ VariationForm.prototype.onFoundVariation = function( event, variation ) { var form = event.data.variationForm, $sku = form.$product.find( '.product_meta' ).find( '.sku' ), $weight = form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ), $dimensions = form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ), $qty_input = form.$singleVariationWrap.find( '.quantity input.qty[name="quantity"]' ), $qty = $qty_input.closest( '.quantity' ), purchasable = true, variation_id = '', template = false, $template_html = ''; if ( variation.sku ) { $sku.wc_set_content( variation.sku ); } else { $sku.wc_reset_content(); } if ( variation.weight ) { $weight.wc_set_content( variation.weight_html ); } else { $weight.wc_reset_content(); } if ( variation.dimensions ) { // Decode HTML entities. $dimensions.wc_set_content( $.parseHTML( variation.dimensions_html )[0].data ); } else { $dimensions.wc_reset_content(); } form.$form.wc_variations_image_update( variation ); if ( ! variation.variation_is_visible ) { template = wp_template( 'unavailable-variation-template' ); } else { template = wp_template( 'variation-template' ); variation_id = variation.variation_id; } $template_html = template( { variation: variation } ); $template_html = $template_html.replace( '/**/', '' ); form.$singleVariation.html( $template_html ); form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( variation.variation_id ).trigger( 'change' ); // Hide or show qty input if ( variation.is_sold_individually === 'yes' ) { $qty_input.val( '1' ).attr( 'min', '1' ).attr( 'max', '' ).trigger( 'change' ); $qty.hide(); } else { var qty_val = parseFloat( $qty_input.val() ); if ( isNaN( qty_val ) ) { qty_val = variation.min_qty; } else { qty_val = qty_val > parseFloat( variation.max_qty ) ? variation.max_qty : qty_val; qty_val = qty_val < parseFloat( variation.min_qty ) ? variation.min_qty : qty_val; } $qty_input.attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty ).val( qty_val ).trigger( 'change' ); $qty.show(); } // Enable or disable the add to cart button if ( ! variation.is_purchasable || ! variation.is_in_stock || ! variation.variation_is_visible ) { purchasable = false; } // Reveal if ( form.$singleVariation.text().trim() ) { form.$singleVariation.slideDown( 200 ).trigger( 'show_variation', [ variation, purchasable ] ); } else { form.$singleVariation.show().trigger( 'show_variation', [ variation, purchasable ] ); } }; /** * Triggered when an attribute field changes. */ VariationForm.prototype.onChange = function( event ) { var form = event.data.variationForm; form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( '' ).trigger( 'change' ); form.$form.find( '.wc-no-matching-variations' ).remove(); if ( form.useAjax ) { form.$form.trigger( 'check_variations' ); } else { form.$form.trigger( 'woocommerce_variation_select_change' ); form.$form.trigger( 'check_variations' ); } // Custom event for when variation selection has been changed form.$form.trigger( 'woocommerce_variation_has_changed' ); }; /** * Escape quotes in a string. * @param {string} string * @return {string} */ VariationForm.prototype.addSlashes = function( string ) { string = string.replace( /'/g, '\\\'' ); string = string.replace( /"/g, '\\\"' ); return string; }; /** * Updates attributes in the DOM to show valid values. */ VariationForm.prototype.onUpdateAttributes = function( event ) { var form = event.data.variationForm, attributes = form.getChosenAttributes(), currentAttributes = attributes.data; if ( form.useAjax ) { return; } // Loop through selects and disable/enable options based on selections. form.$attributeFields.each( function( index, el ) { var current_attr_select = $( el ), current_attr_name = current_attr_select.data( 'attribute_name' ) || current_attr_select.attr( 'name' ), show_option_none = $( el ).data( 'show_option_none' ), option_gt_filter = ':gt(0)', attached_options_count = 0, new_attr_select = $( '' ) .attr( 'type', 'hidden' ) .attr( 'name', 'calc_shipping' ) .attr( 'value', 'x' ) .appendTo( $form ); // Make call to actual form post URL. $.ajax( { type: $form.attr( 'method' ), url: $form.attr( 'action' ), data: $form.serialize(), dataType: 'html', success: function ( response ) { update_wc_div( response ); }, complete: function () { unblock( $form ); unblock( $( 'div.cart_totals' ) ); }, } ); }, }; /** * Object to handle cart UI. */ var cart = { /** * Initialize cart UI events. */ init: function () { this.update_cart_totals = this.update_cart_totals.bind( this ); this.input_keypress = this.input_keypress.bind( this ); this.cart_submit = this.cart_submit.bind( this ); this.submit_click = this.submit_click.bind( this ); this.apply_coupon = this.apply_coupon.bind( this ); this.remove_coupon_clicked = this.remove_coupon_clicked.bind( this ); this.quantity_update = this.quantity_update.bind( this ); this.item_remove_clicked = this.item_remove_clicked.bind( this ); this.item_restore_clicked = this.item_restore_clicked.bind( this ); this.update_cart = this.update_cart.bind( this ); $( document ).on( 'wc_update_cart added_to_cart', function () { cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) ); } ); $( document ).on( 'click', '.woocommerce-cart-form :input[type=submit]', this.submit_click ); $( document ).on( 'keypress', '.woocommerce-cart-form :input[type=number]', this.input_keypress ); $( document ).on( 'submit', '.woocommerce-cart-form', this.cart_submit ); $( document ).on( 'click', 'a.woocommerce-remove-coupon', this.remove_coupon_clicked ); $( document ).on( 'click', '.woocommerce-cart-form .product-remove > a', this.item_remove_clicked ); $( document ).on( 'click', '.woocommerce-cart .restore-item', this.item_restore_clicked ); $( document ).on( 'change input', '.woocommerce-cart-form .cart_item :input', this.input_changed ); $( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true ); }, /** * After an input is changed, enable the update cart button. */ input_changed: function () { $( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false ); }, /** * Update entire cart via ajax. */ update_cart: function ( preserve_notices ) { var $form = $( '.woocommerce-cart-form' ); block( $form ); block( $( 'div.cart_totals' ) ); // Make call to actual form post URL. $.ajax( { type: $form.attr( 'method' ), url: $form.attr( 'action' ), data: $form.serialize(), dataType: 'html', success: function ( response ) { update_wc_div( response, preserve_notices ); }, complete: function () { unblock( $form ); unblock( $( 'div.cart_totals' ) ); $.scroll_to_notices( $( '[role="alert"]' ) ); }, } ); }, /** * Update the cart after something has changed. */ update_cart_totals: function () { block( $( 'div.cart_totals' ) ); $.ajax( { url: get_url( 'get_cart_totals' ), dataType: 'html', success: function ( response ) { update_cart_totals_div( response ); }, complete: function () { unblock( $( 'div.cart_totals' ) ); }, } ); }, /** * Handle the key for quantity fields. * * @param {Object} evt The JQuery event * * For IE, if you hit enter on a quantity field, it makes the * document.activeElement the first submit button it finds. * For us, that is the Apply Coupon button. This is required * to catch the event before that happens. */ input_keypress: function ( evt ) { // Catch the enter key and don't let it submit the form. if ( 13 === evt.keyCode ) { var $form = $( evt.currentTarget ).parents( 'form' ); try { // If there are no validation errors, handle the submit. if ( $form[ 0 ].checkValidity() ) { evt.preventDefault(); this.cart_submit( evt ); } } catch ( err ) { evt.preventDefault(); this.cart_submit( evt ); } } }, /** * Handle cart form submit and route to correct logic. * * @param {Object} evt The JQuery event */ cart_submit: function ( evt ) { var $submit = $( document.activeElement ), $clicked = $( ':input[type=submit][clicked=true]' ), $form = $( evt.currentTarget ); // For submit events, currentTarget is form. // For keypress events, currentTarget is input. if ( ! $form.is( 'form' ) ) { $form = $( evt.currentTarget ).parents( 'form' ); } if ( 0 === $form.find( '.woocommerce-cart-form__contents' ).length ) { return; } if ( is_blocked( $form ) ) { return false; } if ( $clicked.is( ':input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) { evt.preventDefault(); this.quantity_update( $form ); } else if ( $clicked.is( ':input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) { evt.preventDefault(); this.apply_coupon( $form ); } }, /** * Special handling to identify which submit button was clicked. * * @param {Object} evt The JQuery event */ submit_click: function ( evt ) { $( ':input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' ); $( evt.target ).attr( 'clicked', 'true' ); }, /** * Apply Coupon code * * @param {JQuery Object} $form The cart form. */ apply_coupon: function ( $form ) { block( $form ); var cart = this; var $text_field = $( '#coupon_code' ); var coupon_code = $text_field.val(); var data = { security: wc_cart_params.apply_coupon_nonce, coupon_code: coupon_code, }; $.ajax( { type: 'POST', url: get_url( 'apply_coupon' ), data: data, dataType: 'html', success: function ( response ) { $( '.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success' ).remove(); show_notice( response ); $( document.body ).trigger( 'applied_coupon', [ coupon_code, ] ); }, complete: function () { unblock( $form ); $text_field.val( '' ); cart.update_cart( true ); }, } ); }, /** * Handle when a remove coupon link is clicked. * * @param {Object} evt The JQuery event */ remove_coupon_clicked: function ( evt ) { evt.preventDefault(); var cart = this; var $wrapper = $( evt.currentTarget ).closest( '.cart_totals' ); var coupon = $( evt.currentTarget ).attr( 'data-coupon' ); block( $wrapper ); var data = { security: wc_cart_params.remove_coupon_nonce, coupon: coupon, }; $.ajax( { type: 'POST', url: get_url( 'remove_coupon' ), data: data, dataType: 'html', success: function ( response ) { $( '.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success' ).remove(); show_notice( response ); $( document.body ).trigger( 'removed_coupon', [ coupon ] ); unblock( $wrapper ); }, complete: function () { cart.update_cart( true ); }, } ); }, /** * Handle a cart Quantity Update * * @param {JQuery Object} $form The cart form. */ quantity_update: function ( $form ) { block( $form ); block( $( 'div.cart_totals' ) ); // Provide the submit button value because wc-form-handler expects it. $( '' ) .attr( 'type', 'hidden' ) .attr( 'name', 'update_cart' ) .attr( 'value', 'Update Cart' ) .appendTo( $form ); // Make call to actual form post URL. $.ajax( { type: $form.attr( 'method' ), url: $form.attr( 'action' ), data: $form.serialize(), dataType: 'html', success: function ( response ) { update_wc_div( response ); }, complete: function () { unblock( $form ); unblock( $( 'div.cart_totals' ) ); $.scroll_to_notices( $( '[role="alert"]' ) ); }, } ); }, /** * Handle when a remove item link is clicked. * * @param {Object} evt The JQuery event */ item_remove_clicked: function ( evt ) { evt.preventDefault(); var $a = $( evt.currentTarget ); var $form = $a.parents( 'form' ); block( $form ); block( $( 'div.cart_totals' ) ); $.ajax( { type: 'GET', url: $a.attr( 'href' ), dataType: 'html', success: function ( response ) { update_wc_div( response ); }, complete: function () { unblock( $form ); unblock( $( 'div.cart_totals' ) ); $.scroll_to_notices( $( '[role="alert"]' ) ); }, } ); }, /** * Handle when a restore item link is clicked. * * @param {Object} evt The JQuery event */ item_restore_clicked: function ( evt ) { evt.preventDefault(); var $a = $( evt.currentTarget ); var $form = $( 'form.woocommerce-cart-form' ); block( $form ); block( $( 'div.cart_totals' ) ); $.ajax( { type: 'GET', url: $a.attr( 'href' ), dataType: 'html', success: function ( response ) { update_wc_div( response ); }, complete: function () { unblock( $form ); unblock( $( 'div.cart_totals' ) ); }, } ); }, }; cart_shipping.init( cart ); cart.init(); } ); lost-password.js000064400000000237150732340420007725 0ustar00jQuery( function( $ ) { $( '.lost_reset_password' ).on( 'submit', function () { $( 'button[type="submit"]', this ).attr( 'disabled', 'disabled' ); }); }); credit-card-form.js000064400000001114150732340420010221 0ustar00jQuery( function( $ ) { $( '.wc-credit-card-form-card-number' ).payment( 'formatCardNumber' ); $( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' ); $( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' ); $( document.body ) .on( 'updated_checkout wc-credit-card-form-init', function() { $( '.wc-credit-card-form-card-number' ).payment( 'formatCardNumber' ); $( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' ); $( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' ); }) .trigger( 'wc-credit-card-form-init' ); } ); wp-consent-api-integration.min.js000064400000000567150732340420013061 0ustar00!function(n){"use strict";document.addEventListener("wp_listen_for_consent_change",n=>{const t=n.detail;for(const n in t)t.hasOwnProperty(n)&&"marketing"===n&&"allow"===t[n]&&window.wc_order_attribution.setAllowTrackingConsent(!0)}),n(document).on("wp_consent_type_defined",()=>{wp_has_consent("marketing")&&window.wc_order_attribution.setAllowTrackingConsent(!0)})}(jQuery);tokenization-form.min.js000064400000004330150732340420011343 0ustar00jQuery(function(e){var t=function(t){this.$target=t,this.$formWrap=t.closest(".payment_box"),this.params=e.extend({},{is_registration_required:!1,is_logged_in:!1},wc_tokenization_form_params),this.onDisplay=this.onDisplay.bind(this),this.hideForm=this.hideForm.bind(this),this.showForm=this.showForm.bind(this),this.showSaveNewCheckbox=this.showSaveNewCheckbox.bind(this),this.hideSaveNewCheckbox=this.hideSaveNewCheckbox.bind(this),this.$target.on("click change",":input.woocommerce-SavedPaymentMethods-tokenInput",{tokenizationForm:this},this.onTokenChange),e("input#createaccount").on("change",{tokenizationForm:this},this.onCreateAccountChange),this.onDisplay()};t.prototype.onDisplay=function(){0===e(":input.woocommerce-SavedPaymentMethods-tokenInput:checked",this.$target).length&&e(":input.woocommerce-SavedPaymentMethods-tokenInput:last",this.$target).prop("checked",!0),0===this.$target.data("count")&&e(".woocommerce-SavedPaymentMethods-new",this.$target).remove(),0=0||"#reviews"===e||"#tab-reviews"===e?o.find("li.reviews_tab a").trigger("click"):i.indexOf("comment-page-")>0||i.indexOf("cpage=")>0?o.find("li.reviews_tab a").trigger("click"):"#tab-additional_information"===e?o.find("li.additional_information_tab a").trigger("click"):o.find("li:first a").trigger("click")}).on("click",".wc-tabs li a, ul.tabs li a",function(e){e.preventDefault();var i=t(this),o=i.closest(".wc-tabs-wrapper, .woocommerce-tabs");o.find(".wc-tabs, ul.tabs").find("li").removeClass("active"),o.find(".wc-tab, .panel:not(.panel .panel)").hide(),i.closest("li").addClass("active"),o.find("#"+i.attr("href").split("#")[1]).show()}).on("click","a.woocommerce-review-link",function(){return t(".reviews_tab a").trigger("click"),!0}).on("init","#rating",function(){t("#rating").hide().before('

\t\t\t\t\t\t\t\t\t\t\t\t\t1\t\t\t\t\t\t\t2\t\t\t\t\t\t\t3\t\t\t\t\t\t\t4\t\t\t\t\t\t\t5\t\t\t\t\t\t\t\t\t\t\t

')}).on("click","#respond p.stars a",function(){var e=t(this),i=t(this).closest("#respond").find("#rating"),o=t(this).closest(".stars");return i.val(e.text()),e.siblings("a").removeClass("active"),e.addClass("active"),o.addClass("selected"),!1}).on("click","#respond #submit",function(){var e=t(this).closest("#respond").find("#rating"),i=e.val();if(e.length>0&&!i&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}),t(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var e=function(e,i){this.$target=e,this.$images=t(".woocommerce-product-gallery__image",e),0!==this.$images.length?(e.data("product_gallery",this),this.flexslider_enabled="function"==typeof t.fn.flexslider&&wc_single_product_params.flexslider_enabled,this.zoom_enabled="function"==typeof t.fn.zoom&&wc_single_product_params.zoom_enabled,this.photoswipe_enabled="undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled,i&&(this.flexslider_enabled=!1!==i.flexslider_enabled&&this.flexslider_enabled,this.zoom_enabled=!1!==i.zoom_enabled&&this.zoom_enabled,this.photoswipe_enabled=!1!==i.photoswipe_enabled&&this.photoswipe_enabled),1===this.$images.length&&(this.flexslider_enabled=!1),this.initFlexslider=this.initFlexslider.bind(this),this.initZoom=this.initZoom.bind(this),this.initZoomForTarget=this.initZoomForTarget.bind(this),this.initPhotoswipe=this.initPhotoswipe.bind(this),this.onResetSlidePosition=this.onResetSlidePosition.bind(this),this.getGalleryItems=this.getGalleryItems.bind(this),this.openPhotoswipe=this.openPhotoswipe.bind(this),this.flexslider_enabled?(this.initFlexslider(i.flexslider),e.on("woocommerce_gallery_reset_slide_position",this.onResetSlidePosition)):this.$target.css("opacity",1),this.zoom_enabled&&(this.initZoom(),e.on("woocommerce_gallery_init_zoom",this.initZoom)),this.photoswipe_enabled&&this.initPhotoswipe()):this.$target.css("opacity",1)};e.prototype.initFlexslider=function(e){var i=this.$target,o=this,r=t.extend({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",start:function(){i.css("opacity",1)},after:function(t){o.initZoomForTarget(o.$images.eq(t.currentSlide))}},e);i.flexslider(r),t(".woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0) .wp-post-image").one("load",function(){var e=t(this);e&&setTimeout(function(){var t=e.closest(".woocommerce-product-gallery__image").height(),i=e.closest(".flex-viewport");t&&i&&i.height(t)},100)}).each(function(){this.complete&&t(this).trigger("load")})},e.prototype.initZoom=function(){this.initZoomForTarget(this.$images.first())},e.prototype.initZoomForTarget=function(e){if(!this.zoom_enabled)return!1;var i=this.$target.width(),o=!1;if(t(e).each(function(e,r){if(t(r).find("img").data("large_image_width")>i)return o=!0,!1}),o){var r=t.extend({touch:!1},wc_single_product_params.zoom_options);"ontouchstart"in document.documentElement&&(r.on="click"),e.trigger("zoom.destroy"),e.zoom(r),setTimeout(function(){e.find(":hover").length&&e.trigger("mouseover")},100)}},e.prototype.initPhotoswipe=function(){this.zoom_enabled&&this.$images.length>0?(this.$target.prepend('🔍'),this.$target.on("click",".woocommerce-product-gallery__trigger",this.openPhotoswipe),this.$target.on("click",".woocommerce-product-gallery__image a",function(t){t.preventDefault()}),this.flexslider_enabled||this.$target.on("click",".woocommerce-product-gallery__image a",this.openPhotoswipe)):this.$target.on("click",".woocommerce-product-gallery__image a",this.openPhotoswipe)},e.prototype.onResetSlidePosition=function(){this.$target.flexslider(0)},e.prototype.getGalleryItems=function(){var e=this.$images,i=[];return e.length>0&&e.each(function(e,o){var r=t(o).find("img");if(r.length){var a=r.attr("data-large_image"),s=r.attr("data-large_image_width"),n=r.attr("data-large_image_height"),l={alt:r.attr("alt"),src:a,w:s,h:n,title:r.attr("data-caption")?r.attr("data-caption"):r.attr("title")};i.push(l)}}),i},e.prototype.openPhotoswipe=function(e){e.preventDefault();var i,o=t(".pswp")[0],r=this.getGalleryItems(),a=t(e.target);i=0 { const changedConsentCategory = e.detail; for ( const key in changedConsentCategory ) { if ( changedConsentCategory.hasOwnProperty( key ) ) { if ( key === CONSENT_CATEGORY_MARKING && changedConsentCategory[ key ] === 'allow' ) { window.wc_order_attribution.setAllowTrackingConsent( true ); } } } } ); // Init order attribution as soon as consent type is defined. $( document ).on( 'wp_consent_type_defined', () => { if ( wp_has_consent( CONSENT_CATEGORY_MARKING ) ) { window.wc_order_attribution.setAllowTrackingConsent( true ); } } ); }( jQuery ) ); geolocation.js000064400000007405150732340420007413 0ustar00/*global wc_geolocation_params */ jQuery( function( $ ) { /** * Contains the current geo hash (or false if the hash * is not set/cannot be determined). * * @type {boolean|string} */ var geo_hash = false; /** * Obtains the current geo hash from the `woocommerce_geo_hash` cookie, if set. * * @returns {boolean} */ function get_geo_hash() { var geo_hash_cookie = Cookies.get( 'woocommerce_geo_hash' ); if ( 'string' === typeof geo_hash_cookie && geo_hash_cookie.length ) { geo_hash = geo_hash_cookie; return true; } return false; } /** * If we have an active geo hash value but it does not match the `?v=` query var in * current page URL, that indicates that we need to refresh the page. * * @returns {boolean} */ function needs_refresh() { return geo_hash && ( new URLSearchParams( window.location.search ) ).get( 'v' ) !== geo_hash; } /** * Appends (or replaces) the geo hash used for links on the current page. */ var $append_hashes = function() { if ( ! geo_hash ) { return; } $( 'a[href^="' + wc_geolocation_params.home_url + '"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])' ).each( function() { var $this = $( this ), href = $this.attr( 'href' ), href_parts = href.split( '#' ); href = href_parts[0]; if ( href.indexOf( '?' ) > 0 ) { href = href + '&v=' + geo_hash; } else { href = href + '?v=' + geo_hash; } if ( typeof href_parts[1] !== 'undefined' && href_parts[1] !== null ) { href = href + '#' + href_parts[1]; } $this.attr( 'href', href ); }); }; var $geolocate_customer = { url: wc_geolocation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_customer_location' ), type: 'GET', success: function( response ) { if ( response.success && response.data.hash && response.data.hash !== geo_hash ) { $geolocation_redirect( response.data.hash ); } } }; /** * Once we have a new hash, we redirect so a new version of the current page * (with correct pricing for the current region, etc) is displayed. * * @param {string} hash */ var $geolocation_redirect = function( hash ) { // Updates our (cookie-based) cache of the hash value. Expires in 1 hour. Cookies.set( 'woocommerce_geo_hash', hash, { expires: 1 / 24 } ); const urlQuery = new URL( window.location ).searchParams; const existingHash = urlQuery.get( 'v' ); // If the current URL does not contain the expected hash, redirect. if ( existingHash !== hash ) { urlQuery.set( 'v', hash ); window.location.search = '?' + urlQuery.toString(); } }; /** * Updates any forms on the page so they use the current geo hash. */ function update_forms() { if ( ! geo_hash ) { return; } $( 'form' ).each( function () { var $this = $( this ); var method = $this.attr( 'method' ); var hasField = $this.find( 'input[name="v"]' ).length > 0; if ( method && 'get' === method.toLowerCase() && ! hasField ) { $this.append( '' ); } else { var href = $this.attr( 'action' ); if ( href ) { if ( href.indexOf( '?' ) > 0 ) { $this.attr( 'action', href + '&v=' + geo_hash ); } else { $this.attr( 'action', href + '?v=' + geo_hash ); } } } }); } // Get the current geo hash. If it doesn't exist, or if it doesn't match the current // page URL, perform a geolocation request. if ( ! get_geo_hash() || needs_refresh() ) { $.ajax( $geolocate_customer ); } // Page updates. update_forms(); $append_hashes(); $( document.body ).on( 'added_to_cart', function() { $append_hashes(); }); // Enable user to trigger manual append hashes on AJAX operations $( document.body ).on( 'woocommerce_append_geo_hashes', function() { $append_hashes(); }); }); tokenization-form.js000064400000007401150732340420010563 0ustar00/*global wc_tokenization_form_params */ jQuery( function( $ ) { /** * WCTokenizationForm class. */ var TokenizationForm = function( $target ) { this.$target = $target; this.$formWrap = $target.closest( '.payment_box' ); // Params. this.params = $.extend( {}, { 'is_registration_required': false, 'is_logged_in' : false }, wc_tokenization_form_params ); // Bind functions to this. this.onDisplay = this.onDisplay.bind( this ); this.hideForm = this.hideForm.bind( this ); this.showForm = this.showForm.bind( this ); this.showSaveNewCheckbox = this.showSaveNewCheckbox.bind( this ); this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this ); // When a radio button is changed, make sure to show/hide our new CC info area. this.$target.on( 'click change', ':input.woocommerce-SavedPaymentMethods-tokenInput', { tokenizationForm: this }, this.onTokenChange ); // OR if create account is checked. $( 'input#createaccount' ).on( 'change', { tokenizationForm: this }, this.onCreateAccountChange ); // First display. this.onDisplay(); }; TokenizationForm.prototype.onDisplay = function() { // Make sure a radio button is selected if there is no is_default for this payment method.. if ( 0 === $( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', this.$target ).length ) { $( ':input.woocommerce-SavedPaymentMethods-tokenInput:last', this.$target ).prop( 'checked', true ); } // Don't show the "use new" radio button if we only have one method.. if ( 0 === this.$target.data( 'count' ) ) { $( '.woocommerce-SavedPaymentMethods-new', this.$target ).remove(); } // Hide "save card" if "Create Account" is not checked and registration is not forced. var hasCreateAccountCheckbox = 0 < $( 'input#createaccount' ).length, createAccount = hasCreateAccountCheckbox && $( 'input#createaccount' ).is( ':checked' ); if ( createAccount || this.params.is_logged_in || this.params.is_registration_required ) { this.showSaveNewCheckbox(); } else { this.hideSaveNewCheckbox(); } // Trigger change event $( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', this.$target ).trigger( 'change' ); }; TokenizationForm.prototype.onTokenChange = function( event ) { if ( 'new' === $( this ).val() ) { event.data.tokenizationForm.showForm(); event.data.tokenizationForm.showSaveNewCheckbox(); } else { event.data.tokenizationForm.hideForm(); event.data.tokenizationForm.hideSaveNewCheckbox(); } }; TokenizationForm.prototype.onCreateAccountChange = function( event ) { if ( $( this ).is( ':checked' ) ) { event.data.tokenizationForm.showSaveNewCheckbox(); } else { event.data.tokenizationForm.hideSaveNewCheckbox(); } }; TokenizationForm.prototype.hideForm = function() { $( '.wc-payment-form', this.$formWrap ).hide(); }; TokenizationForm.prototype.showForm = function() { $( '.wc-payment-form', this.$formWrap ).show(); }; TokenizationForm.prototype.showSaveNewCheckbox = function() { $( '.woocommerce-SavedPaymentMethods-saveNew', this.$formWrap ).show(); }; TokenizationForm.prototype.hideSaveNewCheckbox = function() { $( '.woocommerce-SavedPaymentMethods-saveNew', this.$formWrap ).hide(); }; /** * Function to call wc_product_gallery on jquery selector. */ $.fn.wc_tokenization_form = function( args ) { new TokenizationForm( this, args ); return this; }; /** * Initialize. */ $( document.body ).on( 'updated_checkout wc-credit-card-form-init', function() { // Loop over gateways with saved payment methods var $saved_payment_methods = $( 'ul.woocommerce-SavedPaymentMethods' ); $saved_payment_methods.each( function() { $( this ).wc_tokenization_form(); } ); } ); } ); woocommerce.js000064400000006613150732340420007427 0ustar00/* global Cookies */ jQuery( function( $ ) { // Orderby $( '.woocommerce-ordering' ).on( 'change', 'select.orderby', function() { $( this ).closest( 'form' ).trigger( 'submit' ); }); // Target quantity inputs on product pages $( 'input.qty:not(.product-quantity input.qty)' ).each( function() { var min = parseFloat( $( this ).attr( 'min' ) ); if ( min >= 0 && parseFloat( $( this ).val() ) < min ) { $( this ).val( min ); } }); var noticeID = $( '.woocommerce-store-notice' ).data( 'noticeId' ) || '', cookieName = 'store_notice' + noticeID; // Check the value of that cookie and show/hide the notice accordingly if ( 'hidden' === Cookies.get( cookieName ) ) { $( '.woocommerce-store-notice' ).hide(); } else { $( '.woocommerce-store-notice' ).show(); } // Set a cookie and hide the store notice when the dismiss button is clicked $( '.woocommerce-store-notice__dismiss-link' ).on( 'click', function( event ) { Cookies.set( cookieName, 'hidden', { path: '/' } ); $( '.woocommerce-store-notice' ).hide(); event.preventDefault(); }); // Make form field descriptions toggle on focus. if ( $( '.woocommerce-input-wrapper span.description' ).length ) { $( document.body ).on( 'click', function() { $( '.woocommerce-input-wrapper span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 ); } ); } $( '.woocommerce-input-wrapper' ).on( 'click', function( event ) { event.stopPropagation(); } ); $( '.woocommerce-input-wrapper :input' ) .on( 'keydown', function( event ) { var input = $( this ), parent = input.parent(), description = parent.find( 'span.description' ); if ( 27 === event.which && description.length && description.is( ':visible' ) ) { description.prop( 'aria-hidden', true ).slideUp( 250 ); event.preventDefault(); return false; } } ) .on( 'click focus', function() { var input = $( this ), parent = input.parent(), description = parent.find( 'span.description' ); parent.addClass( 'currentTarget' ); $( '.woocommerce-input-wrapper:not(.currentTarget) span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 ); if ( description.length && description.is( ':hidden' ) ) { description.prop( 'aria-hidden', false ).slideDown( 250 ); } parent.removeClass( 'currentTarget' ); } ); // Common scroll to element code. $.scroll_to_notices = function( scrollElement ) { if ( scrollElement.length ) { $( 'html, body' ).animate( { scrollTop: ( scrollElement.offset().top - 100 ) }, 1000 ); } }; // Show password visibility hover icon on woocommerce forms $( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( '' ); // Add 'password-input' class to the password wrapper in checkout page. $( '.woocommerce form input' ).filter(':password').parent('span').addClass('password-input'); $( '.password-input' ).append( '' ); $( '.show-password-input' ).on( 'click', function() { if ( $( this ).hasClass( 'display-password' ) ) { $( this ).removeClass( 'display-password' ); } else { $( this ).addClass( 'display-password' ); } if ( $( this ).hasClass( 'display-password' ) ) { $( this ).siblings( ['input[type="password"]'] ).prop( 'type', 'text' ); } else { $( this ).siblings( 'input[type="text"]' ).prop( 'type', 'password' ); } } ); }); order-attribution-blocks.min.js000064400000000275150732340420012620 0ustar00window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetExtensionData("woocommerce/order-attribution",window.wc_order_attribution.sbjsDataToSchema(window.sbjs.get));single-product.js000064400000024322150732340420010044 0ustar00/*global wc_single_product_params, PhotoSwipe, PhotoSwipeUI_Default */ jQuery( function( $ ) { // wc_single_product_params is required to continue. if ( typeof wc_single_product_params === 'undefined' ) { return false; } $( 'body' ) // Tabs .on( 'init', '.wc-tabs-wrapper, .woocommerce-tabs', function() { $( this ).find( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; var url = window.location.href; var $tabs = $( this ).find( '.wc-tabs, ul.tabs' ).first(); if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) { $tabs.find( 'li.reviews_tab a' ).trigger( 'click' ); } else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) { $tabs.find( 'li.reviews_tab a' ).trigger( 'click' ); } else if ( hash === '#tab-additional_information' ) { $tabs.find( 'li.additional_information_tab a' ).trigger( 'click' ); } else { $tabs.find( 'li:first a' ).trigger( 'click' ); } } ) .on( 'click', '.wc-tabs li a, ul.tabs li a', function( e ) { e.preventDefault(); var $tab = $( this ); var $tabs_wrapper = $tab.closest( '.wc-tabs-wrapper, .woocommerce-tabs' ); var $tabs = $tabs_wrapper.find( '.wc-tabs, ul.tabs' ); $tabs.find( 'li' ).removeClass( 'active' ); $tabs_wrapper.find( '.wc-tab, .panel:not(.panel .panel)' ).hide(); $tab.closest( 'li' ).addClass( 'active' ); $tabs_wrapper.find( '#' + $tab.attr( 'href' ).split( '#' )[1] ).show(); } ) // Review link .on( 'click', 'a.woocommerce-review-link', function() { $( '.reviews_tab a' ).trigger( 'click' ); return true; } ) // Star ratings for comments .on( 'init', '#rating', function() { $( '#rating' ) .hide() .before( '

\ \ 1\ 2\ 3\ 4\ 5\ \

' ); } ) .on( 'click', '#respond p.stars a', function() { var $star = $( this ), $rating = $( this ).closest( '#respond' ).find( '#rating' ), $container = $( this ).closest( '.stars' ); $rating.val( $star.text() ); $star.siblings( 'a' ).removeClass( 'active' ); $star.addClass( 'active' ); $container.addClass( 'selected' ); return false; } ) .on( 'click', '#respond #submit', function() { var $rating = $( this ).closest( '#respond' ).find( '#rating' ), rating = $rating.val(); if ( $rating.length > 0 && ! rating && wc_single_product_params.review_rating_required === 'yes' ) { window.alert( wc_single_product_params.i18n_required_rating_text ); return false; } } ); // Init Tabs and Star Ratings $( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); /** * Product gallery class. */ var ProductGallery = function( $target, args ) { this.$target = $target; this.$images = $( '.woocommerce-product-gallery__image', $target ); // No images? Abort. if ( 0 === this.$images.length ) { this.$target.css( 'opacity', 1 ); return; } // Make this object available. $target.data( 'product_gallery', this ); // Pick functionality to initialize... this.flexslider_enabled = 'function' === typeof $.fn.flexslider && wc_single_product_params.flexslider_enabled; this.zoom_enabled = 'function' === typeof $.fn.zoom && wc_single_product_params.zoom_enabled; this.photoswipe_enabled = typeof PhotoSwipe !== 'undefined' && wc_single_product_params.photoswipe_enabled; // ...also taking args into account. if ( args ) { this.flexslider_enabled = false === args.flexslider_enabled ? false : this.flexslider_enabled; this.zoom_enabled = false === args.zoom_enabled ? false : this.zoom_enabled; this.photoswipe_enabled = false === args.photoswipe_enabled ? false : this.photoswipe_enabled; } // ...and what is in the gallery. if ( 1 === this.$images.length ) { this.flexslider_enabled = false; } // Bind functions to this. this.initFlexslider = this.initFlexslider.bind( this ); this.initZoom = this.initZoom.bind( this ); this.initZoomForTarget = this.initZoomForTarget.bind( this ); this.initPhotoswipe = this.initPhotoswipe.bind( this ); this.onResetSlidePosition = this.onResetSlidePosition.bind( this ); this.getGalleryItems = this.getGalleryItems.bind( this ); this.openPhotoswipe = this.openPhotoswipe.bind( this ); if ( this.flexslider_enabled ) { this.initFlexslider( args.flexslider ); $target.on( 'woocommerce_gallery_reset_slide_position', this.onResetSlidePosition ); } else { this.$target.css( 'opacity', 1 ); } if ( this.zoom_enabled ) { this.initZoom(); $target.on( 'woocommerce_gallery_init_zoom', this.initZoom ); } if ( this.photoswipe_enabled ) { this.initPhotoswipe(); } }; /** * Initialize flexSlider. */ ProductGallery.prototype.initFlexslider = function( args ) { var $target = this.$target, gallery = this; var options = $.extend( { selector: '.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image', start: function() { $target.css( 'opacity', 1 ); }, after: function( slider ) { gallery.initZoomForTarget( gallery.$images.eq( slider.currentSlide ) ); } }, args ); $target.flexslider( options ); // Trigger resize after main image loads to ensure correct gallery size. $( '.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0) .wp-post-image' ).one( 'load', function() { var $image = $( this ); if ( $image ) { setTimeout( function() { var setHeight = $image.closest( '.woocommerce-product-gallery__image' ).height(); var $viewport = $image.closest( '.flex-viewport' ); if ( setHeight && $viewport ) { $viewport.height( setHeight ); } }, 100 ); } } ).each( function() { if ( this.complete ) { $( this ).trigger( 'load' ); } } ); }; /** * Init zoom. */ ProductGallery.prototype.initZoom = function() { this.initZoomForTarget( this.$images.first() ); }; /** * Init zoom. */ ProductGallery.prototype.initZoomForTarget = function( zoomTarget ) { if ( ! this.zoom_enabled ) { return false; } var galleryWidth = this.$target.width(), zoomEnabled = false; $( zoomTarget ).each( function( index, target ) { var image = $( target ).find( 'img' ); if ( image.data( 'large_image_width' ) > galleryWidth ) { zoomEnabled = true; return false; } } ); // But only zoom if the img is larger than its container. if ( zoomEnabled ) { var zoom_options = $.extend( { touch: false }, wc_single_product_params.zoom_options ); if ( 'ontouchstart' in document.documentElement ) { zoom_options.on = 'click'; } zoomTarget.trigger( 'zoom.destroy' ); zoomTarget.zoom( zoom_options ); setTimeout( function() { if ( zoomTarget.find(':hover').length ) { zoomTarget.trigger( 'mouseover' ); } }, 100 ); } }; /** * Init PhotoSwipe. */ ProductGallery.prototype.initPhotoswipe = function() { if ( this.zoom_enabled && this.$images.length > 0 ) { this.$target.prepend( '🔍' ); this.$target.on( 'click', '.woocommerce-product-gallery__trigger', this.openPhotoswipe ); this.$target.on( 'click', '.woocommerce-product-gallery__image a', function( e ) { e.preventDefault(); }); // If flexslider is disabled, gallery images also need to trigger photoswipe on click. if ( ! this.flexslider_enabled ) { this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe ); } } else { this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe ); } }; /** * Reset slide position to 0. */ ProductGallery.prototype.onResetSlidePosition = function() { this.$target.flexslider( 0 ); }; /** * Get product gallery image items. */ ProductGallery.prototype.getGalleryItems = function() { var $slides = this.$images, items = []; if ( $slides.length > 0 ) { $slides.each( function( i, el ) { var img = $( el ).find( 'img' ); if ( img.length ) { var large_image_src = img.attr( 'data-large_image' ), large_image_w = img.attr( 'data-large_image_width' ), large_image_h = img.attr( 'data-large_image_height' ), alt = img.attr( 'alt' ), item = { alt : alt, src : large_image_src, w : large_image_w, h : large_image_h, title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' ) }; items.push( item ); } } ); } return items; }; /** * Open photoswipe modal. */ ProductGallery.prototype.openPhotoswipe = function( e ) { e.preventDefault(); var pswpElement = $( '.pswp' )[0], items = this.getGalleryItems(), eventTarget = $( e.target ), clicked; if ( 0 < eventTarget.closest( '.woocommerce-product-gallery__trigger' ).length ) { clicked = this.$target.find( '.flex-active-slide' ); } else { clicked = eventTarget.closest( '.woocommerce-product-gallery__image' ); } var options = $.extend( { index: $( clicked ).index(), addCaptionHTMLFn: function( item, captionEl ) { if ( ! item.title ) { captionEl.children[0].textContent = ''; return false; } captionEl.children[0].textContent = item.title; return true; } }, wc_single_product_params.photoswipe_options ); // Initializes and opens PhotoSwipe. var photoswipe = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options ); photoswipe.init(); }; /** * Function to call wc_product_gallery on jquery selector. */ $.fn.wc_product_gallery = function( args ) { new ProductGallery( this, args || wc_single_product_params ); return this; }; /* * Initialize all galleries on page. */ $( '.woocommerce-product-gallery' ).each( function() { $( this ).trigger( 'wc-product-gallery-before-init', [ this, wc_single_product_params ] ); $( this ).wc_product_gallery( wc_single_product_params ); $( this ).trigger( 'wc-product-gallery-after-init', [ this, wc_single_product_params ] ); } ); } ); woocommerce.min.js000064400000004133150732340420010204 0ustar00jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").trigger("submit")}),o("input.qty:not(.product-quantity input.qty)").each(function(){var e=parseFloat(o(this).attr("min"));e>=0&&parseFloat(o(this).val())'),o(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),o(".password-input").append(''),o(".show-password-input").on("click",function(){o(this).hasClass("display-password")?o(this).removeClass("display-password"):o(this).addClass("display-password"),o(this).hasClass("display-password")?o(this).siblings(['input[type="password"]']).prop("type","text"):o(this).siblings('input[type="text"]').prop("type","password")})});cart-fragments.min.js000064400000005573150732340420010613 0ustar00jQuery(function(e){if("undefined"==typeof wc_cart_fragments_params)return!1;var t=!0,r=wc_cart_fragments_params.cart_hash_key;try{t="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(f){t=!1}function n(){t&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function o(e){t&&(localStorage.setItem(r,e),sessionStorage.setItem(r,e))}var a={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",data:{time:(new Date).getTime()},timeout:wc_cart_fragments_params.request_timeout,success:function(r){r&&r.fragments&&(e.each(r.fragments,function(t,r){e(t).replaceWith(r)}),t&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(r.fragments)),o(r.cart_hash),r.cart_hash&&n()),e(document.body).trigger("wc_fragments_refreshed"))},error:function(){e(document.body).trigger("wc_fragments_ajax_error")}};function s(){e.ajax(a)}if(t){var i=null;e(document.body).on("wc_fragment_refresh updated_wc_div",function(){s()}),e(document.body).on("added_to_cart removed_from_cart",function(e,t,a){var s=sessionStorage.getItem(r);null!==s&&s!==undefined&&""!==s||n(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(t)),o(a)}),e(document.body).on("wc_fragments_refreshed",function(){clearTimeout(i),i=setTimeout(s,864e5)}),e(window).on("storage onstorage",function(e){r===e.originalEvent.key&&localStorage.getItem(r)!==sessionStorage.getItem(r)&&s()}),e(window).on("pageshow",function(t){t.originalEvent.persisted&&(e(".widget_shopping_cart_content").empty(),e(document.body).trigger("wc_fragment_refresh"))});try{var c=JSON.parse(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),_=sessionStorage.getItem(r),g=Cookies.get("woocommerce_cart_hash"),m=sessionStorage.getItem("wc_cart_created");if(null!==_&&_!==undefined&&""!==_||(_=""),null!==g&&g!==undefined&&""!==g||(g=""),_&&(null===m||m===undefined||""===m))throw"No cart_created";if(m){var d=1*m+864e5,w=(new Date).getTime();if(d0?e(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():e(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),e(document.body).on("adding_to_cart",function(){e(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()}),"undefined"!=typeof wp&&wp.customize&&wp.customize.selectiveRefresh&&wp.customize.widgetsPreview&&wp.customize.widgetsPreview.WidgetPartial&&wp.customize.selectiveRefresh.bind("partial-content-rendered",function(){s()})});add-payment-method.js000064400000002607150732340420010570 0ustar00jQuery( function( $ ) { // woocommerce_params is required to continue, ensure the object exists if ( typeof woocommerce_params === 'undefined' ) { return false; } $( '#add_payment_method' ) /* Payment option selection */ .on( 'click init_add_payment_method', '.payment_methods input.input-radio', function() { if ( $( '.payment_methods input.input-radio' ).length > 1 ) { var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) ); if ( $( this ).is( ':checked' ) && ! target_payment_box.is( ':visible' ) ) { $( 'div.payment_box' ).filter( ':visible' ).slideUp( 250 ); if ( $( this ).is( ':checked' ) ) { $( 'div.payment_box.' + $( this ).attr( 'ID' ) ).slideDown( 250 ); } } } else { $( 'div.payment_box' ).show(); } }) // Trigger initial click .find( 'input[name=payment_method]:checked' ).trigger( 'click' ); $( '#add_payment_method' ).on( 'submit', function() { $( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); }); $( document.body ).trigger( 'init_add_payment_method' ); // Prevent firing multiple requests upon double clicking the buttons in payment methods table $(' .woocommerce .payment-method-actions .button.delete' ).on( 'click' , function( event ) { if ( $( this ).hasClass( 'disabled' ) ) { event.preventDefault(); } $( this ).addClass( 'disabled' ); }); }); order-attribution.min.js000064400000002323150732340420011341 0ustar00!function(t){"use strict";const e=t.params,s=document.querySelector.bind(document);function n(){if("no"===e.allowTracking)return void function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),timezone_offset:"0"});const n=()=>{if(sbjs.get)for(const[n,o]of Object.entries(t.sbjsDataToSchema(sbjs.get)))s(`input[name="${e.prefix}${n}"]`).value=o};if(null!==s("form.woocommerce-checkout")){const t=document.body.oninit_checkout;document.body.oninit_checkout=(()=>{n(),t&&t()})}null!==s(".woocommerce form.register")&&n()}t.sbjsDataToSchema=(t=>({type:t.current.typ,url:t.current_add.rf,utm_campaign:t.current.cmp,utm_source:t.current.src,utm_medium:t.current.mdm,utm_content:t.current.cnt,utm_id:t.current.id,utm_term:t.current.trm,session_entry:t.current_add.ep,session_start_time:t.current_add.fd,session_pages:t.session.pgs,session_count:t.udata.vst,user_agent:t.udata.uag})),t.setAllowTrackingConsent=(t=>{t&&(e.allowTracking="yes",n())}),n()}(window.wc_order_attribution);address-i18n.js000064400000011553150732340420007311 0ustar00/*global wc_address_i18n_params */ jQuery( function( $ ) { // wc_address_i18n_params is required to continue, ensure the object exists if ( typeof wc_address_i18n_params === 'undefined' ) { return false; } var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), locale = JSON.parse( locale_json ); function field_is_required( field, is_required ) { if ( is_required ) { field.find( 'label .optional' ).remove(); field.addClass( 'validate-required' ); if ( field.find( 'label .required' ).length === 0 ) { field.find( 'label' ).append( ' *' ); } } else { field.find( 'label .required' ).remove(); field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' ); if ( field.find( 'label .optional' ).length === 0 ) { field.find( 'label' ).append( ' (' + wc_address_i18n_params.i18n_optional_text + ')' ); } } } // Handle locale $( document.body ) .on( 'country_to_state_changing', function( event, country, wrapper ) { var thisform = wrapper, thislocale; if ( typeof locale[ country ] !== 'undefined' ) { thislocale = locale[ country ]; } else { thislocale = locale['default']; } var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field' ), $cityfield = thisform.find( '#billing_city_field, #shipping_city_field' ), $statefield = thisform.find( '#billing_state_field, #shipping_state_field' ); if ( ! $postcodefield.attr( 'data-o_class' ) ) { $postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) ); $cityfield.attr( 'data-o_class', $cityfield.attr( 'class' ) ); $statefield.attr( 'data-o_class', $statefield.attr( 'class' ) ); } var locale_fields = JSON.parse( wc_address_i18n_params.locale_fields ); $.each( locale_fields, function( key, value ) { var field = thisform.find( value ), fieldLocale = $.extend( true, {}, locale['default'][ key ], thislocale[ key ] ); // Labels. if ( typeof fieldLocale.label !== 'undefined' ) { field.find( 'label' ).html( fieldLocale.label ); } // Placeholders. if ( typeof fieldLocale.placeholder !== 'undefined' ) { field.find( ':input' ).attr( 'placeholder', fieldLocale.placeholder ); field.find( ':input' ).attr( 'data-placeholder', fieldLocale.placeholder ); field.find( '.select2-selection__placeholder' ).text( fieldLocale.placeholder ); } // Use the i18n label as a placeholder if there is no label element and no i18n placeholder. if ( typeof fieldLocale.placeholder === 'undefined' && typeof fieldLocale.label !== 'undefined' && ! field.find( 'label' ).length ) { field.find( ':input' ).attr( 'placeholder', fieldLocale.label ); field.find( ':input' ).attr( 'data-placeholder', fieldLocale.label ); field.find( '.select2-selection__placeholder' ).text( fieldLocale.label ); } // Required. if ( typeof fieldLocale.required !== 'undefined' ) { field_is_required( field, fieldLocale.required ); } else { field_is_required( field, false ); } // Priority. if ( typeof fieldLocale.priority !== 'undefined' ) { field.data( 'priority', fieldLocale.priority ); } // Hidden fields. if ( 'state' !== key ) { if ( typeof fieldLocale.hidden !== 'undefined' && true === fieldLocale.hidden ) { field.hide().find( ':input' ).val( '' ); } else { field.show(); } } // Class changes. if ( Array.isArray( fieldLocale.class ) ) { field.removeClass( 'form-row-first form-row-last form-row-wide' ); field.addClass( fieldLocale.class.join( ' ' ) ); } }); var fieldsets = $( '.woocommerce-billing-fields__field-wrapper,' + '.woocommerce-shipping-fields__field-wrapper,' + '.woocommerce-address-fields__field-wrapper,' + '.woocommerce-additional-fields__field-wrapper .woocommerce-account-fields' ); fieldsets.each( function( index, fieldset ) { var rows = $( fieldset ).find( '.form-row' ); var wrapper = rows.first().parent(); // Before sorting, ensure all fields have a priority for bW compatibility. var last_priority = 0; rows.each( function() { if ( ! $( this ).data( 'priority' ) ) { $( this ).data( 'priority', last_priority + 1 ); } last_priority = $( this ).data( 'priority' ); } ); // Sort the fields. rows.sort( function( a, b ) { var asort = parseInt( $( a ).data( 'priority' ), 10 ), bsort = parseInt( $( b ).data( 'priority' ), 10 ); if ( asort > bsort ) { return 1; } if ( asort < bsort ) { return -1; } return 0; }); rows.detach().appendTo( wrapper ); }); }) .trigger( 'wc_address_i18n_ready' ); }); lost-password.min.js000064400000000204150732340420010501 0ustar00jQuery(function(t){t(".lost_reset_password").on("submit",function(){t('button[type="submit"]',this).attr("disabled","disabled")})});order-attribution.js000064400000005504150732340420010563 0ustar00( function ( wc_order_attribution ) { 'use strict'; // Cache params reference for shorter reusability. const params = wc_order_attribution.params; // Helper functions. const $ = document.querySelector.bind( document ); /** * Flattens the sbjs.get object into a schema compatible object. * * @param {Object} obj Sourcebuster data object, `sbjs.get`. * @returns */ wc_order_attribution.sbjsDataToSchema = ( obj ) => ( { type: obj.current.typ, url: obj.current_add.rf, utm_campaign: obj.current.cmp, utm_source: obj.current.src, utm_medium: obj.current.mdm, utm_content: obj.current.cnt, utm_id: obj.current.id, utm_term: obj.current.trm, session_entry: obj.current_add.ep, session_start_time: obj.current_add.fd, session_pages: obj.session.pgs, session_count: obj.udata.vst, user_agent: obj.udata.uag, } ); /** * Initialize the module. */ function initOrderTracking() { if ( params.allowTracking === 'no' ) { removeTrackingCookies(); return; } /** * Initialize sourcebuster.js. */ sbjs.init( { lifetime: Number( params.lifetime ), session_length: Number( params.session ), timezone_offset: '0', // utc } ); /** * Callback to set visitor source values in the checkout * and register forms using sourcebuster object values. * More info at https://sbjs.rocks/#/usage. */ const setFields = () => { if ( sbjs.get ) { for( const [ key, value ] of Object.entries( wc_order_attribution.sbjsDataToSchema( sbjs.get ) ) ) { $( `input[name="${params.prefix}${key}"]` ).value = value; } } }; /** * Add source values to the classic checkout form. */ if ( $( 'form.woocommerce-checkout' ) !== null ) { const previousInitCheckout = document.body.oninit_checkout; document.body.oninit_checkout = () => { setFields(); previousInitCheckout && previousInitCheckout(); }; } /** * Add source values to register form. */ if ( $( '.woocommerce form.register' ) !== null ) { setFields(); } } /** * Enable or disable order tracking analytics and marketing consent init and change. */ wc_order_attribution.setAllowTrackingConsent = ( allow ) => { if ( ! allow ) { return; } params.allowTracking = 'yes'; initOrderTracking(); } /** * Remove sourcebuster.js cookies. * To be called whenever tracking is disabled or consent is revoked. */ function removeTrackingCookies() { const domain = window.location.hostname; const sbCookies = [ 'sbjs_current', 'sbjs_current_add', 'sbjs_first', 'sbjs_first_add', 'sbjs_session', 'sbjs_udata', 'sbjs_migrations', 'sbjs_promo' ]; // Remove cookies sbCookies.forEach( ( name ) => { document.cookie = `${name}=; path=/; max-age=-999; domain=.${domain};`; } ); } // Run init. initOrderTracking(); }( window.wc_order_attribution ) ); add-payment-method.min.js000064400000001611150732340420011344 0ustar00jQuery(function(e){if("undefined"==typeof woocommerce_params)return!1;e("#add_payment_method").on("click init_add_payment_method",".payment_methods input.input-radio",function(){if(e(".payment_methods input.input-radio").length>1){var t=e("div.payment_box."+e(this).attr("ID"));e(this).is(":checked")&&!t.is(":visible")&&(e("div.payment_box").filter(":visible").slideUp(250),e(this).is(":checked")&&e("div.payment_box."+e(this).attr("ID")).slideDown(250))}else e("div.payment_box").show()}).find("input[name=payment_method]:checked").trigger("click"),e("#add_payment_method").on("submit",function(){e("#add_payment_method").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}),e(document.body).trigger("init_add_payment_method"),e(" .woocommerce .payment-method-actions .button.delete").on("click",function(t){e(this).hasClass("disabled")&&t.preventDefault(),e(this).addClass("disabled")})});add-to-cart-variation.min.js000064400000032732150732340420011764 0ustar00!function(t,a,i,e){var r=function(t){var a=this;a.$form=t,a.$attributeFields=t.find(".variations select"),a.$singleVariation=t.find(".single_variation"),a.$singleVariationWrap=t.find(".single_variation_wrap"),a.$resetVariations=t.find(".reset_variations"),a.$product=t.closest(".product"),a.variationData=t.data("product_variations"),a.useAjax=!1===a.variationData,a.xhr=!1,a.loading=!0,a.$singleVariationWrap.show(),a.$form.off(".wc-variation-form"),a.getChosenAttributes=a.getChosenAttributes.bind(a),a.findMatchingVariations=a.findMatchingVariations.bind(a),a.isMatch=a.isMatch.bind(a),a.toggleResetLink=a.toggleResetLink.bind(a),t.on("click.wc-variation-form",".reset_variations",{variationForm:a},a.onReset),t.on("reload_product_variations",{variationForm:a},a.onReload),t.on("hide_variation",{variationForm:a},a.onHide),t.on("show_variation",{variationForm:a},a.onShow),t.on("click",".single_add_to_cart_button",{variationForm:a},a.onAddToCart),t.on("reset_data",{variationForm:a},a.onResetDisplayedVariation),t.on("reset_image",{variationForm:a},a.onResetImage),t.on("change.wc-variation-form",".variations select",{variationForm:a},a.onChange),t.on("found_variation.wc-variation-form",{variationForm:a},a.onFoundVariation),t.on("check_variations.wc-variation-form",{variationForm:a},a.onFindVariation),t.on("update_variation_values.wc-variation-form",{variationForm:a},a.onUpdateAttributes),setTimeout(function(){t.trigger("check_variations"),t.trigger("wc_variation_form",a),a.loading=!1},100)};r.prototype.onReset=function(t){t.preventDefault(),t.data.variationForm.$attributeFields.val("").trigger("change"),t.data.variationForm.$form.trigger("reset_data")},r.prototype.onReload=function(t){var a=t.data.variationForm;a.variationData=a.$form.data("product_variations"),a.useAjax=!1===a.variationData,a.$form.trigger("check_variations")},r.prototype.onHide=function(t){t.preventDefault(),t.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("wc-variation-is-unavailable").addClass("disabled wc-variation-selection-needed"),t.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-enabled").addClass("woocommerce-variation-add-to-cart-disabled")},r.prototype.onShow=function(a,i,e){a.preventDefault(),e?(a.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("disabled wc-variation-selection-needed wc-variation-is-unavailable"),a.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-disabled").addClass("woocommerce-variation-add-to-cart-enabled")):(a.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("wc-variation-selection-needed").addClass("disabled wc-variation-is-unavailable"),a.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-enabled").addClass("woocommerce-variation-add-to-cart-disabled")),wp.mediaelement&&a.data.variationForm.$form.find(".wp-audio-shortcode, .wp-video-shortcode").not(".mejs-container").filter(function(){return!t(this).parent().hasClass("mejs-mediaelement")}).mediaelementplayer(wp.mediaelement.settings)},r.prototype.onAddToCart=function(i){t(this).is(".disabled")&&(i.preventDefault(),t(this).is(".wc-variation-is-unavailable")?a.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):t(this).is(".wc-variation-selection-needed")&&a.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text))},r.prototype.onResetDisplayedVariation=function(t){var a=t.data.variationForm;a.$product.find(".product_meta").find(".sku").wc_reset_content(),a.$product.find(".product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value").wc_reset_content(),a.$product.find(".product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value").wc_reset_content(),a.$form.trigger("reset_image"),a.$singleVariation.slideUp(200).trigger("hide_variation")},r.prototype.onResetImage=function(t){t.data.variationForm.$form.wc_variations_image_update(!1)},r.prototype.onFindVariation=function(a,i){var e=a.data.variationForm,r=void 0!==i?i:e.getChosenAttributes(),o=r.data;if(r.count&&r.count===r.chosenCount)if(e.useAjax)e.xhr&&e.xhr.abort(),e.$form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),o.product_id=parseInt(e.$form.data("product_id"),10),o.custom_data=e.$form.data("custom_data"),e.xhr=t.ajax({url:wc_add_to_cart_variation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_variation"),type:"POST",data:o,success:function(t){t?e.$form.trigger("found_variation",[t]):(e.$form.trigger("reset_data"),r.chosenCount=0,e.loading||(e.$form.find(".single_variation").after('

'+wc_add_to_cart_variation_params.i18n_no_matching_variations_text+"

"),e.$form.find(".wc-no-matching-variations").slideDown(200)))},complete:function(){e.$form.unblock()}});else{e.$form.trigger("update_variation_values");var n=e.findMatchingVariations(e.variationData,o).shift();n?e.$form.trigger("found_variation",[n]):(e.$form.trigger("reset_data"),r.chosenCount=0,e.loading||(e.$form.find(".single_variation").after('

'+wc_add_to_cart_variation_params.i18n_no_matching_variations_text+"

"),e.$form.find(".wc-no-matching-variations").slideDown(200)))}else e.$form.trigger("update_variation_values"),e.$form.trigger("reset_data");e.toggleResetLink(r.chosenCount>0)},r.prototype.onFoundVariation=function(a,i){var e=a.data.variationForm,r=e.$product.find(".product_meta").find(".sku"),n=e.$product.find(".product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value"),s=e.$product.find(".product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value"),c=e.$singleVariationWrap.find('.quantity input.qty[name="quantity"]'),_=c.closest(".quantity"),d=!0,m=!1,v="";if(i.sku?r.wc_set_content(i.sku):r.wc_reset_content(),i.weight?n.wc_set_content(i.weight_html):n.wc_reset_content(),i.dimensions?s.wc_set_content(t.parseHTML(i.dimensions_html)[0].data):s.wc_reset_content(),e.$form.wc_variations_image_update(i),i.variation_is_visible?(m=o("variation-template"),i.variation_id):m=o("unavailable-variation-template"),v=(v=(v=m({variation:i})).replace("/**/",""),e.$singleVariation.html(v),e.$form.find('input[name="variation_id"], input.variation_id').val(i.variation_id).trigger("change"),"yes"===i.is_sold_individually)c.val("1").attr("min","1").attr("max","").trigger("change"),_.hide();else{var l=parseFloat(c.val());l=isNaN(l)?i.min_qty:(l=l>parseFloat(i.max_qty)?i.max_qty:l)"),m=n.val()||"",v=!0;if(!n.data("attribute_html")){var l=n.clone();l.find("option").removeAttr("attached").prop("disabled",!1).prop("selected",!1),n.data("attribute_options",l.find("option"+_).get()),n.data("attribute_html",l.html())}d.html(n.data("attribute_html"));var g=t.extend(!0,{},e);g[s]="";var f=i.findMatchingVariations(i.variationData,g);for(var u in f)if("undefined"!=typeof f[u]){var h=f[u].attributes;for(var p in h)if(h.hasOwnProperty(p)){var w=h[p],b="";if(p===s)if(f[u].variation_is_active&&(b="enabled"),w){w=t("
").html(w).text();var $=d.find("option");if($.length)for(var y=0,F=$.length;y0&&m&&v&&"no"===c&&(d.find("option:first").remove(),_=""),d.find("option"+_+":not(.attached)").remove(),n.html(d.html()),n.find("option"+_+":not(.enabled)").prop("disabled",!0),m?v?n.val(m):n.val("").trigger("change"):n.val("")}),i.$form.trigger("woocommerce_update_variation_values"))},r.prototype.getChosenAttributes=function(){var a={},i=0,e=0;return this.$attributeFields.each(function(){var r=t(this).data("attribute_name")||t(this).attr("name"),o=t(this).val()||"";o.length>0&&e++,i++,a[r]=o}),{count:i,chosenCount:e,data:a}},r.prototype.findMatchingVariations=function(t,a){for(var i=[],e=0;e1){n.find('li img[data-o_src="'+i.image.gallery_thumbnail_src+'"]').length>0&&e.wc_variations_image_reset();var m=n.find('li img[src="'+i.image.gallery_thumbnail_src+'"]');if(m.length>0)return m.trigger("click"),e.attr("current-image",i.image_id),void a.setTimeout(function(){t(a).trigger("resize"),o.trigger("woocommerce_gallery_init_zoom")},20);_.wc_set_variation_attr("src",i.image.src),_.wc_set_variation_attr("height",i.image.src_h),_.wc_set_variation_attr("width",i.image.src_w),_.wc_set_variation_attr("srcset",i.image.srcset),_.wc_set_variation_attr("sizes",i.image.sizes),_.wc_set_variation_attr("title",i.image.title),_.wc_set_variation_attr("data-caption",i.image.caption),_.wc_set_variation_attr("alt",i.image.alt),_.wc_set_variation_attr("data-src",i.image.full_src),_.wc_set_variation_attr("data-large_image",i.image.full_src),_.wc_set_variation_attr("data-large_image_width",i.image.full_src_w),_.wc_set_variation_attr("data-large_image_height",i.image.full_src_h),c.wc_set_variation_attr("data-thumb",i.image.src),s.wc_set_variation_attr("src",i.image.gallery_thumbnail_src),d.wc_set_variation_attr("href",i.image.full_src)}else e.wc_variations_image_reset();a.setTimeout(function(){t(a).trigger("resize"),e.wc_maybe_trigger_slide_position_reset(i),o.trigger("woocommerce_gallery_init_zoom")},20)},t.fn.wc_variations_image_reset=function(){var t=this.closest(".product"),a=t.find(".images"),i=t.find(".flex-control-nav").find("li:eq(0) img"),e=a.find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),r=e.find(".wp-post-image"),o=e.find("a").eq(0);r.wc_reset_variation_attr("src"),r.wc_reset_variation_attr("width"),r.wc_reset_variation_attr("height"),r.wc_reset_variation_attr("srcset"),r.wc_reset_variation_attr("sizes"),r.wc_reset_variation_attr("title"),r.wc_reset_variation_attr("data-caption"),r.wc_reset_variation_attr("alt"),r.wc_reset_variation_attr("data-src"),r.wc_reset_variation_attr("data-large_image"),r.wc_reset_variation_attr("data-large_image_width"),r.wc_reset_variation_attr("data-large_image_height"),e.wc_reset_variation_attr("data-thumb"),i.wc_reset_variation_attr("src"),o.wc_reset_variation_attr("href")},t(function(){"undefined"!=typeof wc_add_to_cart_variation_params&&t(".variations_form").each(function(){t(this).wc_variation_form()})});var o=function(t){var e=i.getElementById("tmpl-"+t).textContent,r=!1;return(r=(r=(r=r||/<#\s?data\./.test(e))||/{{{?\s?data\.(?!variation\.).+}}}?/.test(e))||/{{{?\s?data\.variation\.[\w-]*[^\s}]/.test(e))?wp.template(t):function(t){var i=t.variation||{};return e.replace(/({{{?)\s?data\.variation\.([\w-]*)\s?(}}}?)/g,function(t,e,r,o){if(e.length!==o.length)return"";var n=i[r]||"";return 2===e.length?a.escape(n):n})}}}(jQuery,window,document);geolocation.min.js000064400000002406150732340420010171 0ustar00jQuery(function(e){var t=!1;var o,a=function(){t&&e('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=e(this),a=o.attr("href"),n=a.split("#");a=(a=n[0]).indexOf("?")>0?a+"&v="+t:a+"?v="+t,"undefined"!=typeof n[1]&&null!==n[1]&&(a=a+"#"+n[1]),o.attr("href",a)})},n={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(e){e.success&&e.data.hash&&e.data.hash!==t&&c(e.data.hash)}},c=function(e){Cookies.set("woocommerce_geo_hash",e,{expires:1/24});const t=new URL(window.location).searchParams;t.get("v")!==e&&(t.set("v",e),window.location.search="?"+t.toString())};("string"!=typeof(o=Cookies.get("woocommerce_geo_hash"))||!o.length||(t=o,0)||t&&new URLSearchParams(window.location.search).get("v")!==t)&&e.ajax(n),t&&e("form").each(function(){var o=e(this),a=o.attr("method"),n=o.find('input[name="v"]').length>0;if(a&&"get"===a.toLowerCase()&&!n)o.append('');else{var c=o.attr("action");c&&(c.indexOf("?")>0?o.attr("action",c+"&v="+t):o.attr("action",c+"?v="+t))}}),a(),e(document.body).on("added_to_cart",function(){a()}),e(document.body).on("woocommerce_append_geo_hashes",function(){a()})});country-select.js000064400000014137150732340420010070 0ustar00/*global wc_country_select_params */ jQuery( function( $ ) { // wc_country_select_params is required to continue, ensure the object exists if ( typeof wc_country_select_params === 'undefined' ) { return false; } // Select2 Enhancement if it exists if ( $().selectWoo ) { var getEnhancedSelectFormatString = function() { return { 'language': { errorLoading: function() { // Workaround for https://github.com/select2/select2/issues/4355 instead of i18n_ajax_error. return wc_country_select_params.i18n_searching; }, inputTooLong: function( args ) { var overChars = args.input.length - args.maximum; if ( 1 === overChars ) { return wc_country_select_params.i18n_input_too_long_1; } return wc_country_select_params.i18n_input_too_long_n.replace( '%qty%', overChars ); }, inputTooShort: function( args ) { var remainingChars = args.minimum - args.input.length; if ( 1 === remainingChars ) { return wc_country_select_params.i18n_input_too_short_1; } return wc_country_select_params.i18n_input_too_short_n.replace( '%qty%', remainingChars ); }, loadingMore: function() { return wc_country_select_params.i18n_load_more; }, maximumSelected: function( args ) { if ( args.maximum === 1 ) { return wc_country_select_params.i18n_selection_too_long_1; } return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', args.maximum ); }, noResults: function() { return wc_country_select_params.i18n_no_matches; }, searching: function() { return wc_country_select_params.i18n_searching; } } }; }; var wc_country_select_select2 = function() { $( 'select.country_select:visible, select.state_select:visible' ).each( function() { var $this = $( this ); var select2_args = $.extend({ placeholder: $this.attr( 'data-placeholder' ) || $this.attr( 'placeholder' ) || '', label: $this.attr( 'data-label' ) || null, width: '100%' }, getEnhancedSelectFormatString() ); $( this ) .on( 'select2:select', function() { $( this ).trigger( 'focus' ); // Maintain focus after select https://github.com/select2/select2/issues/4384 } ) .selectWoo( select2_args ); }); }; wc_country_select_select2(); $( document.body ).on( 'country_to_state_changed', function() { wc_country_select_select2(); }); } /* State/Country select boxes */ var states_json = wc_country_select_params.countries.replace( /"/g, '"' ), states = JSON.parse( states_json ), wrapper_selectors = '.woocommerce-billing-fields,' + '.woocommerce-shipping-fields,' + '.woocommerce-address-fields,' + '.woocommerce-shipping-calculator'; $( document.body ).on( 'change refresh', 'select.country_to_state, input.country_to_state', function() { // Grab wrapping element to target only stateboxes in same 'group' var $wrapper = $( this ).closest( wrapper_selectors ); if ( ! $wrapper.length ) { $wrapper = $( this ).closest('.form-row').parent(); } var country = $( this ).val(), $statebox = $wrapper.find( '#billing_state, #shipping_state, #calc_shipping_state' ), $parent = $statebox.closest( '.form-row' ), input_name = $statebox.attr( 'name' ), input_id = $statebox.attr('id'), input_classes = $statebox.attr('data-input-classes'), value = $statebox.val(), placeholder = $statebox.attr( 'placeholder' ) || $statebox.attr( 'data-placeholder' ) || '', $newstate; if ( states[ country ] ) { if ( $.isEmptyObject( states[ country ] ) ) { $newstate = $( '' ) .prop( 'id', input_id ) .prop( 'name', input_name ) .prop( 'placeholder', placeholder ) .attr( 'data-input-classes', input_classes ) .addClass( 'hidden ' + input_classes ); $parent.hide().find( '.select2-container' ).remove(); $statebox.replaceWith( $newstate ); $( document.body ).trigger( 'country_to_state_changed', [ country, $wrapper ] ); } else { var state = states[ country ], $defaultOption = $( '' ).text( wc_country_select_params.i18n_select_state_text ); if ( ! placeholder ) { placeholder = wc_country_select_params.i18n_select_state_text; } $parent.show(); if ( $statebox.is( 'input' ) ) { $newstate = $( '' ) .prop( 'id', input_id ) .prop( 'name', input_name ) .data( 'placeholder', placeholder ) .attr( 'data-input-classes', input_classes ) .addClass( 'state_select ' + input_classes ); $statebox.replaceWith( $newstate ); $statebox = $wrapper.find( '#billing_state, #shipping_state, #calc_shipping_state' ); } $statebox.empty().append( $defaultOption ); $.each( state, function( index ) { var $option = $( '' ) .prop( 'value', index ) .text( state[ index ] ); $statebox.append( $option ); } ); $statebox.val( value ).trigger( 'change' ); $( document.body ).trigger( 'country_to_state_changed', [country, $wrapper ] ); } } else { if ( $statebox.is( 'select, input[type="hidden"]' ) ) { $newstate = $( '' ) .prop( 'id', input_id ) .prop( 'name', input_name ) .prop('placeholder', placeholder) .attr('data-input-classes', input_classes ) .addClass( 'input-text ' + input_classes ); $parent.show().find( '.select2-container' ).remove(); $statebox.replaceWith( $newstate ); $( document.body ).trigger( 'country_to_state_changed', [country, $wrapper ] ); } } $( document.body ).trigger( 'country_to_state_changing', [country, $wrapper ] ); }); $( document.body ).on( 'wc_address_i18n_ready', function() { // Init country selects with their default value once the page loads. $( wrapper_selectors ).each( function() { var $country_input = $( this ).find( '#billing_country, #shipping_country, #calc_shipping_country' ); if ( 0 === $country_input.length || 0 === $country_input.val().length ) { return; } $country_input.trigger( 'refresh' ); }); }); }); cart-fragments.js000064400000013007150732340420010020 0ustar00/* global wc_cart_fragments_params, Cookies */ jQuery( function( $ ) { // wc_cart_fragments_params is required to continue, ensure the object exists if ( typeof wc_cart_fragments_params === 'undefined' ) { return false; } /* Storage Handling */ var $supports_html5_storage = true, cart_hash_key = wc_cart_fragments_params.cart_hash_key; try { $supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null ); window.sessionStorage.setItem( 'wc', 'test' ); window.sessionStorage.removeItem( 'wc' ); window.localStorage.setItem( 'wc', 'test' ); window.localStorage.removeItem( 'wc' ); } catch( err ) { $supports_html5_storage = false; } /* Cart session creation time to base expiration on */ function set_cart_creation_timestamp() { if ( $supports_html5_storage ) { sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() ); } } /** Set the cart hash in both session and local storage */ function set_cart_hash( cart_hash ) { if ( $supports_html5_storage ) { localStorage.setItem( cart_hash_key, cart_hash ); sessionStorage.setItem( cart_hash_key, cart_hash ); } } var $fragment_refresh = { url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments' ), type: 'POST', data: { time: new Date().getTime() }, timeout: wc_cart_fragments_params.request_timeout, success: function( data ) { if ( data && data.fragments ) { $.each( data.fragments, function( key, value ) { $( key ).replaceWith( value ); }); if ( $supports_html5_storage ) { sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( data.fragments ) ); set_cart_hash( data.cart_hash ); if ( data.cart_hash ) { set_cart_creation_timestamp(); } } $( document.body ).trigger( 'wc_fragments_refreshed' ); } }, error: function() { $( document.body ).trigger( 'wc_fragments_ajax_error' ); } }; /* Named callback for refreshing cart fragment */ function refresh_cart_fragment() { $.ajax( $fragment_refresh ); } /* Cart Handling */ if ( $supports_html5_storage ) { var cart_timeout = null, day_in_ms = ( 24 * 60 * 60 * 1000 ); $( document.body ).on( 'wc_fragment_refresh updated_wc_div', function() { refresh_cart_fragment(); }); $( document.body ).on( 'added_to_cart removed_from_cart', function( event, fragments, cart_hash ) { var prev_cart_hash = sessionStorage.getItem( cart_hash_key ); if ( prev_cart_hash === null || prev_cart_hash === undefined || prev_cart_hash === '' ) { set_cart_creation_timestamp(); } sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) ); set_cart_hash( cart_hash ); }); $( document.body ).on( 'wc_fragments_refreshed', function() { clearTimeout( cart_timeout ); cart_timeout = setTimeout( refresh_cart_fragment, day_in_ms ); } ); // Refresh when storage changes in another tab $( window ).on( 'storage onstorage', function ( e ) { if ( cart_hash_key === e.originalEvent.key && localStorage.getItem( cart_hash_key ) !== sessionStorage.getItem( cart_hash_key ) ) { refresh_cart_fragment(); } }); // Refresh when page is shown after back button (safari) $( window ).on( 'pageshow' , function( e ) { if ( e.originalEvent.persisted ) { $( '.widget_shopping_cart_content' ).empty(); $( document.body ).trigger( 'wc_fragment_refresh' ); } } ); try { var wc_fragments = JSON.parse( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) ), cart_hash = sessionStorage.getItem( cart_hash_key ), cookie_hash = Cookies.get( 'woocommerce_cart_hash'), cart_created = sessionStorage.getItem( 'wc_cart_created' ); if ( cart_hash === null || cart_hash === undefined || cart_hash === '' ) { cart_hash = ''; } if ( cookie_hash === null || cookie_hash === undefined || cookie_hash === '' ) { cookie_hash = ''; } if ( cart_hash && ( cart_created === null || cart_created === undefined || cart_created === '' ) ) { throw 'No cart_created'; } if ( cart_created ) { var cart_expiration = ( ( 1 * cart_created ) + day_in_ms ), timestamp_now = ( new Date() ).getTime(); if ( cart_expiration < timestamp_now ) { throw 'Fragment expired'; } cart_timeout = setTimeout( refresh_cart_fragment, ( cart_expiration - timestamp_now ) ); } if ( wc_fragments && wc_fragments['div.widget_shopping_cart_content'] && cart_hash === cookie_hash ) { $.each( wc_fragments, function( key, value ) { $( key ).replaceWith(value); }); $( document.body ).trigger( 'wc_fragments_loaded' ); } else { throw 'No fragment'; } } catch( err ) { refresh_cart_fragment(); } } else { refresh_cart_fragment(); } /* Cart Hiding */ if ( Cookies.get( 'woocommerce_items_in_cart' ) > 0 ) { $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show(); } else { $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide(); } $( document.body ).on( 'adding_to_cart', function() { $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show(); }); // Customiser support. var hasSelectiveRefresh = ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh && wp.customize.widgetsPreview && wp.customize.widgetsPreview.WidgetPartial ); if ( hasSelectiveRefresh ) { wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() { refresh_cart_fragment(); } ); } }); country-select.min.js000064400000006520150732340420010647 0ustar00jQuery(function(t){if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var e=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var e=t(this),n=t.extend({placeholder:e.attr("data-placeholder")||e.attr("placeholder")||"",label:e.attr("data-label")||null,width:"100%"},{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}});t(this).on("select2:select",function(){t(this).trigger("focus")}).selectWoo(n)})};e(),t(document.body).on("country_to_state_changed",function(){e()})}var n=wc_country_select_params.countries.replace(/"/g,'"'),o=JSON.parse(n),a=".woocommerce-billing-fields,.woocommerce-shipping-fields,.woocommerce-address-fields,.woocommerce-shipping-calculator";t(document.body).on("change refresh","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(a);e.length||(e=t(this).closest(".form-row").parent());var n,c=t(this).val(),r=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=r.closest(".form-row"),s=r.attr("name"),_=r.attr("id"),l=r.attr("data-input-classes"),p=r.val(),u=r.attr("placeholder")||r.attr("data-placeholder")||"";if(o[c])if(t.isEmptyObject(o[c]))n=t('').prop("id",_).prop("name",s).prop("placeholder",u).attr("data-input-classes",l).addClass("hidden "+l),i.hide().find(".select2-container").remove(),r.replaceWith(n),t(document.body).trigger("country_to_state_changed",[c,e]);else{var d=o[c],h=t('').text(wc_country_select_params.i18n_select_state_text);u||(u=wc_country_select_params.i18n_select_state_text),i.show(),r.is("input")&&(n=t("").prop("id",_).prop("name",s).data("placeholder",u).attr("data-input-classes",l).addClass("state_select "+l),r.replaceWith(n),r=e.find("#billing_state, #shipping_state, #calc_shipping_state")),r.empty().append(h),t.each(d,function(e){var n=t("").prop("value",e).text(d[e]);r.append(n)}),r.val(p).trigger("change"),t(document.body).trigger("country_to_state_changed",[c,e])}else r.is('select, input[type="hidden"]')&&(n=t('').prop("id",_).prop("name",s).prop("placeholder",u).attr("data-input-classes",l).addClass("input-text "+l),i.show().find(".select2-container").remove(),r.replaceWith(n),t(document.body).trigger("country_to_state_changed",[c,e]));t(document.body).trigger("country_to_state_changing",[c,e])}),t(document.body).on("wc_address_i18n_ready",function(){t(a).each(function(){var e=t(this).find("#billing_country, #shipping_country, #calc_shipping_country");0!==e.length&&0!==e.val().length&&e.trigger("refresh")})})});credit-card-form.min.js000064400000001006150732340420011003 0ustar00jQuery(function(r){r(".wc-credit-card-form-card-number").payment("formatCardNumber"),r(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),r(".wc-credit-card-form-card-cvc").payment("formatCardCVC"),r(document.body).on("updated_checkout wc-credit-card-form-init",function(){r(".wc-credit-card-form-card-number").payment("formatCardNumber"),r(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),r(".wc-credit-card-form-card-cvc").payment("formatCardCVC")}).trigger("wc-credit-card-form-init")});add-to-cart.min.js000064400000005735150732340420007775 0ustar00jQuery(function(t){if("undefined"==typeof wc_add_to_cart_params)return!1;var a=function(){this.requests=[],this.addRequest=this.addRequest.bind(this),this.run=this.run.bind(this),t(document.body).on("click",".add_to_cart_button",{addToCartHandler:this},this.onAddToCart).on("click",".remove_from_cart_button",{addToCartHandler:this},this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("ajax_request_not_sent.adding_to_cart",this.updateButton).on("added_to_cart removed_from_cart",{addToCartHandler:this},this.updateFragments)};a.prototype.addRequest=function(t){this.requests.push(t),1===this.requests.length&&this.run()},a.prototype.run=function(){var a=this,e=a.requests[0].complete;a.requests[0].complete=function(){"function"==typeof e&&e(),a.requests.shift(),a.requests.length>0&&a.run()},t.ajax(this.requests[0])},a.prototype.onAddToCart=function(a){var e=t(this);if(e.is(".ajax_add_to_cart")){if(!e.attr("data-product_id"))return!0;if(a.preventDefault(),e.removeClass("added"),e.addClass("loading"),!1===t(document.body).triggerHandler("should_send_ajax_request.adding_to_cart",[e]))return t(document.body).trigger("ajax_request_not_sent.adding_to_cart",[!1,!1,e]),!0;var r={};t.each(e.data(),function(t,a){r[t]=a}),t.each(e[0].dataset,function(t,a){r[t]=a}),t(document.body).trigger("adding_to_cart",[e,r]),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),data:r,success:function(a){a&&(a.error&&a.product_url?window.location=a.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,e]):window.location=wc_add_to_cart_params.cart_url)},dataType:"json"})}},a.prototype.onRemoveFromCart=function(a){var e=t(this),r=e.closest(".woocommerce-mini-cart-item");a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),data:{cart_item_key:e.data("cart_item_key")},success:function(a){a&&a.fragments?t(document.body).trigger("removed_from_cart",[a.fragments,a.cart_hash,e]):window.location=e.attr("href")},error:function(){window.location=e.attr("href")},dataType:"json"})},a.prototype.updateButton=function(a,e,r,d){(d=void 0!==d&&d)&&(d.removeClass("loading"),e&&d.addClass("added"),e&&!wc_add_to_cart_params.is_cart&&0===d.parent().find(".added_to_cart").length&&d.after(''+wc_add_to_cart_params.i18n_view_cart+""),t(document.body).trigger("wc_cart_button_updated",[d]))},a.prototype.updateFragments=function(a,e){e&&(t.each(e,function(a){t(a).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),t.each(e,function(a,e){t(a).replaceWith(e),t(a).stop(!0).css("opacity","1").unblock()}),t(document.body).trigger("wc_fragments_loaded"))},new a});add-to-cart.js000064400000013226150732340420007205 0ustar00/* global wc_add_to_cart_params */ jQuery( function( $ ) { if ( typeof wc_add_to_cart_params === 'undefined' ) { return false; } /** * AddToCartHandler class. */ var AddToCartHandler = function() { this.requests = []; this.addRequest = this.addRequest.bind( this ); this.run = this.run.bind( this ); $( document.body ) .on( 'click', '.add_to_cart_button', { addToCartHandler: this }, this.onAddToCart ) .on( 'click', '.remove_from_cart_button', { addToCartHandler: this }, this.onRemoveFromCart ) .on( 'added_to_cart', this.updateButton ) .on( 'ajax_request_not_sent.adding_to_cart', this.updateButton ) .on( 'added_to_cart removed_from_cart', { addToCartHandler: this }, this.updateFragments ); }; /** * Add add to cart event. */ AddToCartHandler.prototype.addRequest = function( request ) { this.requests.push( request ); if ( 1 === this.requests.length ) { this.run(); } }; /** * Run add to cart events. */ AddToCartHandler.prototype.run = function() { var requestManager = this, originalCallback = requestManager.requests[0].complete; requestManager.requests[0].complete = function() { if ( typeof originalCallback === 'function' ) { originalCallback(); } requestManager.requests.shift(); if ( requestManager.requests.length > 0 ) { requestManager.run(); } }; $.ajax( this.requests[0] ); }; /** * Handle the add to cart event. */ AddToCartHandler.prototype.onAddToCart = function( e ) { var $thisbutton = $( this ); if ( $thisbutton.is( '.ajax_add_to_cart' ) ) { if ( ! $thisbutton.attr( 'data-product_id' ) ) { return true; } e.preventDefault(); $thisbutton.removeClass( 'added' ); $thisbutton.addClass( 'loading' ); // Allow 3rd parties to validate and quit early. if ( false === $( document.body ).triggerHandler( 'should_send_ajax_request.adding_to_cart', [ $thisbutton ] ) ) { $( document.body ).trigger( 'ajax_request_not_sent.adding_to_cart', [ false, false, $thisbutton ] ); return true; } var data = {}; // Fetch changes that are directly added by calling $thisbutton.data( key, value ) $.each( $thisbutton.data(), function( key, value ) { data[ key ] = value; }); // Fetch data attributes in $thisbutton. Give preference to data-attributes because they can be directly modified by javascript // while `.data` are jquery specific memory stores. $.each( $thisbutton[0].dataset, function( key, value ) { data[ key ] = value; }); // Trigger event. $( document.body ).trigger( 'adding_to_cart', [ $thisbutton, data ] ); e.data.addToCartHandler.addRequest({ type: 'POST', url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_to_cart' ), data: data, success: function( response ) { if ( ! response ) { return; } if ( response.error && response.product_url ) { window.location = response.product_url; return; } // Redirect to cart option if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { window.location = wc_add_to_cart_params.cart_url; return; } // Trigger event so themes can refresh other areas. $( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); }, dataType: 'json' }); } }; /** * Update fragments after remove from cart event in mini-cart. */ AddToCartHandler.prototype.onRemoveFromCart = function( e ) { var $thisbutton = $( this ), $row = $thisbutton.closest( '.woocommerce-mini-cart-item' ); e.preventDefault(); $row.block({ message: null, overlayCSS: { opacity: 0.6 } }); e.data.addToCartHandler.addRequest({ type: 'POST', url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'remove_from_cart' ), data: { cart_item_key : $thisbutton.data( 'cart_item_key' ) }, success: function( response ) { if ( ! response || ! response.fragments ) { window.location = $thisbutton.attr( 'href' ); return; } $( document.body ).trigger( 'removed_from_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); }, error: function() { window.location = $thisbutton.attr( 'href' ); return; }, dataType: 'json' }); }; /** * Update cart page elements after add to cart events. */ AddToCartHandler.prototype.updateButton = function( e, fragments, cart_hash, $button ) { $button = typeof $button === 'undefined' ? false : $button; if ( $button ) { $button.removeClass( 'loading' ); if ( fragments ) { $button.addClass( 'added' ); } // View cart text. if ( fragments && ! wc_add_to_cart_params.is_cart && $button.parent().find( '.added_to_cart' ).length === 0 ) { $button.after( '' + wc_add_to_cart_params.i18n_view_cart + '' ); } $( document.body ).trigger( 'wc_cart_button_updated', [ $button ] ); } }; /** * Update fragments after add to cart events. */ AddToCartHandler.prototype.updateFragments = function( e, fragments ) { if ( fragments ) { $.each( fragments, function( key ) { $( key ) .addClass( 'updating' ) .fadeTo( '400', '0.6' ) .block({ message: null, overlayCSS: { opacity: 0.6 } }); }); $.each( fragments, function( key, value ) { $( key ).replaceWith( value ); $( key ).stop( true ).css( 'opacity', '1' ).unblock(); }); $( document.body ).trigger( 'wc_fragments_loaded' ); } }; /** * Init AddToCartHandler. */ new AddToCartHandler(); }); checkout.js000064400000062036150732340420006716 0ustar00/* global wc_checkout_params */ jQuery( function( $ ) { // wc_checkout_params is required to continue, ensure the object exists if ( typeof wc_checkout_params === 'undefined' ) { return false; } $.blockUI.defaults.overlayCSS.cursor = 'default'; var wc_checkout_form = { updateTimer: false, dirtyInput: false, selectedPaymentMethod: false, xhr: false, $order_review: $( '#order_review' ), $checkout_form: $( 'form.checkout' ), init: function() { $( document.body ).on( 'update_checkout', this.update_checkout ); $( document.body ).on( 'init_checkout', this.init_checkout ); // Payment methods this.$checkout_form.on( 'click', 'input[name="payment_method"]', this.payment_method_selected ); if ( $( document.body ).hasClass( 'woocommerce-order-pay' ) ) { this.$order_review.on( 'click', 'input[name="payment_method"]', this.payment_method_selected ); this.$order_review.on( 'submit', this.submitOrder ); this.$order_review.attr( 'novalidate', 'novalidate' ); } // Prevent HTML5 validation which can conflict. this.$checkout_form.attr( 'novalidate', 'novalidate' ); // Form submission this.$checkout_form.on( 'submit', this.submit ); // Inline validation this.$checkout_form.on( 'input validate change', '.input-text, select, input:checkbox', this.validate_field ); // Manual trigger this.$checkout_form.on( 'update', this.trigger_update_checkout ); // Inputs/selects which update totals this.$checkout_form.on( 'change', 'select.shipping_method, input[name^="shipping_method"], #ship-to-different-address input, .update_totals_on_change select, .update_totals_on_change input[type="radio"], .update_totals_on_change input[type="checkbox"]', this.trigger_update_checkout ); // eslint-disable-line max-len this.$checkout_form.on( 'change', '.address-field select', this.input_changed ); this.$checkout_form.on( 'change', '.address-field input.input-text, .update_totals_on_change input.input-text', this.maybe_input_changed ); // eslint-disable-line max-len this.$checkout_form.on( 'keydown', '.address-field input.input-text, .update_totals_on_change input.input-text', this.queue_update_checkout ); // eslint-disable-line max-len // Address fields this.$checkout_form.on( 'change', '#ship-to-different-address input', this.ship_to_different_address ); // Trigger events this.$checkout_form.find( '#ship-to-different-address input' ).trigger( 'change' ); this.init_payment_methods(); // Update on page load if ( wc_checkout_params.is_checkout === '1' ) { $( document.body ).trigger( 'init_checkout' ); } if ( wc_checkout_params.option_guest_checkout === 'yes' ) { $( 'input#createaccount' ).on( 'change', this.toggle_create_account ).trigger( 'change' ); } }, init_payment_methods: function() { var $payment_methods = $( '.woocommerce-checkout' ).find( 'input[name="payment_method"]' ); // If there is one method, we can hide the radio input if ( 1 === $payment_methods.length ) { $payment_methods.eq(0).hide(); } // If there was a previously selected method, check that one. if ( wc_checkout_form.selectedPaymentMethod ) { $( '#' + wc_checkout_form.selectedPaymentMethod ).prop( 'checked', true ); } // If there are none selected, select the first. if ( 0 === $payment_methods.filter( ':checked' ).length ) { $payment_methods.eq(0).prop( 'checked', true ); } // Get name of new selected method. var checkedPaymentMethod = $payment_methods.filter( ':checked' ).eq(0).prop( 'id' ); if ( $payment_methods.length > 1 ) { // Hide open descriptions. $( 'div.payment_box:not(".' + checkedPaymentMethod + '")' ).filter( ':visible' ).slideUp( 0 ); } // Trigger click event for selected method $payment_methods.filter( ':checked' ).eq(0).trigger( 'click' ); }, get_payment_method: function() { return wc_checkout_form.$checkout_form.find( 'input[name="payment_method"]:checked' ).val(); }, payment_method_selected: function( e ) { e.stopPropagation(); if ( $( '.payment_methods input.input-radio' ).length > 1 ) { var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) ), is_checked = $( this ).is( ':checked' ); if ( is_checked && ! target_payment_box.is( ':visible' ) ) { $( 'div.payment_box' ).filter( ':visible' ).slideUp( 230 ); if ( is_checked ) { target_payment_box.slideDown( 230 ); } } } else { $( 'div.payment_box' ).show(); } if ( $( this ).data( 'order_button_text' ) ) { $( '#place_order' ).text( $( this ).data( 'order_button_text' ) ); } else { $( '#place_order' ).text( $( '#place_order' ).data( 'value' ) ); } var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' ); if ( selectedPaymentMethod !== wc_checkout_form.selectedPaymentMethod ) { $( document.body ).trigger( 'payment_method_selected' ); } wc_checkout_form.selectedPaymentMethod = selectedPaymentMethod; }, toggle_create_account: function() { $( 'div.create-account' ).hide(); if ( $( this ).is( ':checked' ) ) { // Ensure password is not pre-populated. $( '#account_password' ).val( '' ).trigger( 'change' ); $( 'div.create-account' ).slideDown(); } }, init_checkout: function() { $( document.body ).trigger( 'update_checkout' ); }, maybe_input_changed: function( e ) { if ( wc_checkout_form.dirtyInput ) { wc_checkout_form.input_changed( e ); } }, input_changed: function( e ) { wc_checkout_form.dirtyInput = e.target; wc_checkout_form.maybe_update_checkout(); }, queue_update_checkout: function( e ) { var code = e.keyCode || e.which || 0; if ( code === 9 ) { return true; } wc_checkout_form.dirtyInput = this; wc_checkout_form.reset_update_checkout_timer(); wc_checkout_form.updateTimer = setTimeout( wc_checkout_form.maybe_update_checkout, '1000' ); }, trigger_update_checkout: function() { wc_checkout_form.reset_update_checkout_timer(); wc_checkout_form.dirtyInput = false; $( document.body ).trigger( 'update_checkout' ); }, maybe_update_checkout: function() { var update_totals = true; if ( $( wc_checkout_form.dirtyInput ).length ) { var $required_inputs = $( wc_checkout_form.dirtyInput ).closest( 'div' ).find( '.address-field.validate-required' ); if ( $required_inputs.length ) { $required_inputs.each( function() { if ( $( this ).find( 'input.input-text' ).val() === '' ) { update_totals = false; } }); } } if ( update_totals ) { wc_checkout_form.trigger_update_checkout(); } }, ship_to_different_address: function() { $( 'div.shipping_address' ).hide(); if ( $( this ).is( ':checked' ) ) { $( 'div.shipping_address' ).slideDown(); } }, reset_update_checkout_timer: function() { clearTimeout( wc_checkout_form.updateTimer ); }, is_valid_json: function( raw_json ) { try { var json = JSON.parse( raw_json ); return ( json && 'object' === typeof json ); } catch ( e ) { return false; } }, validate_field: function( e ) { var $this = $( this ), $parent = $this.closest( '.form-row' ), validated = true, validate_required = $parent.is( '.validate-required' ), validate_email = $parent.is( '.validate-email' ), validate_phone = $parent.is( '.validate-phone' ), pattern = '', event_type = e.type; if ( 'input' === event_type ) { $parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone woocommerce-validated' ); // eslint-disable-line max-len } if ( 'validate' === event_type || 'change' === event_type ) { if ( validate_required ) { if ( 'checkbox' === $this.attr( 'type' ) && ! $this.is( ':checked' ) ) { $parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' ); validated = false; } else if ( $this.val() === '' ) { $parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' ); validated = false; } } if ( validate_email ) { if ( $this.val() ) { /* https://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */ pattern = new RegExp( /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i ); // eslint-disable-line max-len if ( ! pattern.test( $this.val() ) ) { $parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email woocommerce-invalid-phone' ); // eslint-disable-line max-len validated = false; } } } if ( validate_phone ) { pattern = new RegExp( /[\s\#0-9_\-\+\/\(\)\.]/g ); if ( 0 < $this.val().replace( pattern, '' ).length ) { $parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-phone' ); validated = false; } } if ( validated ) { $parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone' ).addClass( 'woocommerce-validated' ); // eslint-disable-line max-len } } }, update_checkout: function( event, args ) { // Small timeout to prevent multiple requests when several fields update at the same time wc_checkout_form.reset_update_checkout_timer(); wc_checkout_form.updateTimer = setTimeout( wc_checkout_form.update_checkout_action, '5', args ); }, update_checkout_action: function( args ) { if ( wc_checkout_form.xhr ) { wc_checkout_form.xhr.abort(); } if ( $( 'form.checkout' ).length === 0 ) { return; } args = typeof args !== 'undefined' ? args : { update_shipping_method: true }; var country = $( '#billing_country' ).val(), state = $( '#billing_state' ).val(), postcode = $( ':input#billing_postcode' ).val(), city = $( '#billing_city' ).val(), address = $( ':input#billing_address_1' ).val(), address_2 = $( ':input#billing_address_2' ).val(), s_country = country, s_state = state, s_postcode = postcode, s_city = city, s_address = address, s_address_2 = address_2, $required_inputs = $( wc_checkout_form.$checkout_form ).find( '.address-field.validate-required:visible' ), has_full_address = true; if ( $required_inputs.length ) { $required_inputs.each( function() { if ( $( this ).find( ':input' ).val() === '' ) { has_full_address = false; } }); } if ( $( '#ship-to-different-address' ).find( 'input' ).is( ':checked' ) ) { s_country = $( '#shipping_country' ).val(); s_state = $( '#shipping_state' ).val(); s_postcode = $( ':input#shipping_postcode' ).val(); s_city = $( '#shipping_city' ).val(); s_address = $( ':input#shipping_address_1' ).val(); s_address_2 = $( ':input#shipping_address_2' ).val(); } var data = { security : wc_checkout_params.update_order_review_nonce, payment_method : wc_checkout_form.get_payment_method(), country : country, state : state, postcode : postcode, city : city, address : address, address_2 : address_2, s_country : s_country, s_state : s_state, s_postcode : s_postcode, s_city : s_city, s_address : s_address, s_address_2 : s_address_2, has_full_address: has_full_address, post_data : $( 'form.checkout' ).serialize() }; if ( false !== args.update_shipping_method ) { var shipping_methods = {}; // eslint-disable-next-line max-len $( 'select.shipping_method, input[name^="shipping_method"][type="radio"]:checked, input[name^="shipping_method"][type="hidden"]' ).each( function() { shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val(); } ); data.shipping_method = shipping_methods; } $( '.woocommerce-checkout-payment, .woocommerce-checkout-review-order-table' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); wc_checkout_form.xhr = $.ajax({ type: 'POST', url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'update_order_review' ), data: data, success: function( data ) { // Reload the page if requested if ( data && true === data.reload ) { window.location.reload(); return; } // Remove any notices added previously $( '.woocommerce-NoticeGroup-updateOrderReview' ).remove(); var termsCheckBoxChecked = $( '#terms' ).prop( 'checked' ); // Save payment details to a temporary object var paymentDetails = {}; $( '.payment_box :input' ).each( function() { var ID = $( this ).attr( 'id' ); if ( ID ) { if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) { paymentDetails[ ID ] = $( this ).prop( 'checked' ); } else { paymentDetails[ ID ] = $( this ).val(); } } }); // Always update the fragments if ( data && data.fragments ) { $.each( data.fragments, function ( key, value ) { if ( ! wc_checkout_form.fragments || wc_checkout_form.fragments[ key ] !== value ) { $( key ).replaceWith( value ); } $( key ).unblock(); } ); wc_checkout_form.fragments = data.fragments; } // Recheck the terms and conditions box, if needed if ( termsCheckBoxChecked ) { $( '#terms' ).prop( 'checked', true ); } // Fill in the payment details if possible without overwriting data if set. if ( ! $.isEmptyObject( paymentDetails ) ) { $( '.payment_box :input' ).each( function() { var ID = $( this ).attr( 'id' ); if ( ID ) { if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) { $( this ).prop( 'checked', paymentDetails[ ID ] ).trigger( 'change' ); } else if ( $.inArray( $( this ).attr( 'type' ), [ 'select' ] ) !== -1 ) { $( this ).val( paymentDetails[ ID ] ).trigger( 'change' ); } else if ( null !== $( this ).val() && 0 === $( this ).val().length ) { $( this ).val( paymentDetails[ ID ] ).trigger( 'change' ); } } }); } // Check for error if ( data && 'failure' === data.result ) { var $form = $( 'form.checkout' ); // Remove notices from all sources $( '.woocommerce-error, .woocommerce-message' ).remove(); // Add new errors returned by this event if ( data.messages ) { $form.prepend( '
' + data.messages + '
' ); // eslint-disable-line max-len } else { $form.prepend( data ); } // Lose focus for all fields $form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' ); wc_checkout_form.scroll_to_notices(); } // Re-init methods wc_checkout_form.init_payment_methods(); // Fire updated_checkout event. $( document.body ).trigger( 'updated_checkout', [ data ] ); } }); }, handleUnloadEvent: function( e ) { // Modern browsers have their own standard generic messages that they will display. // Confirm, alert, prompt or custom message are not allowed during the unload event // Browsers will display their own standard messages // Check if the browser is Internet Explorer if((navigator.userAgent.indexOf('MSIE') !== -1 ) || (!!document.documentMode)) { // IE handles unload events differently than modern browsers e.preventDefault(); return undefined; } return true; }, attachUnloadEventsOnSubmit: function() { $( window ).on('beforeunload', this.handleUnloadEvent); }, detachUnloadEventsOnSubmit: function() { $( window ).off('beforeunload', this.handleUnloadEvent); }, blockOnSubmit: function( $form ) { var isBlocked = $form.data( 'blockUI.isBlocked' ); if ( 1 !== isBlocked ) { $form.block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); } }, submitOrder: function() { wc_checkout_form.blockOnSubmit( $( this ) ); }, submit: function() { wc_checkout_form.reset_update_checkout_timer(); var $form = $( this ); if ( $form.is( '.processing' ) ) { return false; } // Trigger a handler to let gateways manipulate the checkout if needed // eslint-disable-next-line max-len if ( $form.triggerHandler( 'checkout_place_order', [ wc_checkout_form ] ) !== false && $form.triggerHandler( 'checkout_place_order_' + wc_checkout_form.get_payment_method(), [ wc_checkout_form ] ) !== false ) { $form.addClass( 'processing' ); wc_checkout_form.blockOnSubmit( $form ); // Attach event to block reloading the page when the form has been submitted wc_checkout_form.attachUnloadEventsOnSubmit(); // ajaxSetup is global, but we use it to ensure JSON is valid once returned. $.ajaxSetup( { dataFilter: function( raw_response, dataType ) { // We only want to work with JSON if ( 'json' !== dataType ) { return raw_response; } if ( wc_checkout_form.is_valid_json( raw_response ) ) { return raw_response; } else { // Attempt to fix the malformed JSON var maybe_valid_json = raw_response.match( /{"result.*}/ ); if ( null === maybe_valid_json ) { console.log( 'Unable to fix malformed JSON' ); } else if ( wc_checkout_form.is_valid_json( maybe_valid_json[0] ) ) { console.log( 'Fixed malformed JSON. Original:' ); console.log( raw_response ); raw_response = maybe_valid_json[0]; } else { console.log( 'Unable to fix malformed JSON' ); } } return raw_response; } } ); $.ajax({ type: 'POST', url: wc_checkout_params.checkout_url, data: $form.serialize(), dataType: 'json', success: function( result ) { // Detach the unload handler that prevents a reload / redirect wc_checkout_form.detachUnloadEventsOnSubmit(); try { if ( 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success', [ result, wc_checkout_form ] ) !== false ) { if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) { window.location = result.redirect; } else { window.location = decodeURI( result.redirect ); } } else if ( 'failure' === result.result ) { throw 'Result failure'; } else { throw 'Invalid response'; } } catch( err ) { // Reload page if ( true === result.reload ) { window.location.reload(); return; } // Trigger update in case we need a fresh nonce if ( true === result.refresh ) { $( document.body ).trigger( 'update_checkout' ); } // Add new errors if ( result.messages ) { wc_checkout_form.submit_error( result.messages ); } else { wc_checkout_form.submit_error( '
' + wc_checkout_params.i18n_checkout_error + '
' ); // eslint-disable-line max-len } } }, error: function( jqXHR, textStatus, errorThrown ) { // Detach the unload handler that prevents a reload / redirect wc_checkout_form.detachUnloadEventsOnSubmit(); wc_checkout_form.submit_error( '
' + ( errorThrown || wc_checkout_params.i18n_checkout_error ) + '
' ); } }); } return false; }, submit_error: function( error_message ) { $( '.woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message' ).remove(); wc_checkout_form.$checkout_form.prepend( '
' + error_message + '
' ); // eslint-disable-line max-len wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock(); wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' ); wc_checkout_form.scroll_to_notices(); $( document.body ).trigger( 'checkout_error' , [ error_message ] ); }, scroll_to_notices: function() { var scrollElement = $( '.woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout' ); if ( ! scrollElement.length ) { scrollElement = $( 'form.checkout' ); } $.scroll_to_notices( scrollElement ); } }; var wc_checkout_coupons = { init: function() { $( document.body ).on( 'click', 'a.showcoupon', this.show_coupon_form ); $( document.body ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon ); $( 'form.checkout_coupon' ).hide().on( 'submit', this.submit ); }, show_coupon_form: function() { $( '.checkout_coupon' ).slideToggle( 400, function() { $( '.checkout_coupon' ).find( ':input:eq(0)' ).trigger( 'focus' ); }); return false; }, submit: function() { var $form = $( this ); if ( $form.is( '.processing' ) ) { return false; } $form.addClass( 'processing' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); var data = { security: wc_checkout_params.apply_coupon_nonce, coupon_code: $form.find( 'input[name="coupon_code"]' ).val() }; $.ajax({ type: 'POST', url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'apply_coupon' ), data: data, success: function( code ) { $( '.woocommerce-error, .woocommerce-message' ).remove(); $form.removeClass( 'processing' ).unblock(); if ( code ) { $form.before( code ); $form.slideUp(); $( document.body ).trigger( 'applied_coupon_in_checkout', [ data.coupon_code ] ); $( document.body ).trigger( 'update_checkout', { update_shipping_method: false } ); } }, dataType: 'html' }); return false; }, remove_coupon: function( e ) { e.preventDefault(); var container = $( this ).parents( '.woocommerce-checkout-review-order' ), coupon = $( this ).data( 'coupon' ); container.addClass( 'processing' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); var data = { security: wc_checkout_params.remove_coupon_nonce, coupon: coupon }; $.ajax({ type: 'POST', url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'remove_coupon' ), data: data, success: function( code ) { $( '.woocommerce-error, .woocommerce-message' ).remove(); container.removeClass( 'processing' ).unblock(); if ( code ) { $( 'form.woocommerce-checkout' ).before( code ); $( document.body ).trigger( 'removed_coupon_in_checkout', [ data.coupon ] ); $( document.body ).trigger( 'update_checkout', { update_shipping_method: false } ); // Remove coupon code from coupon field $( 'form.checkout_coupon' ).find( 'input[name="coupon_code"]' ).val( '' ); } }, error: function ( jqXHR ) { if ( wc_checkout_params.debug_mode ) { /* jshint devel: true */ console.log( jqXHR.responseText ); } }, dataType: 'html' }); } }; var wc_checkout_login_form = { init: function() { $( document.body ).on( 'click', 'a.showlogin', this.show_login_form ); }, show_login_form: function() { $( 'form.login, form.woocommerce-form--login' ).slideToggle(); return false; } }; var wc_terms_toggle = { init: function() { $( document.body ).on( 'click', 'a.woocommerce-terms-and-conditions-link', this.toggle_terms ); }, toggle_terms: function() { if ( $( '.woocommerce-terms-and-conditions' ).length ) { $( '.woocommerce-terms-and-conditions' ).slideToggle( function() { var link_toggle = $( '.woocommerce-terms-and-conditions-link' ); if ( $( '.woocommerce-terms-and-conditions' ).is( ':visible' ) ) { link_toggle.addClass( 'woocommerce-terms-and-conditions-link--open' ); link_toggle.removeClass( 'woocommerce-terms-and-conditions-link--closed' ); } else { link_toggle.removeClass( 'woocommerce-terms-and-conditions-link--open' ); link_toggle.addClass( 'woocommerce-terms-and-conditions-link--closed' ); } } ); return false; } } }; wc_checkout_form.init(); wc_checkout_coupons.init(); wc_checkout_login_form.init(); wc_terms_toggle.init(); }); address-i18n.min.js000064400000005136150732340420010073 0ustar00jQuery(function(e){if("undefined"==typeof wc_address_i18n_params)return!1;var a=wc_address_i18n_params.locale.replace(/"/g,'"'),i=JSON.parse(a);function d(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append(' *')):(e.find("label .required").remove(),e.removeClass("validate-required woocommerce-invalid woocommerce-invalid-required-field"),0===e.find("label .optional").length&&e.find("label").append(' ('+wc_address_i18n_params.i18n_optional_text+")"))}e(document.body).on("country_to_state_changing",function(a,r,t){var l,n=t;l="undefined"!=typeof i[r]?i[r]:i["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),p=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),p.attr("data-o_class",p.attr("class")));var f=JSON.parse(wc_address_i18n_params.locale_fields);e.each(f,function(a,r){var t=n.find(r),o=e.extend(!0,{},i["default"][a],l[a]);"undefined"!=typeof o.label&&t.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(t.find(":input").attr("placeholder",o.placeholder),t.find(":input").attr("data-placeholder",o.placeholder),t.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||t.find("label").length||(t.find(":input").attr("placeholder",o.label),t.find(":input").attr("data-placeholder",o.label),t.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?d(t,o.required):d(t,!1),"undefined"!=typeof o.priority&&t.data("priority",o.priority),"state"!==a&&("undefined"!=typeof o.hidden&&!0===o.hidden?t.hide().find(":input").val(""):t.show()),Array.isArray(o["class"])&&(t.removeClass("form-row-first form-row-last form-row-wide"),t.addClass(o["class"].join(" ")))}),e(".woocommerce-billing-fields__field-wrapper,.woocommerce-shipping-fields__field-wrapper,.woocommerce-address-fields__field-wrapper,.woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var d=e(i).find(".form-row"),r=d.first().parent(),t=0;d.each(function(){e(this).data("priority")||e(this).data("priority",t+1),t=e(this).data("priority")}),d.sort(function(a,i){var d=parseInt(e(a).data("priority"),10),r=parseInt(e(i).data("priority"),10);return d>r?1:d0&&n(s),t(document.body).trigger("wc_cart_emptied")}else t(".woocommerce-checkout").length&&t(document.body).trigger("update_checkout"),t(".woocommerce-cart-form").replaceWith(i),t(".woocommerce-cart-form").find(':input[name="update_cart"]').prop("disabled",!0),s.length>0&&n(s),a(r);t(document.body).trigger("updated_wc_div")}else window.location.reload()},a=function(e){t(".cart_totals").replaceWith(e),t(document.body).trigger("updated_cart_totals")},n=function(e,o){o||(o=t(".woocommerce-notices-wrapper:first")||t(".wc-empty-cart-message").closest(".woocommerce")||t(".woocommerce-cart-form")),o.prepend(e)},s={init:function(e){this.cart=e,this.toggle_shipping=this.toggle_shipping.bind(this),this.shipping_method_selected=this.shipping_method_selected.bind(this),this.shipping_calculator_submit=this.shipping_calculator_submit.bind(this),t(document).on("click",".shipping-calculator-button",this.toggle_shipping),t(document).on("change","select.shipping_method, :input[name^=shipping_method]",this.shipping_method_selected),t(document).on("submit","form.woocommerce-shipping-calculator",this.shipping_calculator_submit),t(".shipping-calculator-form").hide()},toggle_shipping:function(){return t(".shipping-calculator-form").slideToggle("slow"),t("select.country_to_state, input.country_to_state").trigger("change"),t(document.body).trigger("country_to_state_changed"),!1},shipping_method_selected:function(){var o={};t("select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]").each(function(){o[t(this).data("index")]=t(this).val()}),c(t("div.cart_totals"));var r={security:wc_cart_params.update_shipping_method_nonce,shipping_method:o};t.ajax({type:"post",url:e("update_shipping_method"),data:r,dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals")),t(document.body).trigger("updated_shipping_method")}})},shipping_calculator_submit:function(e){e.preventDefault();var o=t(e.currentTarget);c(t("div.cart_totals")),c(o),t("").attr("type","hidden").attr("name","calc_shipping").attr("value","x").appendTo(o),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(o),i(t("div.cart_totals"))}})}},u={init:function(){this.update_cart_totals=this.update_cart_totals.bind(this),this.input_keypress=this.input_keypress.bind(this),this.cart_submit=this.cart_submit.bind(this),this.submit_click=this.submit_click.bind(this),this.apply_coupon=this.apply_coupon.bind(this),this.remove_coupon_clicked=this.remove_coupon_clicked.bind(this),this.quantity_update=this.quantity_update.bind(this),this.item_remove_clicked=this.item_remove_clicked.bind(this),this.item_restore_clicked=this.item_restore_clicked.bind(this),this.update_cart=this.update_cart.bind(this),t(document).on("wc_update_cart added_to_cart",function(){u.update_cart.apply(u,[].slice.call(arguments,1))}),t(document).on("click",".woocommerce-cart-form :input[type=submit]",this.submit_click),t(document).on("keypress",".woocommerce-cart-form :input[type=number]",this.input_keypress),t(document).on("submit",".woocommerce-cart-form",this.cart_submit),t(document).on("click","a.woocommerce-remove-coupon",this.remove_coupon_clicked),t(document).on("click",".woocommerce-cart-form .product-remove > a",this.item_remove_clicked),t(document).on("click",".woocommerce-cart .restore-item",this.item_restore_clicked),t(document).on("change input",".woocommerce-cart-form .cart_item :input",this.input_changed),t('.woocommerce-cart-form :input[name="update_cart"]').prop("disabled",!0)},input_changed:function(){t('.woocommerce-cart-form :input[name="update_cart"]').prop("disabled",!1)},update_cart:function(e){var o=t(".woocommerce-cart-form");c(o),c(t("div.cart_totals")),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t,e)},complete:function(){i(o),i(t("div.cart_totals")),t.scroll_to_notices(t('[role="alert"]'))}})},update_cart_totals:function(){c(t("div.cart_totals")),t.ajax({url:e("get_cart_totals"),dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals"))}})},input_keypress:function(e){if(13===e.keyCode){var o=t(e.currentTarget).parents("form");try{o[0].checkValidity()&&(e.preventDefault(),this.cart_submit(e))}catch(c){e.preventDefault(),this.cart_submit(e)}}},cart_submit:function(e){var c=t(document.activeElement),i=t(":input[type=submit][clicked=true]"),r=t(e.currentTarget);if(r.is("form")||(r=t(e.currentTarget).parents("form")),0!==r.find(".woocommerce-cart-form__contents").length)return!o(r)&&void(i.is(':input[name="update_cart"]')||c.is("input.qty")?(e.preventDefault(),this.quantity_update(r)):(i.is(':input[name="apply_coupon"]')||c.is("#coupon_code"))&&(e.preventDefault(),this.apply_coupon(r)))},submit_click:function(e){t(":input[type=submit]",t(e.target).parents("form")).removeAttr("clicked"),t(e.target).attr("clicked","true")},apply_coupon:function(o){c(o);var r=this,a=t("#coupon_code"),s=a.val(),u={security:wc_cart_params.apply_coupon_nonce,coupon_code:s};t.ajax({type:"POST",url:e("apply_coupon"),data:u,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success").remove(),n(e),t(document.body).trigger("applied_coupon",[s])},complete:function(){i(o),a.val(""),r.update_cart(!0)}})},remove_coupon_clicked:function(o){o.preventDefault();var r=this,a=t(o.currentTarget).closest(".cart_totals"),s=t(o.currentTarget).attr("data-coupon");c(a);var u={security:wc_cart_params.remove_coupon_nonce,coupon:s};t.ajax({type:"POST",url:e("remove_coupon"),data:u,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success").remove(),n(e),t(document.body).trigger("removed_coupon",[s]),i(a)},complete:function(){r.update_cart(!0)}})},quantity_update:function(e){c(e),c(t("div.cart_totals")),t("").attr("type","hidden").attr("name","update_cart").attr("value","Update Cart").appendTo(e),t.ajax({type:e.attr("method"),url:e.attr("action"),data:e.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(e),i(t("div.cart_totals")),t.scroll_to_notices(t('[role="alert"]'))}})},item_remove_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=o.parents("form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals")),t.scroll_to_notices(t('[role="alert"]'))}})},item_restore_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=t("form.woocommerce-cart-form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals"))}})}};s.init(u),u.init()});password-strength-meter.min.js000064400000003756150732340420012507 0ustar00jQuery(function(s){"use strict";var r={init:function(){s(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),s("form.checkout #createaccount").trigger("change")},strengthMeter:function(){var e,t=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),o=s('button[type="submit"]',t),a=s("#reg_password, #account_password, #password_1",t),d=a.val(),n=!t.is("form.checkout");r.includeMeter(t,a),e=r.checkPasswordStrength(t,a),wc_password_strength_meter_params.stop_checkout&&(n=!0),d.length>0&&e
'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o=''+wc_password_strength_meter_params.i18n_password_hint+"",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputDisallowedList()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a