diff --git a/app/javascript/retrospring/features/settings/index.ts b/app/javascript/retrospring/features/settings/index.ts index cca0c189..ab96781c 100644 --- a/app/javascript/retrospring/features/settings/index.ts +++ b/app/javascript/retrospring/features/settings/index.ts @@ -10,7 +10,7 @@ export default (): void => { themeDocumentHandler(); registerEvents([ - { type: 'submit', target: document.querySelector('#update_theme'), handler: themeSubmitHandler }, + { type: 'submit', target: document.querySelector('[action="/settings/theme"]'), handler: themeSubmitHandler }, { type: 'submit', target: document.querySelector('#edit_user'), handler: userSubmitHandler }, { type: 'change', target: document.querySelector('#user_profile_picture[type=file]'), handler: profilePictureChangeHandler }, { type: 'change', target: document.querySelector('#user_profile_header[type=file]'), handler: profileHeaderChangeHandler }, diff --git a/app/javascript/retrospring/features/settings/theme.ts b/app/javascript/retrospring/features/settings/theme.ts index 03acca3e..541e5ea6 100644 --- a/app/javascript/retrospring/features/settings/theme.ts +++ b/app/javascript/retrospring/features/settings/theme.ts @@ -6,7 +6,7 @@ let previewTimeout = null; const previewTheme = (): void => { const payload = {}; - Array.from(document.querySelectorAll('#update_theme .color')).forEach((color: HTMLInputElement) => { + Array.from(document.querySelectorAll('#update .color')).forEach((color: HTMLInputElement) => { const name = color.name.substring(6, color.name.length - 1); payload[name] = parseInt(color.value.substr(1, 6), 16); }); @@ -67,7 +67,7 @@ const getDecimalTripletsFromHex = (hex: string): string => { } export function themeDocumentHandler(): void { - if (!document.querySelector('#update_theme')) return; + if (!document.querySelector('[action="/settings/theme"]')) return; if (document.querySelector('#clr-picker')) return; previewStyle = document.createElement('style'); @@ -76,7 +76,7 @@ export function themeDocumentHandler(): void { Coloris.init(); - Array.from(document.querySelectorAll('#update_theme .color')).forEach((color: HTMLInputElement) => { + Array.from(document.querySelectorAll('#update .color')).forEach((color: HTMLInputElement) => { // If there already is a hex-color in the input, skip if (color.value.startsWith('#')) return; @@ -108,7 +108,7 @@ export function themeDocumentHandler(): void { } export function themeSubmitHandler(): void { - Array.from(document.querySelectorAll('#update_theme .color')).forEach((color: HTMLInputElement) => { + Array.from(document.querySelectorAll('#update .color')).forEach((color: HTMLInputElement) => { color.value = String(parseInt(color.value.substr(1, 6), 16)); }); } \ No newline at end of file