Route window.open to "new-window" event
This commit is contained in:
parent
94818aef26
commit
389e56ce36
5 changed files with 41 additions and 24 deletions
|
@ -1,34 +1,31 @@
|
|||
process = global.process
|
||||
ipc = require 'ipc'
|
||||
remote = require 'remote'
|
||||
|
||||
unless process.guestInstanceId?
|
||||
# Override default window.close, see:
|
||||
if process.guestInstanceId?
|
||||
# Override default window.close.
|
||||
window.close = ->
|
||||
remote.getCurrentWindow().close()
|
||||
|
||||
# Override default window.open.
|
||||
window.open = (url, name, features) ->
|
||||
options = {}
|
||||
for feature in features.split ','
|
||||
[name, value] = feature.split '='
|
||||
options[name] =
|
||||
if value is 'yes'
|
||||
true
|
||||
else if value is 'no'
|
||||
false
|
||||
else
|
||||
value
|
||||
# Make the browser window or guest view emit "new-window" event.
|
||||
window.open = (url, name='', features='') ->
|
||||
options = {}
|
||||
for feature in features.split ','
|
||||
[name, value] = feature.split '='
|
||||
options[name] =
|
||||
if value is 'yes'
|
||||
true
|
||||
else if value is 'no'
|
||||
false
|
||||
else
|
||||
value
|
||||
options.x ?= options.left
|
||||
options.y ?= options.top
|
||||
options.title ?= name
|
||||
options.width ?= 800
|
||||
options.height ?= 600
|
||||
|
||||
options.x ?= options.left
|
||||
options.y ?= options.top
|
||||
options.title ?= name
|
||||
options.width ?= 800
|
||||
options.height ?= 600
|
||||
|
||||
BrowserWindow = require('remote').require 'browser-window'
|
||||
browser = new BrowserWindow options
|
||||
browser.loadUrl url
|
||||
browser
|
||||
ipc.send 'ATOM_SHELL_WEB_CONTENTS_WINDOW_OPEN', url, name, features
|
||||
|
||||
# Use the dialog API to implement alert().
|
||||
window.alert = (message, title='') ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue