Commit be521d7d authored by Phil Hughes's avatar Phil Hughes

icons on search bar

parent 8e4aa6e3
......@@ -109,7 +109,7 @@ class Dispatcher
when 'projects:group_links:index'
new GroupsSelect()
when 'search:show'
new SearchDropdowns()
new Search()
switch path.first()
when 'admin'
......
class @SearchDropdowns
class @Search
constructor: ->
@eventListeners()
$('.js-search-group-dropdown').glDropdown(
selectable: true
filterable: true
......@@ -40,5 +42,27 @@ class @SearchDropdowns
@submitSearch()
)
eventListeners: ->
$(document)
.off 'keyup', '.js-search-input'
.on 'keyup', '.js-search-input', @searchKeyUp
$(document)
.off 'click', '.js-search-clear'
.on 'click', '.js-search-clear', @clearSearchField
submitSearch: ->
$('.js-search-form').submit()
searchKeyUp: ->
$input = $(@)
if $input.val() is ''
$('.js-search-clear').addClass 'hidden'
else
$('.js-search-clear').removeClass 'hidden'
clearSearchField: ->
$('.js-search-input')
.val ''
.trigger 'keyup'
......@@ -169,6 +169,19 @@
}
}
.search-icon {
position: absolute;
left: 10px;
top: 10px;
color: $gray-darkest;
pointer-events: none;
}
.search-text-input {
padding-left: $gl-padding + 15px;
padding-right: $gl-padding + 15px;
}
.btn-search {
width: 100%;
margin-top: 5px;
......@@ -197,3 +210,20 @@
}
}
}
.search-clear {
position: absolute;
right: 10px;
top: 10px;
padding: 0;
color: $gray-darkest;
line-height: 0;
background: none;
border: 0;
&:hover,
&:focus {
color: $gl-link-color;
outline: none;
}
}
......@@ -9,7 +9,7 @@
= @group.name
- else
Any
%b.caret
= icon("chevron-down")
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
.dropdown-title
%span Filter results by group
......@@ -26,7 +26,7 @@
= @project.name_with_namespace
- else
Any
%b.caret
= icon("chevron-down")
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
.dropdown-title
%span Filter results by project
......
......@@ -4,7 +4,12 @@
.search-holder
.search-field-holder
= search_field_tag :search, params[:search], placeholder: "Search for projects, issues etc", class: "form-control search-text-input", id: "dashboard_search", autofocus: true, spellcheck: false
= search_field_tag :search, params[:search], placeholder: "Search for projects, issues etc", class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false
= icon("search", class: "search-icon")
%button.search-clear.js-search-clear{ class: ("hidden" if !params[:search].present?), type: "button", tabindex: "-1" }
= icon("times-circle")
%span.sr-only
Clear search
- unless params[:snippets].eql? 'true'
= render 'filter' if current_user
= button_tag 'Search', class: "btn btn-success btn-search"
= button_tag "Search", class: "btn btn-success btn-search"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment