💄 Add ES6; Clean up from CoffeeScript conversion
This commit is contained in:
parent
5ec2e8d7e5
commit
5dc88aa543
1 changed files with 22 additions and 35 deletions
|
@ -1,33 +1,34 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const {Menu} = require('electron')
|
const {Menu} = require('electron')
|
||||||
const EventEmitter = require('events').EventEmitter
|
const {EventEmitter} = require('events')
|
||||||
|
|
||||||
const bindings = process.atomBinding('app')
|
const bindings = process.atomBinding('app')
|
||||||
const downloadItemBindings = process.atomBinding('download_item')
|
const downloadItemBindings = process.atomBinding('download_item')
|
||||||
const app = bindings.app
|
const {app} = bindings
|
||||||
|
|
||||||
Object.setPrototypeOf(app, EventEmitter.prototype)
|
Object.setPrototypeOf(app, EventEmitter.prototype)
|
||||||
|
|
||||||
app.setApplicationMenu = function (menu) {
|
let appPath = null
|
||||||
return Menu.setApplicationMenu(menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.getApplicationMenu = function () {
|
Object.assign(app, {
|
||||||
return Menu.getApplicationMenu()
|
getAppPath() { return appPath },
|
||||||
}
|
setAppPath(path) { appPath = path },
|
||||||
|
setApplicationMenu(menu) {
|
||||||
app.commandLine = {
|
return Menu.setApplicationMenu(menu)
|
||||||
appendSwitch: bindings.appendSwitch,
|
},
|
||||||
appendArgument: bindings.appendArgument
|
getApplicationMenu() {
|
||||||
}
|
return Menu.getApplicationMenu()
|
||||||
|
},
|
||||||
|
commandLine: {
|
||||||
|
appendSwitch: bindings.appendSwitch,
|
||||||
|
appendArgument: bindings.appendArgument
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock = {
|
app.dock = {
|
||||||
bounce: function (type) {
|
bounce (type = 'informational') {
|
||||||
if (type == null) {
|
|
||||||
type = 'informational'
|
|
||||||
}
|
|
||||||
return bindings.dockBounce(type)
|
return bindings.dockBounce(type)
|
||||||
},
|
},
|
||||||
cancelBounce: bindings.dockCancelBounce,
|
cancelBounce: bindings.dockCancelBounce,
|
||||||
|
@ -41,30 +42,16 @@ if (process.platform === 'darwin') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var appPath = null
|
|
||||||
|
|
||||||
app.setAppPath = function (path) {
|
|
||||||
appPath = path
|
|
||||||
}
|
|
||||||
|
|
||||||
app.getAppPath = function () {
|
|
||||||
return appPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// Routes the events to webContents.
|
// Routes the events to webContents.
|
||||||
var ref1 = ['login', 'certificate-error', 'select-client-certificate']
|
const events = ['login', 'certificate-error', 'select-client-certificate']
|
||||||
var fn = function (name) {
|
for (let name of events) {
|
||||||
return app.on(name, function (event, webContents, ...args) {
|
app.on(name, (event, webContents, ...args) => {
|
||||||
return webContents.emit.apply(webContents, [name, event].concat(args))
|
return webContents.emit.apply(webContents, [name, event].concat(args))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var i, len
|
|
||||||
for (i = 0, len = ref1.length; i < len; i++) {
|
|
||||||
fn(ref1[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wrappers for native classes.
|
// Wrappers for native classes.
|
||||||
var wrapDownloadItem = function (downloadItem) {
|
const wrapDownloadItem = (downloadItem) => {
|
||||||
// downloadItem is an EventEmitter.
|
// downloadItem is an EventEmitter.
|
||||||
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue