Sha256: fb18384aff2d8903dfce1b95ecc4206f0f37c40000e0367e910c05742f7fb14a

Contents?: true

Size: 1.46 KB

Versions: 62

Compression:

Stored size: 1.46 KB

Contents

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

    var toggleElements = function ($radio, positive) {
            var $container = $radio.closest('[data-toggle-button]'),
                $elements = $('.toggle-button__more', $container),
                reverseSwitch = positive ? 'negative' : 'positive',
                selector = '[data-toggle-button-' + reverseSwitch + '-element]';

            $elements.removeClass('toggle-button__more--active');

            $elements
                .not(selector)
                .addClass('toggle-button__more--active');
        },

        determineState = function ($radio) {
            if ($radio.is('.toggle-button__input--positive')) {
                toggleElements($radio, true);
            } else {
                toggleElements($radio, false);
            }
        },

        getCheckedRadio = function (event) {
            determineState($(event.currentTarget));
        },

        getInitialState = function (index, button) {
            determineState($('.toggle-button__input:checked', button));
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.toggleButtons
         */
        init = function ($scope) {
            $('[data-toggle-button]', $scope)
            .on('change', '.toggle-button__input', getCheckedRadio)
            .each(getInitialState);
        };

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

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.4.27 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.4 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.26 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.3 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.25 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.2 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.24 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.1 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.23 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.22 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.0 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.21 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.5.0.beta.1 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.20 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.19 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.18 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.17 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.16 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.15 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js
workarea-admin-3.4.14 app/assets/javascripts/workarea/admin/modules/toggle_buttons.js