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
002d17f1
Commit
002d17f1
authored
Dec 09, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clear button
parent
ddc42a61
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
61 deletions
+66
-61
app/assets/javascripts/droplab/droplab.js
app/assets/javascripts/droplab/droplab.js
+28
-23
app/assets/javascripts/filtered_search/dropdown_assignee.js.es6
...sets/javascripts/filtered_search/dropdown_assignee.js.es6
+2
-2
app/assets/javascripts/filtered_search/dropdown_author.js.es6
...assets/javascripts/filtered_search/dropdown_author.js.es6
+2
-2
app/assets/javascripts/filtered_search/dropdown_label.js.es6
app/assets/javascripts/filtered_search/dropdown_label.js.es6
+2
-1
app/assets/javascripts/filtered_search/dropdown_milestone.js.es6
...ets/javascripts/filtered_search/dropdown_milestone.js.es6
+2
-1
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
...vascripts/filtered_search/filtered_search_dropdown.js.es6
+11
-24
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+14
-3
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
...javascripts/filtered_search/filtered_search_tokenizer.es6
+5
-5
No files found.
app/assets/javascripts/droplab/droplab.js
View file @
002d17f1
...
@@ -51,26 +51,28 @@ Object.assign(DropDown.prototype, {
...
@@ -51,26 +51,28 @@ Object.assign(DropDown.prototype, {
return
this
.
items
;
return
this
.
items
;
},
},
clickEvent
:
function
(
e
)
{
// climb up the tree to find the LI
var
selected
=
utils
.
closest
(
e
.
target
,
'
LI
'
);
if
(
selected
)
{
e
.
preventDefault
();
this
.
hide
();
var
listEvent
=
new
CustomEvent
(
'
click.dl
'
,
{
detail
:
{
list
:
this
,
selected
:
selected
,
data
:
e
.
target
.
dataset
,
},
});
this
.
list
.
dispatchEvent
(
listEvent
);
}
},
addEvents
:
function
()
{
addEvents
:
function
()
{
var
self
=
this
;
this
.
clickWrapper
=
this
.
clickEvent
.
bind
(
this
)
;
// event delegation.
// event delegation.
this
.
list
.
addEventListener
(
'
click
'
,
function
(
e
)
{
this
.
list
.
addEventListener
(
'
click
'
,
this
.
clickWrapper
);
// climb up the tree to find the LI
var
selected
=
utils
.
closest
(
e
.
target
,
'
LI
'
);
if
(
selected
)
{
e
.
preventDefault
();
self
.
hide
();
var
listEvent
=
new
CustomEvent
(
'
click.dl
'
,
{
detail
:
{
list
:
self
,
selected
:
selected
,
data
:
e
.
target
.
dataset
,
},
});
self
.
list
.
dispatchEvent
(
listEvent
);
}
});
},
},
toggle
:
function
()
{
toggle
:
function
()
{
...
@@ -93,6 +95,7 @@ Object.assign(DropDown.prototype, {
...
@@ -93,6 +95,7 @@ Object.assign(DropDown.prototype, {
// call render manually on data;
// call render manually on data;
render
:
function
(
data
){
render
:
function
(
data
){
// debugger
// empty the list first
// empty the list first
var
sampleItem
;
var
sampleItem
;
var
newChildren
=
[];
var
newChildren
=
[];
...
@@ -134,17 +137,23 @@ Object.assign(DropDown.prototype, {
...
@@ -134,17 +137,23 @@ Object.assign(DropDown.prototype, {
},
},
show
:
function
()
{
show
:
function
()
{
// debugger
this
.
list
.
style
.
display
=
'
block
'
;
this
.
list
.
style
.
display
=
'
block
'
;
this
.
hidden
=
false
;
this
.
hidden
=
false
;
},
},
hide
:
function
()
{
hide
:
function
()
{
// debugger
this
.
list
.
style
.
display
=
'
none
'
;
this
.
list
.
style
.
display
=
'
none
'
;
this
.
hidden
=
true
;
this
.
hidden
=
true
;
},
},
destroy
:
function
()
{
destroy
:
function
()
{
this
.
hide
();
if
(
!
this
.
hidden
)
{
this
.
hide
();
}
this
.
list
.
removeEventListener
(
'
click
'
,
this
.
clickWrapper
);
}
}
});
});
...
@@ -257,10 +266,6 @@ require('./window')(function(w){
...
@@ -257,10 +266,6 @@ require('./window')(function(w){
// list = document.querySelector(list);
// list = document.querySelector(list);
this
.
hooks
.
every
(
function
(
hook
,
i
)
{
this
.
hooks
.
every
(
function
(
hook
,
i
)
{
if
(
hook
.
trigger
===
trigger
)
{
if
(
hook
.
trigger
===
trigger
)
{
// Restore initial State
hook
.
list
.
list
.
innerHTML
=
hook
.
list
.
initialState
;
hook
.
list
.
hide
();
hook
.
destroy
();
hook
.
destroy
();
this
.
hooks
.
splice
(
i
,
1
);
this
.
hooks
.
splice
(
i
,
1
);
this
.
addHook
(
trigger
,
list
,
plugins
,
config
);
this
.
addHook
(
trigger
,
list
,
plugins
,
config
);
...
...
app/assets/javascripts/filtered_search/dropdown_assignee.js.es6
View file @
002d17f1
...
@@ -32,9 +32,9 @@
...
@@ -32,9 +32,9 @@
this.dismissDropdown(!dataValueSet);
this.dismissDropdown(!dataValueSet);
}
}
renderContent() {
renderContent(forceShowList = false) {
// TODO: Pass elements instead of querySelectors
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjaxFilter], this.config);
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjaxFilter], this.config);
super.renderContent(forceShowList);
}
}
getSearchInput() {
getSearchInput() {
...
...
app/assets/javascripts/filtered_search/dropdown_author.js.es6
View file @
002d17f1
...
@@ -28,9 +28,9 @@
...
@@ -28,9 +28,9 @@
this.dismissDropdown();
this.dismissDropdown();
}
}
renderContent() {
renderContent(forceShowList) {
// TODO: Pass elements instead of querySelectors
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjaxFilter], this.config);
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjaxFilter], this.config);
super.renderContent(forceShowList);
}
}
getSearchInput() {
getSearchInput() {
...
...
app/assets/javascripts/filtered_search/dropdown_label.js.es6
View file @
002d17f1
...
@@ -30,8 +30,9 @@
...
@@ -30,8 +30,9 @@
this.dismissDropdown(!dataValueSet);
this.dismissDropdown(!dataValueSet);
}
}
renderContent() {
renderContent(
forceShowList
) {
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
super.renderContent(forceShowList);
}
}
configure() {
configure() {
...
...
app/assets/javascripts/filtered_search/dropdown_milestone.js.es6
View file @
002d17f1
...
@@ -29,8 +29,9 @@
...
@@ -29,8 +29,9 @@
this.dismissDropdown(!dataValueSet);
this.dismissDropdown(!dataValueSet);
}
}
renderContent() {
renderContent(
forceShowList = false
) {
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
super.renderContent(forceShowList);
}
}
configure() {
configure() {
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
View file @
002d17f1
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
class FilteredSearchDropdown {
class FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
constructor(droplab, dropdown, input) {
console.log('constructor');
this.droplab = droplab;
this.droplab = droplab;
this.hookId = 'filtered-search';
this.hookId = 'filtered-search';
this.input = input;
this.input = input;
...
@@ -54,8 +55,10 @@
...
@@ -54,8 +55,10 @@
// Overridden by dropdown sub class
// Overridden by dropdown sub class
}
}
renderContent() {
renderContent(forceShowList = false) {
// Overriden by dropdown sub class
if (forceShowList && this.getCurrentHook().list.hidden) {
this.getCurrentHook().list.show();
}
}
}
setAsDropdown() {
setAsDropdown() {
...
@@ -77,7 +80,6 @@
...
@@ -77,7 +80,6 @@
}
}
dismissDropdown() {
dismissDropdown() {
this.getCurrentHook().list.hide();
this.input.focus();
this.input.focus();
}
}
...
@@ -87,31 +89,16 @@
...
@@ -87,31 +89,16 @@
this.input.dispatchEvent(new Event('input'));
this.input.dispatchEvent(new Event('input'));
}
}
render(forceRenderContent) {
render(forceRenderContent
= false, forceShowList = false
) {
this.setAsDropdown();
this.setAsDropdown();
const firstTimeInitialized = this.getCurrentHook() === undefined;
if (firstTimeInitialized || forceRenderContent) {
this.renderContent();
} else if(this.getCurrentHook().list.list.id !== this.listId) {
this.renderContent();
}
}
resetFilters() {
const currentHook = this.getCurrentHook();
const currentHook = this.getCurrentHook();
const firstTimeInitialized = currentHook === undefined;
if (currentHook) {
if (firstTimeInitialized || forceRenderContent) {
const list = currentHook.list;
this.renderContent(forceShowList);
} else if(currentHook.list.list.id !== this.listId) {
if (list.data) {
this.renderContent(forceShowList);
const data = list.data.map((item) => {
item.droplab_hidden = false;
});
list.render(data);
}
}
}
}
}
...
...
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
002d17f1
...
@@ -150,6 +150,7 @@
...
@@ -150,6 +150,7 @@
const element = this.mapping[key].element;
const element = this.mapping[key].element;
const filterIconPadding = 27;
const filterIconPadding = 27;
const dropdownOffset = gl.text.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
const dropdownOffset = gl.text.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
let forceShowList = false;
if (!this.mapping[key].reference) {
if (!this.mapping[key].reference) {
this.mapping[key].reference = new gl[glClass](this.droplab, element, this.filteredSearchInput);
this.mapping[key].reference = new gl[glClass](this.droplab, element, this.filteredSearchInput);
...
@@ -159,8 +160,13 @@
...
@@ -159,8 +160,13 @@
this.mapping[key].reference.configure();
this.mapping[key].reference.configure();
}
}
if (this.currentDropdown === 'hint') {
// Clicked from hint dropdown
forceShowList = true;
}
this.mapping[key].reference.setOffset(dropdownOffset);
this.mapping[key].reference.setOffset(dropdownOffset);
this.mapping[key].reference.render(firstLoad);
this.mapping[key].reference.render(firstLoad
, forceShowList
);
this.currentDropdown = key;
this.currentDropdown = key;
}
}
...
@@ -207,6 +213,12 @@
...
@@ -207,6 +213,12 @@
}
}
}
}
// dismissCurrentDropdown() {
// if (this.currentDropdown === 'hint') {
// this.mapping['hint'].hide();
// }
// }
bindEvents() {
bindEvents() {
this.filteredSearchInput.addEventListener('input', this.setDropdown.bind(this));
this.filteredSearchInput.addEventListener('input', this.setDropdown.bind(this));
this.filteredSearchInput.addEventListener('input', toggleClearSearchButton);
this.filteredSearchInput.addEventListener('input', toggleClearSearchButton);
...
@@ -220,8 +232,7 @@
...
@@ -220,8 +232,7 @@
this.filteredSearchInput.value = '';
this.filteredSearchInput.value = '';
this.clearSearchButton.classList.add('hidden');
this.clearSearchButton.classList.add('hidden');
dropdownHint.resetFilters();
this.setDropdown();
this.loadDropdown('hint');
}
}
checkForEnter(e) {
checkForEnter(e) {
...
...
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
View file @
002d17f1
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
class FilteredSearchTokenizer {
class FilteredSearchTokenizer {
// TODO: Remove when going to pro
// TODO: Remove when going to pro
static printTokens(tokens, searchToken, lastToken) {
static printTokens(tokens, searchToken, lastToken) {
//
console.log('tokens:');
console.log('tokens:');
//
tokens.forEach(token => console.log(token));
tokens.forEach(token => console.log(token));
//
console.log(`search: ${searchToken}`);
console.log(`search: ${searchToken}`);
//
console.log('last token:');
console.log('last token:');
//
console.log(lastToken);
console.log(lastToken);
}
}
static parseToken(input) {
static parseToken(input) {
...
...
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