icons on search bar
This commit is contained in:
parent
8e4aa6e391
commit
be521d7d76
5 changed files with 65 additions and 6 deletions
|
@ -109,7 +109,7 @@ class Dispatcher
|
||||||
when 'projects:group_links:index'
|
when 'projects:group_links:index'
|
||||||
new GroupsSelect()
|
new GroupsSelect()
|
||||||
when 'search:show'
|
when 'search:show'
|
||||||
new SearchDropdowns()
|
new Search()
|
||||||
|
|
||||||
switch path.first()
|
switch path.first()
|
||||||
when 'admin'
|
when 'admin'
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
class @SearchDropdowns
|
class @Search
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@eventListeners()
|
||||||
|
|
||||||
$('.js-search-group-dropdown').glDropdown(
|
$('.js-search-group-dropdown').glDropdown(
|
||||||
selectable: true
|
selectable: true
|
||||||
filterable: true
|
filterable: true
|
||||||
|
@ -40,5 +42,27 @@ class @SearchDropdowns
|
||||||
@submitSearch()
|
@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: ->
|
submitSearch: ->
|
||||||
$('.js-search-form').submit()
|
$('.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 {
|
.btn-search {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 5px;
|
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
|
= @group.name
|
||||||
- else
|
- else
|
||||||
Any
|
Any
|
||||||
%b.caret
|
= icon("chevron-down")
|
||||||
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
|
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
|
||||||
.dropdown-title
|
.dropdown-title
|
||||||
%span Filter results by group
|
%span Filter results by group
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
= @project.name_with_namespace
|
= @project.name_with_namespace
|
||||||
- else
|
- else
|
||||||
Any
|
Any
|
||||||
%b.caret
|
= icon("chevron-down")
|
||||||
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
|
.dropdown-menu.dropdown-select.dropdown-menu-selectable.dropdown-menu-align-right
|
||||||
.dropdown-title
|
.dropdown-title
|
||||||
%span Filter results by project
|
%span Filter results by project
|
||||||
|
|
|
@ -4,7 +4,12 @@
|
||||||
|
|
||||||
.search-holder
|
.search-holder
|
||||||
.search-field-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'
|
- unless params[:snippets].eql? 'true'
|
||||||
= render 'filter' if current_user
|
= render 'filter' if current_user
|
||||||
= button_tag 'Search', class: "btn btn-success btn-search"
|
= button_tag "Search", class: "btn btn-success btn-search"
|
||||||
|
|
Loading…
Reference in a new issue