Added close on open new tab.

This commit is contained in:
Martin Edenhofer 2015-06-01 16:39:27 +02:00
parent 190d86d4f1
commit 8c651959a8

View file

@ -100,14 +100,14 @@ class App.Navigation extends App.Controller
# remove result if not result exists # remove result if not result exists
if _.isEmpty( result ) if _.isEmpty( result )
@$('.search').removeClass('open') @$('.search').removeClass('open')
el.html( '' ) el.html('')
return return
# build markup # build markup
html = App.view('navigation/result')( html = App.view('navigation/result')(
result: result result: result
) )
el.html( html ) el.html(html)
# show result list # show result list
@$('.search').addClass('open') @$('.search').addClass('open')
@ -195,12 +195,30 @@ class App.Navigation extends App.Controller
area.result.push data area.result.push data
@renderResult(result) @renderResult(result)
@$('#global-search-result').on('click', 'a', =>
close()
) )
)
removePopovers = ->
$('.popover').remove()
close = =>
@$('#global-search').blur()
@$('.search').removeClass('open')
# remove not needed popovers
@delay( removePopovers, 280, 'removePopovers' )
emptyAndClose = => emptyAndClose = =>
@$('#global-search').val('').blur() @$('#global-search').val('').blur()
@$('.search').removeClass('filled').removeClass('open') @$('.search').removeClass('filled').removeClass('open')
# remove not needed popovers
@delay( removePopovers, 280, 'removePopovers' )
# observer search box # observer search box
@$('#global-search').bind( 'focusout', (e) => @$('#global-search').bind( 'focusout', (e) =>
@$('.search').removeClass('focused') @$('.search').removeClass('focused')
@ -211,7 +229,7 @@ class App.Navigation extends App.Controller
@$('.search').addClass('focused') @$('.search').addClass('focused')
# remove not needed popovers # remove not needed popovers
$('.popover').remove() removePopovers()
# check if search is needed # check if search is needed
term = @$('#global-search').val().trim() term = @$('#global-search').val().trim()
@ -220,27 +238,13 @@ class App.Navigation extends App.Controller
@delay( searchFunction, 220, 'search' ) @delay( searchFunction, 220, 'search' )
) )
# remove search result
# @$('#global-search').bind( 'focusout', (e) =>
# @delay(
# =>
# @$('.search').removeClass('focused')
# # remove not needed popovers
# $('.popover').remove()
# @renderResult()
# 320
# )
# )
# prevent submit of search box # prevent submit of search box
@$('form.search').bind( 'submit', (e) => @$('form.search').on( 'submit', (e) =>
e.preventDefault() e.preventDefault()
) )
# start search # start search
@$('#global-search').bind( 'keyup', (e) => @$('#global-search').on( 'keyup', (e) =>
# close on esc # close on esc
if e.which == 27 if e.which == 27