Sha256: d7be4cf0b1b6a83544c12bd94954c37c223b318845f13bcb1dda53900fb6c0aa

Contents?: true

Size: 1.39 KB

Versions: 62

Compression:

Stored size: 1.39 KB

Contents

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

    var randomizeID = function (event) {
            var form = event.delegateTarget,
                $target = $('[name="product[id]"]', form),
                hash = Math.random().toString(32).slice(2).toUpperCase();

            $target.val(hash);
        },

        copyOriginalID = function (event) {
            var form = event.delegateTarget,
                id = $('[name=source_product_id]', form).val(),
                $target = $('[name="product[id]"]', form);

            $target.val(id + '-copy');
        },

        setProductId = function(event) {
            var form = event.delegateTarget,
                $target = $('[name=original_id]', form),
                $containers = $('.property.hidden', form);

            $target.val(event.target.value);
            $containers.removeClass('hidden');
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.productCopyIds
         */
        init = function ($scope) {
            $('[data-product-copy-ids]', $scope)
            .on('change', 'select[name=source_product_id]', setProductId)
            .on('click', 'button[value=copy_original]', copyOriginalID)
            .on('click', 'button[value=randomize]', randomizeID);
        };

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

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.26 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.45 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.25 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.23 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.44 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.22 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.43 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.21 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.42 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/product_copy_ids.js