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.27 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.26 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.45 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.25 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.23 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.44 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.22 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.43 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.21 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.42 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.20 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.41 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.19 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.40 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.18 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.39 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.17 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.38 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.5.16 app/assets/javascripts/workarea/storefront/modules/optional_fields.js
workarea-storefront-3.4.37 app/assets/javascripts/workarea/storefront/modules/optional_fields.js