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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
f76066b9
Commit
f76066b9
authored
Mar 31, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue based on feedback
parent
a103fcb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
21 deletions
+26
-21
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+26
-21
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
f76066b9
class
GitLabDropdownFilter
BLUR_KEYCODES
=
[
27
,
40
]
ARROW_KEY_CODES
=
[
38
,
40
]
HAS_VALUE_CLASS
=
"has-value"
constructor
:
(
@
input
,
@
options
)
->
...
...
@@ -22,19 +23,23 @@ class GitLabDropdownFilter
# Key events
timeout
=
""
@
input
.
on
"keyup"
,
(
e
)
=>
keyCode
=
e
.
which
return
if
ARROW_KEY_CODES
.
indexOf
(
keyCode
)
>=
0
if
@
input
.
val
()
isnt
""
and
!
$inputContainer
.
hasClass
HAS_VALUE_CLASS
$inputContainer
.
addClass
HAS_VALUE_CLASS
else
if
@
input
.
val
()
is
""
and
$inputContainer
.
hasClass
HAS_VALUE_CLASS
$inputContainer
.
removeClass
HAS_VALUE_CLASS
if
e
.
keyCode
is
13
and
@
input
.
val
()
isnt
""
if
keyCode
is
13
and
@
input
.
val
()
isnt
""
if
@
options
.
enterCallback
@
options
.
enterCallback
()
return
clearTimeout
timeout
timeout
=
setTimeout
=>
blur_field
=
@
shouldBlur
e
.
keyCode
blur_field
=
@
shouldBlur
keyCode
search_text
=
@
input
.
val
()
if
blur_field
and
@
filterInputBlur
...
...
@@ -96,7 +101,7 @@ class GitLabDropdown
LOADING_CLASS
=
"is-loading"
PAGE_TWO_CLASS
=
"is-page-two"
ACTIVE_CLASS
=
"is-active"
CURRENT_INDEX
=
-
1
currentIndex
=
-
1
FILTER_INPUT
=
'.dropdown-input .dropdown-input-field'
...
...
@@ -146,7 +151,7 @@ class GitLabDropdown
data
:
=>
return
@
fullData
callback
:
(
data
)
=>
CURRENT_INDEX
=
-
1
currentIndex
=
-
1
@
parseData
data
enterCallback
:
=>
if
@
enterCallback
...
...
@@ -311,11 +316,11 @@ class GitLabDropdown
if
@
highlight
text
=
@
highlightTextMatches
(
text
,
@
filterInput
.
val
())
html
=
"<li>
"
html
+=
"<a href='
#{
url
}
' class='
#{
cssClass
}
'>"
html
+=
text
html
+=
"</a>"
html
+=
"
</li>"
html
=
"<li>
<a href='
#{
url
}
' class='
#{
cssClass
}
'>
#{
text
}
</a>
</li>"
return
html
...
...
@@ -398,31 +403,31 @@ class GitLabDropdown
selector
=
".dropdown-page-one
#{
selector
}
"
$
(
'body'
).
on
'keydown'
,
(
e
)
=>
currentKeyCode
=
e
.
keyCode
currentKeyCode
=
e
.
which
if
ARROW_KEY_CODES
.
indexOf
(
currentKeyCode
)
>=
0
e
.
preventDefault
()
e
.
stopPropagation
()
e
.
stop
Immediate
Propagation
()
PREV_INDEX
=
CURRENT_INDEX
PREV_INDEX
=
currentIndex
$listItems
=
$
(
selector
,
@
dropdown
)
if
@
options
.
filterable
$input
.
blur
()
#
if @options.filterable
#
$input.blur()
if
currentKeyCode
is
40
# Move down
CURRENT_INDEX
+=
1
if
CURRENT_INDEX
<
(
$listItems
.
length
-
1
)
currentIndex
+=
1
if
currentIndex
<
(
$listItems
.
length
-
1
)
else
if
currentKeyCode
is
38
# Move up
CURRENT_INDEX
-=
1
if
CURRENT_INDEX
>
0
currentIndex
-=
1
if
currentIndex
>
0
@
highlightRowAtIndex
(
$listItems
,
CURRENT_INDEX
)
if
CURRENT_INDEX
isnt
PREV_INDEX
@
highlightRowAtIndex
(
$listItems
,
currentIndex
)
if
currentIndex
isnt
PREV_INDEX
return
false
if
currentKeyCode
is
13
@
selectRowAtIndex
CURRENT_INDEX
@
selectRowAtIndex
currentIndex
removeArrayKeyEvent
:
->
$
(
'body'
).
off
'keydown'
...
...
@@ -437,13 +442,13 @@ class GitLabDropdown
# Dropdown content scroll area
$dropdownContent
=
$listItem
.
closest
(
'.dropdown-content'
)
dropdownScrollTop
=
$dropdownContent
.
prop
(
'scrollTop'
)
dropdownContentHeight
=
$dropdownContent
.
prop
(
'offsetHeight'
)
dropdownScrollTop
=
$dropdownContent
.
scrollTop
(
)
dropdownContentHeight
=
$dropdownContent
.
outerHeight
(
)
dropdownContentTop
=
$dropdownContent
.
prop
(
'offsetTop'
)
dropdownContentBottom
=
dropdownContentTop
+
dropdownContentHeight
# Get the offset bottom of the list item
listItemHeight
=
$listItem
.
prop
(
'offsetHeight'
)
listItemHeight
=
$listItem
.
outerHeight
(
)
listItemTop
=
$listItem
.
prop
(
'offsetTop'
)
listItemBottom
=
listItemTop
+
listItemHeight
...
...
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