Commit 5cc79c8f authored by Phil Hughes's avatar Phil Hughes

Merge branch 'autocomplete' into 'master'

Remove var from compare_autocomplete.js

Closes #36267

See merge request gitlab-org/gitlab!20107
parents b3196928 c6526f45
/* eslint-disable func-names, one-var, no-var, no-else-return */ /* eslint-disable func-names, no-else-return */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from './locale'; import { __ } from './locale';
...@@ -8,9 +8,8 @@ import { capitalizeFirstCharacter } from './lib/utils/text_utility'; ...@@ -8,9 +8,8 @@ import { capitalizeFirstCharacter } from './lib/utils/text_utility';
export default function initCompareAutocomplete(limitTo = null, clickHandler = () => {}) { export default function initCompareAutocomplete(limitTo = null, clickHandler = () => {}) {
$('.js-compare-dropdown').each(function() { $('.js-compare-dropdown').each(function() {
var $dropdown, selected; const $dropdown = $(this);
$dropdown = $(this); const selected = $dropdown.data('selected');
selected = $dropdown.data('selected');
const $dropdownContainer = $dropdown.closest('.dropdown'); const $dropdownContainer = $dropdown.closest('.dropdown');
const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer); const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
...@@ -44,17 +43,16 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = ( ...@@ -44,17 +43,16 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
fieldName: $dropdown.data('fieldName'), fieldName: $dropdown.data('fieldName'),
filterInput: 'input[type="search"]', filterInput: 'input[type="search"]',
renderRow(ref) { renderRow(ref) {
var link; const link = $('<a />')
.attr('href', '#')
.addClass(ref === selected ? 'is-active' : '')
.text(ref)
.attr('data-ref', ref);
if (ref.header != null) { if (ref.header != null) {
return $('<li />') return $('<li />')
.addClass('dropdown-header') .addClass('dropdown-header')
.text(ref.header); .text(ref.header);
} else { } else {
link = $('<a />')
.attr('href', '#')
.addClass(ref === selected ? 'is-active' : '')
.text(ref)
.attr('data-ref', ref);
return $('<li />').append(link); return $('<li />').append(link);
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment