Added esc support of search box.
This commit is contained in:
parent
a2798b17c2
commit
92f596e7f4
1 changed files with 16 additions and 2 deletions
|
@ -197,7 +197,15 @@ class App.Navigation extends App.Controller
|
||||||
@renderResult(result)
|
@renderResult(result)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
emptyAndClose = =>
|
||||||
|
@$('#global-search').val('').blur()
|
||||||
|
@$('.search').removeClass('filled').removeClass('open')
|
||||||
|
|
||||||
# observer search box
|
# observer search box
|
||||||
|
@$('#global-search').bind( 'focusout', (e) =>
|
||||||
|
@$('.search').removeClass('focused')
|
||||||
|
)
|
||||||
|
|
||||||
@$('#global-search').bind( 'focusin', (e) =>
|
@$('#global-search').bind( 'focusin', (e) =>
|
||||||
|
|
||||||
@$('.search').addClass('focused')
|
@$('.search').addClass('focused')
|
||||||
|
@ -233,6 +241,13 @@ class App.Navigation extends App.Controller
|
||||||
|
|
||||||
# start search
|
# start search
|
||||||
@$('#global-search').bind( 'keyup', (e) =>
|
@$('#global-search').bind( 'keyup', (e) =>
|
||||||
|
|
||||||
|
# close on esc
|
||||||
|
if e.which == 27
|
||||||
|
emptyAndClose()
|
||||||
|
return
|
||||||
|
|
||||||
|
# on other keys, show result
|
||||||
term = @$('#global-search').val().trim()
|
term = @$('#global-search').val().trim()
|
||||||
return if !term
|
return if !term
|
||||||
return if term is @term
|
return if term is @term
|
||||||
|
@ -245,8 +260,7 @@ class App.Navigation extends App.Controller
|
||||||
@$('.empty-search').on(
|
@$('.empty-search').on(
|
||||||
'click'
|
'click'
|
||||||
=>
|
=>
|
||||||
@$('#global-search').val('')
|
emptyAndClose()
|
||||||
@$('.search').removeClass('filled')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
new App.OnlineNotificationWidget(
|
new App.OnlineNotificationWidget(
|
||||||
|
|
Loading…
Reference in a new issue