From 8f8ebaf77b08615018a7cb627b0863b5cbaab594 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 26 Jun 2022 03:00:08 +0200 Subject: [PATCH] Update theme settings related TypeScript code --- app/javascript/retrospring/features/settings/index.ts | 2 +- app/javascript/retrospring/features/settings/theme.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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