mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
add onBlur and onFocus events for the window
This allows us to simulate those events and test for them easier
This commit is contained in:
@@ -15,10 +15,11 @@ describe "Window", ->
|
||||
|
||||
describe "window is loaded", ->
|
||||
it "doesn't have .is-blurred on the body tag", ->
|
||||
$(window).trigger 'window:focus'
|
||||
expect($("body").hasClass("is-blurred")).toBe false
|
||||
|
||||
it "does have .is-blurred on the window blur event", ->
|
||||
$(window).blur()
|
||||
$(window).trigger 'window:blur'
|
||||
expect($("body").hasClass("is-blurred")).toBe true
|
||||
|
||||
describe ".close()", ->
|
||||
|
||||
@@ -28,8 +28,12 @@ windowAdditions =
|
||||
|
||||
$(window).on 'core:close', => @close()
|
||||
$(window).command 'window:close', => @close()
|
||||
$(window).on 'focus', -> $("body").removeClass('is-blurred')
|
||||
$(window).on 'blur', -> $("body").addClass('is-blurred')
|
||||
|
||||
$(window).on 'window:focus', onFocus
|
||||
$(window).on 'window:blur', onBlur
|
||||
|
||||
$(window).on 'focus', -> $(@).trigger 'window:focus'
|
||||
$(window).on 'blur', -> $(@).trigger 'window:blur'
|
||||
|
||||
# This method is intended only to be run when starting a normal application
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
@@ -102,6 +106,13 @@ windowAdditions =
|
||||
onerror: ->
|
||||
atom.showDevTools()
|
||||
|
||||
onFocus: (event) =>
|
||||
console.log 'focused'
|
||||
$('body').removeClass 'is-blurred'
|
||||
|
||||
onBlur: (event) =>
|
||||
$('body').addClass 'is-blurred'
|
||||
|
||||
measure: (description, fn) ->
|
||||
start = new Date().getTime()
|
||||
value = fn()
|
||||
|
||||
Reference in New Issue
Block a user