Menu fixes concerning flexbox ordering versus dom ordering.
This commit is contained in:
parent
2d677acad4
commit
faee3e0d9e
File diff suppressed because one or more lines are too long
@ -493,7 +493,7 @@ a[href="javascript:;"] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
#menu {
|
||||
border-width: 1px 1px 0;
|
||||
border-bottom: 0;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
-webkit-flex-flow: column nowrap;
|
||||
@ -526,6 +526,7 @@ a[href="javascript:;"] {
|
||||
display: none;
|
||||
}
|
||||
.submenu {
|
||||
border-bottom: 0;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
-webkit-flex-flow: column nowrap;
|
||||
|
||||
@ -52,7 +52,10 @@ UI = (->
|
||||
for entry in @entries
|
||||
@insertEntry entry, menu, data
|
||||
|
||||
@focus $ '.entry', menu
|
||||
entry = $ '.entry', menu
|
||||
while prevEntry = @findNextEntry entry, -1
|
||||
entry = prevEntry
|
||||
@focus entry
|
||||
$.on d, 'click', @close
|
||||
$.on d, 'CloseMenu', @close
|
||||
$.add d.body, menu
|
||||
@ -103,6 +106,12 @@ UI = (->
|
||||
$.off d, 'click', @close
|
||||
$.off d, 'CloseMenu', @close
|
||||
|
||||
findNextEntry: (entry, direction) ->
|
||||
entries = Array::slice.call entry.parentNode.children
|
||||
entries.sort (first, second) ->
|
||||
+(first.style.order or first.style.webkitOrder) - +(second.style.order or second.style.webkitOrder)
|
||||
entries[entries.indexOf(entry) + direction]
|
||||
|
||||
keybinds: (e) ->
|
||||
entry = $ '.focused', currentMenu
|
||||
while subEntry = $ '.focused', entry
|
||||
@ -115,13 +124,16 @@ UI = (->
|
||||
when 13, 32 # Enter, Space
|
||||
entry.click()
|
||||
when 38 # Up
|
||||
if next = entry.previousElementSibling
|
||||
if next = @findNextEntry entry, -1
|
||||
@focus next
|
||||
when 40 # Down
|
||||
if next = entry.nextElementSibling
|
||||
if next = @findNextEntry entry, +1
|
||||
@focus next
|
||||
when 39 # Right
|
||||
if (submenu = $ '.submenu', entry) and next = submenu.firstElementChild
|
||||
if (submenu = $ '.submenu', entry)
|
||||
next = submenu.firstElementChild
|
||||
while nextPrev = @findNextEntry next, -1
|
||||
next = nextPrev
|
||||
@focus next
|
||||
when 37 # Left
|
||||
if next = $.x 'parent::*[contains(@class,"submenu")]/parent::*', entry
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user