BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a477d604
Commit
a477d604
authored
Mar 21, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to clear location badge
parent
eff98ffe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
42 deletions
+82
-42
search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+23
-5
variables.scss
app/assets/stylesheets/framework/variables.scss
+2
-1
search.scss
app/assets/stylesheets/pages/search.scss
+46
-25
_search.html.haml
app/views/layouts/_search.html.haml
+11
-2
_location_badge.html.haml
app/views/shared/_location_badge.html.haml
+0
-9
No files found.
app/assets/javascripts/search_autocomplete.js.coffee
View file @
a477d604
...
@@ -27,6 +27,7 @@ class @SearchAutocomplete
...
@@ -27,6 +27,7 @@ class @SearchAutocomplete
@
groupInputEl
=
@
getElement
(
'#group_id'
)
@
groupInputEl
=
@
getElement
(
'#group_id'
)
@
searchCodeInputEl
=
@
getElement
(
'#search_code'
)
@
searchCodeInputEl
=
@
getElement
(
'#search_code'
)
@
repositoryInputEl
=
@
getElement
(
'#repository_ref'
)
@
repositoryInputEl
=
@
getElement
(
'#repository_ref'
)
@
clearInput
=
@
getElement
(
'.js-clear-input'
)
@
saveOriginalState
()
@
saveOriginalState
()
...
@@ -59,6 +60,7 @@ class @SearchAutocomplete
...
@@ -59,6 +60,7 @@ class @SearchAutocomplete
@
searchInput
.
on
'keydown'
,
@
onSearchInputKeyDown
@
searchInput
.
on
'keydown'
,
@
onSearchInputKeyDown
@
searchInput
.
on
'focus'
,
@
onSearchInputFocus
@
searchInput
.
on
'focus'
,
@
onSearchInputFocus
@
searchInput
.
on
'blur'
,
@
onSearchInputBlur
@
searchInput
.
on
'blur'
,
@
onSearchInputBlur
@
clearInput
.
on
'click'
,
@
onRemoveLocationClick
enableAutocomplete
:
->
enableAutocomplete
:
->
return
if
@
autocomplete
return
if
@
autocomplete
...
@@ -150,12 +152,25 @@ class @SearchAutocomplete
...
@@ -150,12 +152,25 @@ class @SearchAutocomplete
onSearchInputFocus
:
=>
onSearchInputFocus
:
=>
@
wrap
.
addClass
(
'search-active'
)
@
wrap
.
addClass
(
'search-active'
)
onSearchInputBlur
:
=>
onRemoveLocationClick
:
(
e
)
=>
@
wrap
.
removeClass
(
'search-active'
)
e
.
preventDefault
()
@
removeLocationBadge
()
@
searchInput
.
val
(
''
).
focus
()
@
skipBlurEvent
=
true
# If input is blank then restore state
onSearchInputBlur
:
(
e
)
=>
if
@
searchInput
.
val
()
is
''
@
skipBlurEvent
=
false
@
restoreOriginalState
()
# We should wait to make sure we are not clearing the input instead
setTimeout
(
=>
return
if
@
skipBlurEvent
@
wrap
.
removeClass
(
'search-active'
)
# If input is blank then restore state
if
@
searchInput
.
val
()
is
''
@
restoreOriginalState
()
,
100
)
addLocationBadge
:
(
item
)
->
addLocationBadge
:
(
item
)
->
category
=
if
item
.
category
?
then
"
#{
item
.
category
}
: "
else
''
category
=
if
item
.
category
?
then
"
#{
item
.
category
}
: "
else
''
...
@@ -165,6 +180,7 @@ class @SearchAutocomplete
...
@@ -165,6 +180,7 @@ class @SearchAutocomplete
<i class='location-text'>
#{
category
}#{
value
}
</i>
<i class='location-text'>
#{
category
}#{
value
}
</i>
</span>"
</span>"
@
locationBadgeEl
.
html
(
html
)
@
locationBadgeEl
.
html
(
html
)
@
wrap
.
addClass
(
'has-location-badge'
)
restoreOriginalState
:
->
restoreOriginalState
:
->
inputs
=
Object
.
keys
@
originalState
inputs
=
Object
.
keys
@
originalState
...
@@ -208,6 +224,8 @@ class @SearchAutocomplete
...
@@ -208,6 +224,8 @@ class @SearchAutocomplete
# Reset state
# Reset state
@
resetSearchState
()
@
resetSearchState
()
@
wrap
.
removeClass
(
'has-location-badge'
)
disableAutocomplete
:
->
disableAutocomplete
:
->
if
@
autocomplete
if
@
autocomplete
@
searchInput
.
addClass
(
'disabled'
)
@
searchInput
.
addClass
(
'disabled'
)
...
...
app/assets/stylesheets/framework/variables.scss
View file @
a477d604
...
@@ -199,4 +199,5 @@ $award-emoji-new-btn-icon-color: #dcdcdc;
...
@@ -199,4 +199,5 @@ $award-emoji-new-btn-icon-color: #dcdcdc;
$location-badge-color
:
#aaa
;
$location-badge-color
:
#aaa
;
$location-badge-bg
:
$gray-normal
;
$location-badge-bg
:
$gray-normal
;
$location-icon-color
:
#e7e9ed
;
$location-icon-color
:
#e7e9ed
;
$location-active-color
:
#7f8fa4
;
$location-active-bg
:
$location-active-color
;
app/assets/stylesheets/pages/search.scss
View file @
a477d604
...
@@ -26,24 +26,6 @@
...
@@ -26,24 +26,6 @@
margin-left
:
10px
;
margin-left
:
10px
;
margin-top
:
(
$header-height
-
35
)
/
2
;
margin-top
:
(
$header-height
-
35
)
/
2
;
&
.search-active
{
form
{
@extend
.form-control
:focus
;
}
.location-badge
{
@include
transition
(
all
.15s
);
background-color
:
$input-border-focus
;
color
:
$white-light
;
}
.search-input-wrap
{
i
{
color
:
$input-border-focus
;
}
}
}
form
{
form
{
@extend
.form-control
;
@extend
.form-control
;
margin
:
0
;
margin
:
0
;
...
@@ -92,16 +74,11 @@
...
@@ -92,16 +74,11 @@
width
:
100%
;
width
:
100%
;
position
:
relative
;
position
:
relative
;
.search-icon
{
.search-icon
,
.clear-icon
{
@extend
.fa-search
;
@include
transition
(
color
.15s
);
position
:
absolute
;
position
:
absolute
;
right
:
5px
;
right
:
5px
;
color
:
$location-icon-color
;
top
:
0
;
top
:
0
;
-webkit-user-select
:
none
;
color
:
$location-icon-color
;
-moz-user-select
:
none
;
-ms-user-select
:
none
;
&
:before
{
&
:before
{
font-family
:
FontAwesome
;
font-family
:
FontAwesome
;
...
@@ -110,9 +87,53 @@
...
@@ -110,9 +87,53 @@
}
}
}
}
.search-icon
{
@extend
.fa-search
;
@include
transition
(
color
.15s
);
-webkit-user-select
:
none
;
-moz-user-select
:
none
;
-ms-user-select
:
none
;
}
.clear-icon
{
@extend
.fa-times
;
display
:
none
;
}
.dropdown-header
{
.dropdown-header
{
text-transform
:
uppercase
;
text-transform
:
uppercase
;
font-size
:
11px
;
font-size
:
11px
;
}
}
}
}
&
.search-active
{
form
{
@extend
.form-control
:focus
;
}
.location-badge
{
@include
transition
(
all
.15s
);
background-color
:
$location-active-bg
;
color
:
$white-light
;
}
.search-input-wrap
{
i
{
color
:
$location-active-color
;
}
}
&
.has-location-badge
{
.search-icon
{
display
:
none
;
}
.clear-icon
{
cursor
:
pointer
;
display
:
block
;
}
}
}
}
}
app/views/layouts/_search.html.haml
View file @
a477d604
.search.search-form
-
if
controller
.
controller_path
=~
/^groups/
-
label
=
'This group'
-
if
controller
.
controller_path
=~
/^projects/
-
label
=
'This project'
.search.search-form
{
class:
"#{'has-location-badge' if label.present?}"
}
=
form_tag
search_path
,
method: :get
,
class:
'navbar-form'
do
|
f
|
=
form_tag
search_path
,
method: :get
,
class:
'navbar-form'
do
|
f
|
.search-input-container
.search-input-container
.search-location-badge
.search-location-badge
=
render
'shared/location_badge'
-
if
label
.
present?
%span
.location-badge
%i
.location-text
=
label
.search-input-wrap
.search-input-wrap
.dropdown
{
data:
{
url:
search_autocomplete_path
}
}
.dropdown
{
data:
{
url:
search_autocomplete_path
}
}
=
search_field_tag
"search"
,
nil
,
placeholder:
'Search'
,
class:
"search-input dropdown-menu-toggle"
,
spellcheck:
false
,
tabindex:
"1"
,
autocomplete:
'off'
,
data:
{
toggle:
'dropdown'
}
=
search_field_tag
"search"
,
nil
,
placeholder:
'Search'
,
class:
"search-input dropdown-menu-toggle"
,
spellcheck:
false
,
tabindex:
"1"
,
autocomplete:
'off'
,
data:
{
toggle:
'dropdown'
}
...
@@ -10,6 +18,7 @@
...
@@ -10,6 +18,7 @@
=
dropdown_content
=
dropdown_content
=
dropdown_loading
=
dropdown_loading
%i
.search-icon
%i
.search-icon
%i
.clear-icon.js-clear-input
=
hidden_field_tag
:group_id
,
@group
.
try
(
:id
)
=
hidden_field_tag
:group_id
,
@group
.
try
(
:id
)
=
hidden_field_tag
:project_id
,
@project
&&
@project
.
persisted?
?
@project
.
id
:
''
,
id:
'search_project_id'
=
hidden_field_tag
:project_id
,
@project
&&
@project
.
persisted?
?
@project
.
id
:
''
,
id:
'search_project_id'
...
...
app/views/shared/_location_badge.html.haml
deleted
100644 → 0
View file @
eff98ffe
-
if
controller
.
controller_path
=~
/^groups/
-
label
=
'This group'
-
if
controller
.
controller_path
=~
/^projects/
-
label
=
'This project'
-
if
label
.
present?
%span
.location-badge
%i
.location-text
=
label
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