clean up excess code from generateGroupId
This commit is contained in:
parent
f93121b226
commit
75f32afcd5
1 changed files with 6 additions and 11 deletions
|
@ -188,20 +188,15 @@ Menu.buildFromTemplate = function (template) {
|
|||
|
||||
// Search between separators to find a radio menu item and return its group id
|
||||
function generateGroupId (items, pos) {
|
||||
let i, item
|
||||
if (pos > 0) {
|
||||
let asc, start
|
||||
for (start = pos - 1, i = start, asc = start <= 0; asc ? i <= 0 : i >= 0; asc ? i++ : i--) {
|
||||
item = items[i]
|
||||
if (item.type === 'radio') { return item.groupId }
|
||||
if (item.type === 'separator') { break }
|
||||
for (let idx = pos - 1; idx >= 0; idx--) {
|
||||
if (items[idx].type === 'radio') return items[idx].groupId
|
||||
if (items[idx].type === 'separator') break
|
||||
}
|
||||
} else if (pos < items.length) {
|
||||
let asc1, end
|
||||
for (i = pos, end = items.length - 1, asc1 = pos <= end; asc1 ? i <= end : i >= end; asc1 ? i++ : i--) {
|
||||
item = items[i]
|
||||
if (item.type === 'radio') { return item.groupId }
|
||||
if (item.type === 'separator') { break }
|
||||
for (let idx = pos; idx <= items.length - 1; idx++) {
|
||||
if (items[idx].type === 'radio') return items[idx].groupId
|
||||
if (items[idx].type === 'separator') break
|
||||
}
|
||||
}
|
||||
groupIdIndex += 1
|
||||
|
|
Loading…
Reference in a new issue