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.5.27 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.26 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.45 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.25 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.23 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.44 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.22 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.43 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.21 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.42 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.20 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.41 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.19 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.40 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.18 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.39 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.17 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.38 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.16 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.37 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js