mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
clean up menuWillShow
This commit is contained in:
@@ -88,15 +88,15 @@ Menu.prototype._init = function () {
|
||||
this.items = []
|
||||
this.delegate = {
|
||||
isCommandIdChecked: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.checked : undefined
|
||||
},
|
||||
isCommandIdEnabled: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.enabled : undefined
|
||||
},
|
||||
isCommandIdVisible: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.visible : undefined
|
||||
},
|
||||
getAcceleratorForCommandId: (commandId, useDefaultAccelerator) => {
|
||||
@@ -106,7 +106,7 @@ Menu.prototype._init = function () {
|
||||
if (useDefaultAccelerator) return command.getDefaultRoleAccelerator()
|
||||
},
|
||||
getIconForCommandId: (commandId) => {
|
||||
var command = this.commandsMap[commandId]
|
||||
const command = this.commandsMap[commandId]
|
||||
return command != null ? command.icon : undefined
|
||||
},
|
||||
executeCommand: (event, commandId) => {
|
||||
@@ -115,23 +115,17 @@ Menu.prototype._init = function () {
|
||||
command.click(event, BrowserWindow.getFocusedWindow(), webContents.getFocusedWebContents())
|
||||
},
|
||||
menuWillShow: () => {
|
||||
// Make sure radio groups have at least one menu item seleted.
|
||||
var checked, group, id, j, len, radioItem, ref1
|
||||
ref1 = this.groupsMap
|
||||
for (id in ref1) {
|
||||
group = ref1[id]
|
||||
checked = false
|
||||
for (j = 0, len = group.length; j < len; j++) {
|
||||
radioItem = group[j]
|
||||
if (!radioItem.checked) {
|
||||
continue
|
||||
}
|
||||
// Make sure radio groups have at least one menu item selected
|
||||
for (let id in this.groupsMap) {
|
||||
const group = this.groupsMap[id]
|
||||
const checked = false
|
||||
for (let idx = 0; idx < group.length; idx++) {
|
||||
const radioItem = group[idx]
|
||||
if (!radioItem.checked) continue
|
||||
checked = true
|
||||
break
|
||||
}
|
||||
if (!checked) {
|
||||
v8Util.setHiddenValue(group[0], 'checked', true)
|
||||
}
|
||||
if (!checked) v8Util.setHiddenValue(group[0], 'checked', true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user