Hide tooltips when window is resized

Refs atom/feedback#12
This commit is contained in:
Kevin Sawicki
2014-01-21 12:33:23 -08:00
parent cb8b38b7f7
commit 627e43dccf
2 changed files with 23 additions and 0 deletions

View File

@@ -65,3 +65,19 @@ describe "SpacePen extensions", ->
it "replaces multiple keystroke", ->
expect(humanizeKeystrokes('cmd-o ctrl-2')).toEqual '⌘O ⌃2'
describe "when the window is resized", ->
it "hides the tooltips", ->
class TooltipView extends View
@content: ->
@div()
view = new TooltipView()
view.attachToDom()
view.setTooltip('this is a tip')
view.tooltip('show')
expect($(document.body).find('.tooltip')).toBeVisible()
$(window).trigger('resize')
expect($(document.body).find('.tooltip')).not.toExist()

View File

@@ -59,6 +59,13 @@ jQuery.fn.destroyTooltip = ->
@hideTooltip()
@tooltip('destroy')
# Hide tooltips when window is resized
jQuery(document.body).on 'show.bs.tooltip', ({target}) ->
windowHandler = -> jQuery(target).hideTooltip()
jQuery(window).one('resize', windowHandler)
jQuery(target).one 'hide.bs.tooltip', ->
jQuery(window).off('resize', windowHandler)
jQuery.fn.setTooltip.getKeystroke = getKeystroke
jQuery.fn.setTooltip.humanizeKeystrokes = humanizeKeystrokes