Sha256: 7347bcf906682ce968ba52dfda8d8710c38e904603b79615e07cb4c185f66575

Contents?: true

Size: 1.85 KB

Versions: 62

Compression:

Stored size: 1.85 KB

Contents

/**
 * @namespace WORKAREA.checkoutShippingServices
 */
WORKAREA.registerModule('checkoutShippingServices', (function () {
    'use strict';

    var updateCheckoutStepSummary = function (response, $container) {
            var $response = $(response);
            $('.checkout-step-summary', $container).replaceWith($response);
            WORKAREA.initModules($response);
        },

        enableSubmit = function ($form) {
            $('button[type=submit]', $form).prop('disabled', false);
            $('input[type=radio]', $form).prop('disabled', false);
        },

        disableSubmit = function ($form) {
            $('button[type=submit]', $form).prop('disabled', 'disabled');
            $('input[type=radio]', $form).prop('disabled', 'disabled');
        },

        handleShippingChange = _.debounce(function (event) {
            var $shippingForm = $(event.currentTarget).closest('form'),
                $container = $shippingForm.closest('.page-content'),
                url = $shippingForm.attr('action'),
                data = $shippingForm.serialize(),
                updatingShipping = $.post(url, data);

            disableSubmit($shippingForm);

            updatingShipping.done(function (response) {
                updateCheckoutStepSummary(response, $container);
                enableSubmit($shippingForm);
            });
        }, WORKAREA.config.checkoutShippingServices.requestTimeout),

        /**
         * @method
         * @name init
         * @memberof WORKAREA.checkoutShippingServices
         */
        init = function ($scope) {
            $('[data-checkout-shipping-service]', $scope).on('change', [
                '[name=shipping_service]', // TODO: v4 use only data attr
                '[data-checkout-shipping-service-option]'
            ].join(','), handleShippingChange);
        };

    return {
        init: init
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.4.13 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.12 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js