Sha256: 02c14d13de7ca8bf9e8396fdcda877df5a3b5d2541c1b3816dbd4625c85f9c98

Contents?: true

Size: 1.7 KB

Versions: 52

Compression:

Stored size: 1.7 KB

Contents

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

    var getConfig = function ($select) {
            var $option = $('option:selected', $select);

            return _.merge(WORKAREA.config.remoteSelects, {
                ajax: {
                    url: $option.data('newNavigationTaxonEndpoint')
                },
                placeholder: '',
                allowClear: true
              });
        },

        destroyRemoteSelect = function ($select) {
            $select.val(null).trigger('change').select2('destroy');
        },

        createRemoteSelect = function (event) {
            var $typeSelect = $(event.currentTarget),
                $idSelect = $('[name=navigable_id]', event.delegateTarget),
                settings = getConfig($typeSelect),
                selected = $typeSelect.data('newNavigationTaxon');

            if ($idSelect.is('.select2-hidden-accessible') && _.isUndefined(selected)) {
                destroyRemoteSelect($idSelect);
            }

            $idSelect.select2(settings).val(selected);
        },

        changeRemoteSelect = function (index, element) {
            var $navigationLink = $(element);

            $navigationLink
            .on('change', '[name=navigable_type]', createRemoteSelect)
                .find('[name=navigable_type]')
                .trigger('change');
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.newNavigationTaxons
         */
        init = function ($scope) {
            $('[data-new-navigation-taxon]', $scope)
            .each(changeRemoteSelect);
        };

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

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.15 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.36 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.14 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.35 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.13 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.34 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.12 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.4.33 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.11 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js
workarea-admin-3.5.10 app/assets/javascripts/workarea/admin/modules/new_navigation_taxons.js