From 2dc1111619d8b673a83d3da640984e4efb9116eb Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 8 May 2017 13:57:58 -0500 Subject: remove bind polyfill from gl_dropdown.js --- app/assets/javascripts/gl_dropdown.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'app/assets/javascripts/gl_dropdown.js') diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 0c9eb84f0eb..7ebc0501e84 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -2,7 +2,6 @@ /* global fuzzaldrinPlus */ var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote, - bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i += 1) { if (i in this && this[i] === item) return i; } return -1; }; GitLabDropdownFilter = (function() { @@ -213,10 +212,10 @@ GitLabDropdown = (function() { var searchFields, selector, self; this.el = el1; this.options = options; - this.updateLabel = bind(this.updateLabel, this); - this.hidden = bind(this.hidden, this); - this.opened = bind(this.opened, this); - this.shouldPropagate = bind(this.shouldPropagate, this); + this.updateLabel = this.updateLabel.bind(this); + this.hidden = this.hidden.bind(this); + this.opened = this.opened.bind(this); + this.shouldPropagate = this.shouldPropagate.bind(this); self = this; selector = $(this.el).data("target"); this.dropdown = selector != null ? $(selector) : $(this.el).parent(); -- cgit v1.2.1 From f6d214e17e134e0cb868eb9cff021d8cfc1e88bf Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 8 May 2017 14:25:12 -0500 Subject: remove unnecessary indexOf polyfills --- app/assets/javascripts/gl_dropdown.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts/gl_dropdown.js') diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 7ebc0501e84..2eee989bffe 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -1,8 +1,7 @@ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */ /* global fuzzaldrinPlus */ -var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote, - indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i += 1) { if (i in this && this[i] === item) return i; } return -1; }; +var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote; GitLabDropdownFilter = (function() { var ARROW_KEY_CODES, BLUR_KEYCODES, HAS_VALUE_CLASS; @@ -626,8 +625,8 @@ GitLabDropdown = (function() { }; GitLabDropdown.prototype.highlightTextMatches = function(text, term) { - var occurrences; - occurrences = fuzzaldrinPlus.match(text, term); + const occurrences = fuzzaldrinPlus.match(text, term); + const indexOf = [].indexOf; return text.split('').map(function(character, i) { if (indexOf.call(occurrences, i) !== -1) { return "" + character + ""; -- cgit v1.2.1 From 6a547779ff441becb8662e8ee84507775b0a2ed6 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 9 May 2017 07:57:13 +0100 Subject: Fixed search terms not highlight Closes #31997 --- app/assets/javascripts/gl_dropdown.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/gl_dropdown.js') diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 2eee989bffe..9666eeeb5ad 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -608,7 +608,12 @@ GitLabDropdown = (function() { var link = document.createElement('a'); link.href = url; - link.innerHTML = text; + + if (this.highlight) { + link.innerHTML = text; + } else { + link.textContent = text; + } if (selected) { link.className = 'is-active'; -- cgit v1.2.1 From 269c0fe00715cf2ebf6e7e9f9f8fb6feef5d610d Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 10 May 2017 16:17:31 +0000 Subject: Replace old isObject for underscore methods --- app/assets/javascripts/gl_dropdown.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/assets/javascripts/gl_dropdown.js') diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 9666eeeb5ad..24c423dd01e 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -1,5 +1,6 @@ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */ /* global fuzzaldrinPlus */ +import { isObject } from './lib/utils/type_utility'; var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote; @@ -93,7 +94,7 @@ GitLabDropdownFilter = (function() { // { prop: 'def' } // ] // } - if (gl.utils.isObject(data)) { + if (isObject(data)) { results = {}; for (key in data) { group = data[key]; @@ -396,7 +397,7 @@ GitLabDropdown = (function() { html = [this.noResults()]; } else { // Handle array groups - if (gl.utils.isObject(data)) { + if (isObject(data)) { html = []; for (name in data) { groupData = data[name]; -- cgit v1.2.1