Sha256: 24bb2288f38710290f6065b0bbd3d1736675d5f1e1241dbb139818409a517629

Contents?: true

Size: 1.33 KB

Versions: 62

Compression:

Stored size: 1.33 KB

Contents

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

    var prompt = JST['workarea/storefront/templates/optional_field_prompt'],

        reveal = function ($container, $prompt, event) {
            event.preventDefault();
            event.stopPropagation();
            $prompt.remove();
            $container.removeClass('hidden-if-js-enabled');
            $container.find(':focusable').first().trigger('focus');
        },

        inject = function ($prompt, $container) {
            $container.before($prompt);
        },

        build = function ($container) {
            var $prompt = $(prompt({
                text: $container.data('optionalField')
            }));

            $prompt.on('click', _.partial(reveal, $container, $prompt));
            $container.on('change', _.partial(reveal, $container, $prompt));

            return $prompt;
        },

        setup = function (index, container) {
            var $container = $(container);
            inject(build($container), $container);
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.optionalFields
         */
        init = function ($scope) {
            $('[data-optional-field]', $scope).each(setup);
        };

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

Version data entries

62 entries across 62 versions & 1 rubygems

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