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.27 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.4 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.26 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.3 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.25 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.2 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.24 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.1 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.23 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.22 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.0 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.21 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.5.0.beta.1 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.20 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.19 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.18 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.17 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.16 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.15 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js
workarea-storefront-3.4.14 app/assets/javascripts/workarea/storefront/modules/checkout_shipping_services.js