Sha256: a6d2d9d2006e2bac78b97a65d12c58bb2fbab4ac7da92b836e18c66c488a111f

Contents?: true

Size: 1.66 KB

Versions: 33

Compression:

Stored size: 1.66 KB

Contents

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

    var getSource = function (request, response) {
            $.getJSON(WORKAREA.routes.admin.jumpToPath(), { q: request.term }, function (data) {
                response(data.results);
            });
        },

        openSelected = function (event, ui) {
            var $adminToolbar = $(event.target).closest('.admin-toolbar');

            if (_.isEmpty($adminToolbar)) {
                Turbolinks.visit(ui.item.url);
            } else {
                window.top.location.href = ui.item.url;
            }
        },

        getConfig = function () {
            return _.assign({}, WORKAREA.config.categorizedAutocompleteFields.uiOptions, {
                source: getSource,
                select: openSelected,
                position: {
                    my: 'center top',
                    at: 'center bottom',
                    collision: 'none'
                }
            });
        },

        initAutocomplete = function ($field) {
            $field.categorizedAutocomplete(getConfig());
        },

        defineInjectionPoint = function (index, field) {
            $(field).parent().addClass('ui-front');
            return $(field);
        },

        setup = _.flow(defineInjectionPoint, initAutocomplete),

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

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

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.26 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.45 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.25 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.23 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.44 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.22 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.43 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.21 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.42 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/categorized_autocomplete_fields.js