Sha256: 96026c52e97657b5a08c60efe5da30313640cb4d88cd89948575dfd7fd5a8b25

Contents?: true

Size: 1.44 KB

Versions: 62

Compression:

Stored size: 1.44 KB

Contents

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

    var updatePreview = function (container) {
            var $selectedTaxon = $('[data-taxon-selected]', container),
                $taxonIdField = $('input[type=hidden]:first', container),
                selectedTaxonId = $selectedTaxon.data('taxonSelected');

            $taxonIdField.val(selectedTaxonId).trigger('change');
        },

        replaceTaxonomy = function (container, response) {
            $('[data-taxon-selected]', container).replaceWith(response);
            return container;
        },

        updateTaxonomy = _.flow(replaceTaxonomy, updatePreview),

        fetchTaxonomy = function (event) {
            event.preventDefault();

            $.get(event.currentTarget.href)
            .done(_.partial(updateTaxonomy, event.delegateTarget));
        },

        reset = function (event) {
            event.preventDefault();

            $.get(WORKAREA.routes.admin.selectNavigationTaxonsPath())
            .done(_.partial(updateTaxonomy, event.delegateTarget));
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.taxonSelect
         */
        init = function ($scope) {
            $('[data-taxon-select]', $scope)
            .on('click', 'a', fetchTaxonomy)
            .on('click', 'button[value=reset]', reset);
        };

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