mirror of
https://github.com/atom/atom.git
synced 2026-01-14 17:38:03 -05:00
fix window blur and focus events
This commit is contained in:
1
.pairs
1
.pairs
@@ -5,6 +5,7 @@ pairs:
|
||||
ks: Kevin Sawicki; kevin
|
||||
jc: Jerry Cheung; jerry
|
||||
bl: Brian Lopez; brian
|
||||
jp: Justin Palmer; justin
|
||||
email:
|
||||
domain: github.com
|
||||
#global: true
|
||||
|
||||
@@ -13,14 +13,24 @@ describe "Window", ->
|
||||
atom.setRootViewStateForPath(rootView.project.getPath(), null)
|
||||
$(window).off 'beforeunload'
|
||||
|
||||
describe "window is loaded", ->
|
||||
describe "when the window is loaded", ->
|
||||
it "doesn't have .is-blurred on the body tag", ->
|
||||
$(window).trigger 'window:focus'
|
||||
expect($("body").hasClass("is-blurred")).toBe false
|
||||
expect($("body")).not.toHaveClass("is-blurred")
|
||||
|
||||
it "does have .is-blurred on the window blur event", ->
|
||||
$(window).trigger 'window:blur'
|
||||
expect($("body").hasClass("is-blurred")).toBe true
|
||||
fdescribe "when the window is blurred", ->
|
||||
beforeEach ->
|
||||
$(window).trigger 'blur'
|
||||
|
||||
afterEach ->
|
||||
$('body').removeClass('is-blurred')
|
||||
|
||||
it "adds the .is-blurred class on the body", ->
|
||||
expect($("body")).toHaveClass("is-blurred")
|
||||
|
||||
describe "when the window is focused again", ->
|
||||
it "removes the .is-blurred class from the body", ->
|
||||
$(window).trigger 'focus'
|
||||
expect($("body")).not.toHaveClass("is-blurred")
|
||||
|
||||
describe ".close()", ->
|
||||
it "is triggered by the 'core:close' event", ->
|
||||
|
||||
@@ -29,11 +29,11 @@ windowAdditions =
|
||||
$(window).on 'core:close', => @close()
|
||||
$(window).command 'window:close', => @close()
|
||||
|
||||
$(window).on 'window:focus', onFocus
|
||||
$(window).on 'window:blur', onBlur
|
||||
$(window).on 'focus', ->
|
||||
$('body').removeClass 'is-blurred'
|
||||
|
||||
$(window).on 'focus', -> $(@).trigger 'window:focus'
|
||||
$(window).on 'blur', -> $(@).trigger 'window:blur'
|
||||
$(window).on 'blur', ->
|
||||
$('body').addClass 'is-blurred'
|
||||
|
||||
# This method is intended only to be run when starting a normal application
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
@@ -106,12 +106,6 @@ windowAdditions =
|
||||
onerror: ->
|
||||
atom.showDevTools()
|
||||
|
||||
onFocus: (event) =>
|
||||
$('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