mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Send window commands instead of invoking window APIs directly.
For some events generated on the browser side, like reloading, closing window, we should not handle those events directly, instead we should send the corresponding commands to the renderer and let the renderer deal with it. The window.reload() is also moved to atom.reload(), because I saw things like toggleFullScreen(), focus(), toggleDevTools() are also there.
This commit is contained in:
@@ -111,13 +111,13 @@ window.unloadConfigWindow = ->
|
||||
$(window).off('focus blur before')
|
||||
|
||||
window.handleEvents = ->
|
||||
ipc.on 'close', -> $(window).trigger 'window:close'
|
||||
ipc.on 'command', (command) -> console.log command; $(window).trigger command
|
||||
|
||||
$(window).command 'window:toggle-full-screen', => atom.toggleFullScreen()
|
||||
$(window).on 'focus', -> $("body").removeClass('is-blurred')
|
||||
$(window).on 'blur', -> $("body").addClass('is-blurred')
|
||||
$(window).command 'window:close', => confirmClose()
|
||||
$(window).command 'window:reload', => reload()
|
||||
$(window).command 'window:reload', => atom.reload()
|
||||
|
||||
$(document).on 'click', 'a', (e) ->
|
||||
location = $(e.target).attr('href')
|
||||
@@ -224,16 +224,6 @@ window.applyStylesheet = (id, text, ttype = 'bundled') ->
|
||||
window.closeWithoutConfirm = ->
|
||||
ipc.sendChannel 'close-without-confirm'
|
||||
|
||||
window.reload = ->
|
||||
timesReloaded = process.global.timesReloaded ? 0
|
||||
++timesReloaded
|
||||
|
||||
if timesReloaded > 3
|
||||
atom.restartRendererProcess()
|
||||
else
|
||||
process.global.timesReloaded = timesReloaded
|
||||
$native.reload()
|
||||
|
||||
window.onerror = ->
|
||||
atom.openDevTools()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user