remove excess code in delegate

This commit is contained in:
Shelley Vohr 2017-10-23 22:33:23 -04:00
parent 9b364d5be3
commit 508b614769
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -16,31 +16,19 @@ Menu.prototype._init = function () {
this.groupsMap = {} this.groupsMap = {}
this.items = [] this.items = []
this.delegate = { this.delegate = {
isCommandIdChecked: (commandId) => { isCommandIdChecked: id => this.commandsMap[id].checked,
var command = this.commandsMap[commandId] isCommandIdEnabled: id => this.commandsMap[id].enabled,
return command != null ? command.checked : undefined isCommandIdVisible: id => this.commandsMap[id].visible,
}, getAcceleratorForCommandId: (id, useDefaultAccelerator) => {
isCommandIdEnabled: (commandId) => { const command = this.commandsMap[id]
var command = this.commandsMap[commandId] if (command === null) return
return command != null ? command.enabled : undefined if (command.accelerator !== null) return command.accelerator
},
isCommandIdVisible: (commandId) => {
var command = this.commandsMap[commandId]
return command != null ? command.visible : undefined
},
getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
const command = this.commandsMap[commandId]
if (command == null) return
if (command.accelerator != null) return command.accelerator
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator() if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
}, },
getIconForCommandId: (commandId) => { getIconForCommandId: id => this.commandsMap[id].icon,
var command = this.commandsMap[commandId] executeCommand: (event, id) => {
return command != null ? command.icon : undefined const command = this.commandsMap[id]
}, if (command === null) return
executeCommand: (event, commandId) => {
const command = this.commandsMap[commandId]
if (command == null) return
command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents()) command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
}, },
menuWillShow: () => { menuWillShow: () => {