fix: restore toggle synchronization using hyperscript 'or' operator
**Problem**: Toggles in action bar and hamburger menu were not synchronizing. When user clicked one toggle, the other didn't update. **Root Cause**: After restoring toggle functions, they were setting BOTH checkboxes explicitly instead of using the hyperscript 'or' operator pattern from the working version. **Fix**: Restored the original pattern from commitd4ef91b: - Use `set otherToggle to (#lengthToggle or #lengthToggleMenu)` - This dynamically selects "the other" toggle (not the one being clicked) - Simplified code: removed redundant null checks for both checkboxes - Fixed all 3 toggles: toggleCVLength, toggleIcons, toggleTheme **Benefits**: - Toggles now properly sync between action bar and menu - Cleaner, more maintainable code - Matches the proven working pattern **Reference**: Compared with working version at commitd4ef91b
This commit is contained in:
@@ -132,90 +132,54 @@ end
|
|||||||
|
|
||||||
def toggleCVLength(isLong)
|
def toggleCVLength(isLong)
|
||||||
set paper to the first .cv-paper
|
set paper to the first .cv-paper
|
||||||
set lengthCheckbox to the first #lengthToggle
|
set otherToggle to (#lengthToggle or #lengthToggleMenu)
|
||||||
set menuLengthCheckbox to the first #lengthToggleMenu
|
|
||||||
|
|
||||||
-- Update DOM state
|
|
||||||
if isLong is true
|
if isLong is true
|
||||||
remove .cv-short from paper
|
remove .cv-short from paper
|
||||||
add .cv-long to paper
|
add .cv-long to paper
|
||||||
if lengthCheckbox exists
|
|
||||||
set lengthCheckbox's checked to true
|
|
||||||
end
|
|
||||||
if menuLengthCheckbox exists
|
|
||||||
set menuLengthCheckbox's checked to true
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-length', 'long')
|
call localStorage.setItem('cv-length', 'long')
|
||||||
|
if otherToggle exists set otherToggle's checked to true
|
||||||
end
|
end
|
||||||
|
|
||||||
if isLong is false
|
if isLong is false
|
||||||
remove .cv-long from paper
|
remove .cv-long from paper
|
||||||
add .cv-short to paper
|
add .cv-short to paper
|
||||||
if lengthCheckbox exists
|
|
||||||
set lengthCheckbox's checked to false
|
|
||||||
end
|
|
||||||
if menuLengthCheckbox exists
|
|
||||||
set menuLengthCheckbox's checked to false
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-length', 'short')
|
call localStorage.setItem('cv-length', 'short')
|
||||||
|
if otherToggle exists set otherToggle's checked to false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggleIcons(showIcons)
|
def toggleIcons(showIcons)
|
||||||
set paper to the first .cv-paper
|
set paper to the first .cv-paper
|
||||||
set iconsCheckbox to the first #iconToggle
|
set otherToggle to (#iconToggle or #iconToggleMenu)
|
||||||
set menuIconsCheckbox to the first #iconToggleMenu
|
|
||||||
|
|
||||||
-- Update DOM state
|
|
||||||
if showIcons is true
|
if showIcons is true
|
||||||
add .show-icons to paper
|
add .show-icons to paper
|
||||||
if iconsCheckbox exists
|
call localStorage.setItem('cv-icons', 'true')
|
||||||
set iconsCheckbox's checked to true
|
if otherToggle exists set otherToggle's checked to true
|
||||||
end
|
|
||||||
if menuIconsCheckbox exists
|
|
||||||
set menuIconsCheckbox's checked to true
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-icons', 'show')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if showIcons is false
|
if showIcons is false
|
||||||
remove .show-icons from paper
|
remove .show-icons from paper
|
||||||
if iconsCheckbox exists
|
call localStorage.setItem('cv-icons', 'false')
|
||||||
set iconsCheckbox's checked to false
|
if otherToggle exists set otherToggle's checked to false
|
||||||
end
|
|
||||||
if menuIconsCheckbox exists
|
|
||||||
set menuIconsCheckbox's checked to false
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-icons', 'hide')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggleTheme(isClean)
|
def toggleTheme(isClean)
|
||||||
set container to the first .cv-container
|
set container to the first .cv-container
|
||||||
set themeCheckbox to the first #themeToggle
|
set otherToggle to (#themeToggle or #themeToggleMenu)
|
||||||
set menuThemeCheckbox to the first #themeToggleMenu
|
|
||||||
|
|
||||||
-- Update DOM state
|
|
||||||
if isClean is true
|
if isClean is true
|
||||||
add .theme-clean to container
|
add .theme-clean to container
|
||||||
if themeCheckbox exists
|
|
||||||
set themeCheckbox's checked to true
|
|
||||||
end
|
|
||||||
if menuThemeCheckbox exists
|
|
||||||
set menuThemeCheckbox's checked to true
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-theme', 'clean')
|
call localStorage.setItem('cv-theme', 'clean')
|
||||||
|
if otherToggle exists set otherToggle's checked to true
|
||||||
end
|
end
|
||||||
|
|
||||||
if isClean is false
|
if isClean is false
|
||||||
remove .theme-clean from container
|
remove .theme-clean from container
|
||||||
if themeCheckbox exists
|
|
||||||
set themeCheckbox's checked to false
|
|
||||||
end
|
|
||||||
if menuThemeCheckbox exists
|
|
||||||
set menuThemeCheckbox's checked to false
|
|
||||||
end
|
|
||||||
call localStorage.setItem('cv-theme', 'default')
|
call localStorage.setItem('cv-theme', 'default')
|
||||||
|
if otherToggle exists set otherToggle's checked to false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user