Sha256: f34b03e9967f67b2c0b1785e21157555660a419b833175a06478365f07b0b6db

Contents?: true

Size: 1023 Bytes

Versions: 6

Compression:

Stored size: 1023 Bytes

Contents

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

    var submitForm = function ($form, event) {
            if ($form.valid() === false) { return; }

            event.preventDefault();

            $.ajax({
                url: $form.attr('action'),
                type: $form.attr('method'),
                data: $form.serialize()
            }).done(_.partial(WORKAREA.dialog.closeClosest, $form));
        },

        formNotInDialog = function ($form) {
            return _.isEmpty($form.closest('.ui-dialog'));
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.productReviewAjaxSubmit
         */
        init = function ($scope) {
            var $form = $('[data-product-review-ajax-submit]', $scope);

            if (formNotInDialog($form)) { return; }

            $form.on('submit', _.partial(submitForm, $form));
        };

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-reviews-3.1.2 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js
workarea-reviews-3.1.1 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js
workarea-reviews-3.1.0 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js
workarea-reviews-3.0.10 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js
workarea-reviews-3.0.9 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js
workarea-reviews-3.0.8 app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js