Sha256: eb3118a6608ecd3ac1aedbe3403fbc1d18a95b1816cbe4ea78a994bfd72bb3c3

Contents?: true

Size: 1.72 KB

Versions: 62

Compression:

Stored size: 1.72 KB

Contents

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

    var findVariantPositions = function (event) {
            var result = {},
                $variants = $('[data-sort-variant-id]', event.target);

            $variants.each(function (index, menu) {
                var id = $(menu).data('sortVariantId');

                if (id) {
                    result['positions[' + id + ']'] = index;
                }
            });

            return result;
        },

        saveSort = function (event) {
            var productId = $(event.target)
                                .closest('[data-sort-variant]')
                                .data('productId'),

                url = WORKAREA.routes.admin.moveCatalogProductVariantsPath(
                    { catalog_product_id: productId }
                );

            $.post(url, findVariantPositions(event));
        },

        setCellWidth = function (event, ui) {
            $('td', ui.item).each(function (index, cell) {
                $(cell).width($(cell).width());
            });

            return ui;
        },

        resetCellWidth = function (event, ui) {
            $('td', ui.item).each(function (index, cell) {
                $(cell).width('auto');
            });

            return ui;
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.sortVariants
         */
        init = function ($scope) {
            $('[data-sort-variant]', $scope).sortable({
                axis: 'y',
                update: saveSort,
                helper: setCellWidth,
                stop: resetCellWidth
            });
        };

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

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.15 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.36 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.14 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.35 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.13 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.34 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.12 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.33 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.11 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.10 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.32 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.9 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.31 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.8 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.30 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.7 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.29 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.6 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.4.28 app/assets/javascripts/workarea/admin/modules/sort_variants.js
workarea-admin-3.5.5 app/assets/javascripts/workarea/admin/modules/sort_variants.js