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
|
// Search between separators to find a radio menu item and return its group id
|
||||||
function generateGroupId (items, pos) {
|
function generateGroupId (items, pos) {
|
||||||
let i, item
|
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
let asc, start
|
for (let idx = pos - 1; idx >= 0; idx--) {
|
||||||
for (start = pos - 1, i = start, asc = start <= 0; asc ? i <= 0 : i >= 0; asc ? i++ : i--) {
|
if (items[idx].type === 'radio') return items[idx].groupId
|
||||||
item = items[i]
|
if (items[idx].type === 'separator') break
|
||||||
if (item.type === 'radio') { return item.groupId }
|
|
||||||
if (item.type === 'separator') { break }
|
|
||||||
}
|
}
|
||||||
} else if (pos < items.length) {
|
} else if (pos < items.length) {
|
||||||
let asc1, end
|
for (let idx = pos; idx <= items.length - 1; idx++) {
|
||||||
for (i = pos, end = items.length - 1, asc1 = pos <= end; asc1 ? i <= end : i >= end; asc1 ? i++ : i--) {
|
if (items[idx].type === 'radio') return items[idx].groupId
|
||||||
item = items[i]
|
if (items[idx].type === 'separator') break
|
||||||
if (item.type === 'radio') { return item.groupId }
|
|
||||||
if (item.type === 'separator') { break }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
groupIdIndex += 1
|
groupIdIndex += 1
|
||||||
|
|
Loading…
Reference in a new issue