Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0ce24455
Commit
0ce24455
authored
Dec 13, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix eslint
parent
4786a978
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
81 deletions
+37
-81
app/assets/javascripts/droplab/droplab.js
app/assets/javascripts/droplab/droplab.js
+1
-1
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
+4
-14
app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
...sets/javascripts/filtered_search/dropdown_non_user.js.es6
+6
-40
app/assets/javascripts/filtered_search/dropdown_user.js.es6
app/assets/javascripts/filtered_search/dropdown_user.js.es6
+3
-0
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
...vascripts/filtered_search/filtered_search_dropdown.js.es6
+1
-12
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
...s/filtered_search/filtered_search_dropdown_manager.js.es6
+2
-0
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+2
-0
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
...ascripts/filtered_search/filtered_search_tokenizer.js.es6
+18
-14
No files found.
app/assets/javascripts/droplab/droplab.js
View file @
0ce24455
/* 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
'
;
...
...
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
View file @
0ce24455
/*= require filtered_search/filtered_search_dropdown */
/* global droplabFilter */
(() => {
const dropdownData = [{
icon: 'fa-pencil',
...
...
@@ -24,7 +27,7 @@
this.config = {
droplabFilter: {
template: 'hint',
filterFunction:
thi
s.filterMethod,
filterFunction:
gl.DropdownUtil
s.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();
}
...
...
app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
View file @
0ce24455
/*= 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}${
thi
s.getEscapedText(title)}`;
return `${this.symbol}${
gl.DropdownUtil
s.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);
...
...
app/assets/javascripts/filtered_search/dropdown_user.js.es6
View file @
0ce24455
/*= require filtered_search/filtered_search_dropdown */
/* global droplabAjaxFilter */
(() => {
class DropdownUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
View file @
0ce24455
...
...
@@ -28,7 +28,7 @@
itemClicked(e, getValueFunction) {
const { selected } = e.detail;
const dataValueSet =
thi
s.setDataValueIfSelected(selected);
const dataValueSet =
gl.DropdownUtil
s.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();
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
View file @
0ce24455
/* global DropLab */
(() => {
class FilteredSearchDropdownManager {
constructor() {
...
...
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
0ce24455
/* global Turbolinks */
(() => {
class FilteredSearchManager {
constructor() {
...
...
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
View file @
0ce24455
...
...
@@ -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 && i
nput[i] === d
oubleQuote) ||
(lastQuotation === singleQuote && i
nput[i] === s
ingleQuote)) {
if ((lastQuotation === doubleQuote && i
sD
oubleQuote) ||
(lastQuotation === singleQuote && i
sS
ingleQuote)) {
completeQuotation = true;
}
// Save the first quotation
if ((i
nput[i] === d
oubleQuote && lastQuotation === '') ||
(i
nput[i] === s
ingleQuote && lastQuotation === '')) {
if ((i
sD
oubleQuote && lastQuotation === '') ||
(i
sS
ingleQuote && 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) {
le
t tokens = [];
cons
t 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();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment