refactor: use hyperscript event filtering and destructuring
- Use event filtering [key is 'Enter' or key is ' '] on PDF modal cards - Remove handlePdfCardKey helper function (now inline) - Use event destructuring on keydown(key, target, ctrlKey, metaKey, altKey) - Cleaner, more idiomatic hyperscript patterns
This commit is contained in:
@@ -33,13 +33,3 @@ def selectPdfCard(card)
|
||||
set window.selectedPdfFormat to card's @data-cv-format
|
||||
end
|
||||
|
||||
-- ==============================================================================
|
||||
-- PDF CARD KEYDOWN HANDLER
|
||||
-- ==============================================================================
|
||||
-- Handles keyboard navigation for PDF cards (Enter/Space to select)
|
||||
def handlePdfCardKey(card, evt)
|
||||
if evt.key is 'Enter' or evt.key is ' '
|
||||
call evt.preventDefault()
|
||||
call selectPdfCard(card)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
<body {{if .ThemeClean}}class="theme-clean"{{end}}
|
||||
_="on load call initScrollBehavior()
|
||||
on scroll from window call handleScroll()
|
||||
on keydown
|
||||
set tag to event.target.tagName
|
||||
on keydown(key, target, ctrlKey, metaKey, altKey)
|
||||
set ninjaKeys to #cmd-k-bar
|
||||
set ninjaOpen to (ninjaKeys is not null and ninjaKeys.opened)
|
||||
set skip to (tag is 'INPUT' or tag is 'TEXTAREA' or ninjaOpen)
|
||||
set noMod to (not event.ctrlKey and not event.metaKey and not event.altKey)
|
||||
if event.key is '?' and noMod and not skip then halt the event then call openModalShortcut('shortcuts-modal') end
|
||||
if (event.key is 'l' or event.key is 'L') and noMod and not skip then halt the event then call handleToggleShortcut('lengthToggle', 'lengthToggleMenu') end
|
||||
if (event.key is 'i' or event.key is 'I') and noMod and not skip then halt the event then call handleToggleShortcut('iconToggle', 'iconToggleMenu') end
|
||||
if (event.key is 'v' or event.key is 'V') and noMod and not skip then halt the event then call handleToggleShortcut('themeToggle', 'themeToggleMenu') end
|
||||
set skip to (target.tagName is 'INPUT' or target.tagName is 'TEXTAREA' or ninjaOpen)
|
||||
set noMod to (not ctrlKey and not metaKey and not altKey)
|
||||
if key is '?' and noMod and not skip then halt the event then call openModalShortcut('shortcuts-modal') end
|
||||
if (key is 'l' or key is 'L') and noMod and not skip then halt the event then call handleToggleShortcut('lengthToggle', 'lengthToggleMenu') end
|
||||
if (key is 'i' or key is 'I') and noMod and not skip then halt the event then call handleToggleShortcut('iconToggle', 'iconToggleMenu') end
|
||||
if (key is 'v' or key is 'V') and noMod and not skip then halt the event then call handleToggleShortcut('themeToggle', 'themeToggleMenu') end
|
||||
end">
|
||||
|
||||
<!-- ============================================ -->
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
aria-label="{{.UI.PdfModal.ShortCv.AriaLabel}}"
|
||||
tabindex="0"
|
||||
_="on click call selectPdfCard(me)
|
||||
on keydown call handlePdfCardKey(me, event)">
|
||||
on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">
|
||||
|
||||
<div class="pdf-thumbnail thumbnail-short">
|
||||
<!-- Header representation -->
|
||||
@@ -80,7 +80,7 @@
|
||||
aria-label="{{.UI.PdfModal.DefaultCv.AriaLabel}}"
|
||||
tabindex="0"
|
||||
_="on click call selectPdfCard(me)
|
||||
on keydown call handlePdfCardKey(me, event)">
|
||||
on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">
|
||||
|
||||
<div class="pdf-thumbnail thumbnail-default">
|
||||
<!-- Two-column layout with sidebar -->
|
||||
@@ -123,7 +123,7 @@
|
||||
aria-label="{{.UI.PdfModal.ExtendedCv.AriaLabel}}"
|
||||
tabindex="0"
|
||||
_="on click call selectPdfCard(me)
|
||||
on keydown call handlePdfCardKey(me, event)">
|
||||
on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">
|
||||
|
||||
<div class="pdf-thumbnail thumbnail-long">
|
||||
<!-- Header representation -->
|
||||
|
||||
Reference in New Issue
Block a user