luda
Version:
A library helps to build cross-framework UI components.
41 lines (29 loc) • 801 B
text/coffeescript
import '../kernel/index.coffee'
luda.component 'tabulate', document
.protect
selector: 'input[type=radio]:not([disabled])'
.protect
disabled: -> .data('tabulate') is false
.protect
findSiblings: (radio) ->
selector =
selector = "#{selector}[name=#{name}]" if name = radio.name
radios = luda(selector).els.filter (el) -> el.tabIndex >= 0
index = radios.indexOf radio
prev: radios[index - 1]
next: radios[index + 1]
trigger: (e) ->
return if
if e.shiftKey
if prev = .prev
e.preventDefault()
prev.focus()
else
if next = .next
e.preventDefault()
next.focus()
.help
listen: ->
[
['keydown@tab', , ]
]