Sha256: e8fdf05ebaad6995db16048a665cf26cc284e97fe253eda45a069225a6fbb398
Contents?: true
Size: 1.5 KB
Versions: 62
Compression:
Stored size: 1.5 KB
Contents
/** * @namespace WORKAREA.autocompleteFields */ WORKAREA.registerModule('autocompleteFields', (function () { 'use strict'; var addPlaceholder = function ($field) { var placeholder = $field.prop('placeholder') || I18n.t('workarea.admin.js.autocomplete_fields.placeholder'); $field.prop('placeholder', placeholder); }, getSource = function (url) { return function (request, response) { $.getJSON(url, { q: request.term }, function (data) { response(data.results); }); }; }, initAutocomplete = function ($field) { var url = $field.data('autocompleteField'); return $field.autocomplete({ minLength: 2, source: getSource(url), position: { my: 'center top', at: 'center bottom', collision: 'none' } }); }, defineInjectionPoint = function (index, field) { $(field).parent().addClass('ui-front'); return $(field); }, setup = _.flow(defineInjectionPoint, initAutocomplete, addPlaceholder), /** * @method * @name init * @memberof WORKAREA.autocompleteFields */ init = function ($scope) { $('[data-autocomplete-field]', $scope).each(setup); }; return { init: init }; }()));
Version data entries
62 entries across 62 versions & 1 rubygems