Sha256: 94e690e7180bc28ab7d5cb8efde2dae247bbf925692976119bba1280bab3509e

Contents?: true

Size: 1.15 KB

Versions: 10

Compression:

Stored size: 1.15 KB

Contents

//= require accessible-autocomplete/dist/accessible-autocomplete.min.js

window.GOVUK = window.GOVUK || {};
window.GOVUK.Modules = window.GOVUK.Modules || {};

(function (Modules) {
  "use strict";

  Modules.AccessibleAutocomplete = function () {
    this.start = function ($element) {
      var $selectElem = $element.find('select');

      var configOptions = {
        selectElement: document.getElementById($selectElem.attr('id')),
        showAllValues: true,
        confirmOnBlur: false
      };

      if ($selectElem.data('track-category') !== undefined && $selectElem.data('track-action') !== undefined) {
        configOptions.onConfirm = function(val) {
          track($selectElem.data('track-category'), $selectElem.data('track-action'), val, $selectElem.data('track-options'));
        };
      }

      new accessibleAutocomplete.enhanceSelectElement(configOptions);
    };

    function track (category, action, label, options) {
      if (GOVUK.analytics && GOVUK.analytics.trackEvent) {
        options = options || {};
        options.label = label;

        GOVUK.analytics.trackEvent(category, action, options);
      }
    }
  };
})(window.GOVUK.Modules);

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
govuk_publishing_components-13.0.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.21.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.20.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.19.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.18.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.17.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.16.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.15.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.14.1 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js
govuk_publishing_components-12.14.0 app/assets/javascripts/govuk_publishing_components/components/accessible-autocomplete.js