Sha256: d9efbcc1be9261f07116d593451f7178493e96ad0fec401a1d82f499618e13e3

Contents?: true

Size: 789 Bytes

Versions: 75

Compression:

Stored size: 789 Bytes

Contents

/*global Bloodhound */
import Bloodhound from 'typeahead.js/dist/bloodhound.js'

Blacklight.onLoad(function() {
  'use strict';

  $('[data-autocomplete-enabled="true"]').each(function() {
    var $el = $(this);
    if($el.hasClass('tt-hint')) {
      return;
    }
    var suggestUrl = $el.data().autocompletePath;

    var terms = new Bloodhound({
      datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      remote: {
        url: suggestUrl + '?q=%QUERY',
        wildcard: '%QUERY'
      }
    });

    terms.initialize();

    $el.typeahead({
      hint: true,
      highlight: true,
      minLength: 2
    },
    {
      name: 'terms',
      displayKey: 'term',
      source: terms.ttAdapter()
    });
  });
});

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/javascript/blacklight/autocomplete.js
blacklight-7.39.0 app/javascript/blacklight/autocomplete.js
blacklight-7.38.0 app/javascript/blacklight/autocomplete.js
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/javascript/blacklight/autocomplete.js
blacklight-7.37.0 app/javascript/blacklight/autocomplete.js
blacklight-7.36.2 app/javascript/blacklight/autocomplete.js
blacklight-7.36.1 app/javascript/blacklight/autocomplete.js
blacklight-7.36.0 app/javascript/blacklight/autocomplete.js
blacklight-7.35.0 app/javascript/blacklight/autocomplete.js
blacklight-7.34.0 app/javascript/blacklight/autocomplete.js
blacklight-7.33.1 app/javascript/blacklight/autocomplete.js
blacklight-7.33.0 app/javascript/blacklight/autocomplete.js
blacklight-7.32.0 app/javascript/blacklight/autocomplete.js
blacklight-7.31.0 app/javascript/blacklight/autocomplete.js
blacklight-7.30.0 app/javascript/blacklight/autocomplete.js
blacklight-7.29.0 app/javascript/blacklight/autocomplete.js
blacklight-7.28.0 app/javascript/blacklight/autocomplete.js
blacklight-7.27.1 app/javascript/blacklight/autocomplete.js
blacklight-7.27.0 app/javascript/blacklight/autocomplete.js
blacklight-7.26.1 app/javascript/blacklight/autocomplete.js