summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2016-12-13 21:55:25 -0600
committerClement Ho <ClemMakesApps@gmail.com>2017-01-09 16:01:25 -0600
commit0ce2445512529711bcf4f5f1354647cd8c0ed1e6 (patch)
tree8f840546038f38274523eb174291eb03d3ecfacd /app/assets
parent4786a9780337839844d5839fefda51430e13685e (diff)
downloadgitlab-ce-0ce2445512529711bcf4f5f1354647cd8c0ed1e6.tar.gz
Fix eslint
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/droplab/droplab.js2
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_hint.js.es618
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_non_user.js.es646
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_user.js.es63
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es613
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es62
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_manager.js.es62
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es632
8 files changed, 37 insertions, 81 deletions
diff --git a/app/assets/javascripts/droplab/droplab.js b/app/assets/javascripts/droplab/droplab.js
index 94236153e41..ed545ec8748 100644
--- a/app/assets/javascripts/droplab/droplab.js
+++ b/app/assets/javascripts/droplab/droplab.js
@@ -1,3 +1,4 @@
+/* eslint-disable */
// Determine where to place this
if (typeof Object.assign != 'function') {
Object.assign = function (target, varArgs) { // .length of function is 2
@@ -24,7 +25,6 @@ if (typeof Object.assign != 'function') {
};
}
-/* eslint-disable */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.droplab = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var DATA_TRIGGER = 'data-dropdown-trigger';
var DATA_DROPDOWN = 'data-dropdown';
diff --git a/app/assets/javascripts/filtered_search/dropdown_hint.js.es6 b/app/assets/javascripts/filtered_search/dropdown_hint.js.es6
index b920b17d915..34079b25846 100644
--- a/app/assets/javascripts/filtered_search/dropdown_hint.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_hint.js.es6
@@ -1,4 +1,7 @@
/*= require filtered_search/filtered_search_dropdown */
+
+/* global droplabFilter */
+
(() => {
const dropdownData = [{
icon: 'fa-pencil',
@@ -24,7 +27,7 @@
this.config = {
droplabFilter: {
template: 'hint',
- filterFunction: this.filterMethod,
+ filterFunction: gl.DropdownUtils.filterMethod,
},
};
}
@@ -59,19 +62,6 @@
this.droplab.setData(this.hookId, dropdownData);
}
- filterMethod(item, query) {
- const updatedItem = item;
- const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
-
- if (value === '') {
- updatedItem.droplab_hidden = false;
- } else {
- updatedItem.droplab_hidden = updatedItem.hint.indexOf(value) === -1;
- }
-
- return updatedItem;
- }
-
init() {
this.droplab.addHook(this.input, this.dropdown, [droplabFilter], this.config).init();
}
diff --git a/app/assets/javascripts/filtered_search/dropdown_non_user.js.es6 b/app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
index 95133db4c04..54090375c5c 100644
--- a/app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
@@ -1,4 +1,8 @@
/*= require filtered_search/filtered_search_dropdown */
+
+/* global droplabAjax */
+/* global droplabFilter */
+
(() => {
class DropdownNonUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, endpoint, symbol) {
@@ -11,7 +15,7 @@
loadingTemplate: this.loadingTemplate,
},
droplabFilter: {
- filterFunction: this.filterWithSymbol.bind(this, this.symbol),
+ filterFunction: gl.DropdownUtils.filterWithSymbol.bind(null, this.symbol),
},
};
}
@@ -19,48 +23,10 @@
itemClicked(e) {
super.itemClicked(e, (selected) => {
const title = selected.querySelector('.js-data-value').innerText.trim();
- return `${this.symbol}${this.getEscapedText(title)}`;
+ return `${this.symbol}${gl.DropdownUtils.getEscapedText(title)}`;
});
}
- getEscapedText(text) {
- let escapedText = text;
- const hasSpace = text.indexOf(' ') !== -1;
- const hasDoubleQuote = text.indexOf('"') !== -1;
-
- // Encapsulate value with quotes if it has spaces
- // Known side effect: values's with both single and double quotes
- // won't escape properly
- if (hasSpace) {
- if (hasDoubleQuote) {
- escapedText = `'${text}'`;
- } else {
- // Encapsulate singleQuotes or if it hasSpace
- escapedText = `"${text}"`;
- }
- }
-
- return escapedText;
- }
-
- filterWithSymbol(filterSymbol, item, query) {
- const updatedItem = item;
- const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
- const valueWithoutColon = value.slice(1).toLowerCase();
- const prefix = valueWithoutColon[0];
- const valueWithoutPrefix = valueWithoutColon.slice(1);
-
- const title = updatedItem.title.toLowerCase();
-
- // Eg. filterSymbol = ~ for labels
- const matchWithoutPrefix =
- prefix === filterSymbol && title.indexOf(valueWithoutPrefix) !== -1;
- const match = title.indexOf(valueWithoutColon) !== -1;
-
- updatedItem.droplab_hidden = !match && !matchWithoutPrefix;
- return updatedItem;
- }
-
renderContent(forceShowList = false) {
this.droplab
.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
diff --git a/app/assets/javascripts/filtered_search/dropdown_user.js.es6 b/app/assets/javascripts/filtered_search/dropdown_user.js.es6
index 2ee46559e63..7a566907312 100644
--- a/app/assets/javascripts/filtered_search/dropdown_user.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_user.js.es6
@@ -1,4 +1,7 @@
/*= require filtered_search/filtered_search_dropdown */
+
+/* global droplabAjaxFilter */
+
(() => {
class DropdownUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
index 7ddfdca10fa..6c66a3b0613 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
@@ -28,7 +28,7 @@
itemClicked(e, getValueFunction) {
const { selected } = e.detail;
- const dataValueSet = this.setDataValueIfSelected(selected);
+ const dataValueSet = gl.DropdownUtils.setDataValueIfSelected(selected);
if (!dataValueSet) {
const value = getValueFunction(selected);
@@ -46,17 +46,6 @@
this.dropdown.style.left = `${offset}px`;
}
- setDataValueIfSelected(selected) {
- const dataValue = selected.getAttribute('data-value');
-
- if (dataValue) {
- gl.FilteredSearchDropdownManager.addWordToInput(dataValue);
- }
-
- // Return boolean based on whether it was set
- return dataValue !== null;
- }
-
renderContent(forceShowList = false) {
if (forceShowList && this.getCurrentHook().list.hidden) {
this.getCurrentHook().list.show();
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
index 7864ebf7aa1..ac71b5e4434 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
@@ -1,3 +1,5 @@
+/* global DropLab */
+
(() => {
class FilteredSearchDropdownManager {
constructor() {
diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
index 96131a673ef..e5b37f1e691 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
@@ -1,3 +1,5 @@
+/* global Turbolinks */
+
(() => {
class FilteredSearchManager {
constructor() {
diff --git a/app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
index 0507f7bbc48..57c0e8fc359 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
@@ -16,7 +16,7 @@
tokenKey,
tokenValue,
tokenSymbol,
- }
+ };
}
static getLastTokenObject(input) {
@@ -29,7 +29,7 @@
return {
key,
value,
- }
+ };
}
static getLastToken(input) {
@@ -40,19 +40,19 @@
const doubleQuote = '"';
const singleQuote = '\'';
- while(!completeToken && i >= 0) {
+ while (!completeToken && i >= 0) {
const isDoubleQuote = input[i] === doubleQuote;
const isSingleQuote = input[i] === singleQuote;
// If the second quotation is found
- if ((lastQuotation === doubleQuote && input[i] === doubleQuote) ||
- (lastQuotation === singleQuote && input[i] === singleQuote)) {
+ if ((lastQuotation === doubleQuote && isDoubleQuote) ||
+ (lastQuotation === singleQuote && isSingleQuote)) {
completeQuotation = true;
}
// Save the first quotation
- if ((input[i] === doubleQuote && lastQuotation === '') ||
- (input[i] === singleQuote && lastQuotation === '')) {
+ if ((isDoubleQuote && lastQuotation === '') ||
+ (isSingleQuote && lastQuotation === '')) {
lastQuotation = input[i];
completeQuotation = false;
}
@@ -60,7 +60,7 @@
if (completeQuotation && input[i] === ' ') {
completeToken = true;
} else {
- i--;
+ i -= 1;
}
}
@@ -69,7 +69,7 @@
}
static processTokens(input) {
- let tokens = [];
+ const tokens = [];
let searchToken = '';
let lastToken = '';
@@ -118,16 +118,20 @@
const singleQuoteExist = singleQuoteIndex !== -1;
const doubleQuoteExistOnly = doubleQuoteExist && !singleQuoteExist;
- const doubleQuoteIsBeforeSingleQuote = doubleQuoteExist && singleQuoteExist && doubleQuoteIndex < singleQuoteIndex;
+ const doubleQuoteIsBeforeSingleQuote =
+ doubleQuoteExist && singleQuoteExist && doubleQuoteIndex < singleQuoteIndex;
const singleQuoteExistOnly = singleQuoteExist && !doubleQuoteExist;
- const singleQuoteIsBeforeDoubleQuote = doubleQuoteExist && singleQuoteExist && singleQuoteIndex < doubleQuoteIndex;
+ const singleQuoteIsBeforeDoubleQuote =
+ doubleQuoteExist && singleQuoteExist && singleQuoteIndex < doubleQuoteIndex;
- if ((doubleQuoteExistOnly || doubleQuoteIsBeforeSingleQuote) && doubleQuoteOccurrences % 2 !== 0) {
+ if ((doubleQuoteExistOnly || doubleQuoteIsBeforeSingleQuote)
+ && doubleQuoteOccurrences % 2 !== 0) {
// " is found and is in front of ' (if any)
lastQuotation = '"';
incompleteToken = true;
- } else if ((singleQuoteExistOnly || singleQuoteIsBeforeDoubleQuote) && singleQuoteOccurrences % 2 !== 0) {
+ } else if ((singleQuoteExistOnly || singleQuoteIsBeforeDoubleQuote)
+ && singleQuoteOccurrences % 2 !== 0) {
// ' is found and is in front of " (if any)
lastQuotation = '\'';
incompleteToken = true;
@@ -137,7 +141,7 @@
tokens.push({
key: keyMatch.key,
value: tokenValue,
- wildcard: symbolMatch ? false : true,
+ wildcard: !symbolMatch,
});
lastToken = tokens.last();