From 92b10ce80866137c80510f9a43e676593fb5b94d Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Tue, 10 Oct 2023 10:58:04 +0300 Subject: [PATCH] work for #7104 Themes API: Rename cover -> header, list its properties, create an interface for onThemeApplied arguments --- src/cover.ts | 2 +- src/survey-events-api.ts | 5 +++++ src/survey.ts | 6 +++--- src/themes.ts | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cover.ts b/src/cover.ts index 8ce015776a..a5a08793db 100644 --- a/src/cover.ts +++ b/src/cover.ts @@ -97,7 +97,7 @@ export class Cover extends Base { .toString(); } public fromTheme(theme: ITheme): void { - super.fromJSON(theme.cover); + super.fromJSON(theme.header); if(!!theme.cssVariables) { this.backgroundColor = theme.cssVariables["--sjs-cover-backcolor"]; } diff --git a/src/survey-events-api.ts b/src/survey-events-api.ts index 6d28a46d7e..bf311299e5 100644 --- a/src/survey-events-api.ts +++ b/src/survey-events-api.ts @@ -13,6 +13,7 @@ import { QuestionMatrixDynamicModel } from "./question_matrixdynamic"; import { QuestionPanelDynamicModel } from "./question_paneldynamic"; import { SurveyModel } from "./survey"; import { SurveyError } from "./survey-error"; +import { ITheme } from "./themes"; import { Trigger } from "./trigger"; export interface QuestionEventMixin { @@ -941,4 +942,8 @@ export interface PopupVisibleChangedEvent extends QuestionEventMixin { * Indicates whether the popup is visible now. */ visible: boolean; +} + +export interface ThemeAppliedEvent { + theme: ITheme; } \ No newline at end of file diff --git a/src/survey.ts b/src/survey.ts index 1bb6069546..aa0cbec90c 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -63,7 +63,7 @@ import { MatrixCellValidateEvent, DynamicPanelModifiedEvent, DynamicPanelRemovingEvent, TimerPanelInfoTextEvent, DynamicPanelItemValueChangedEvent, DynamicPanelGetTabTitleEvent, IsAnswerCorrectEvent, DragDropAllowEvent, ScrollingElementToTopEvent, GetQuestionTitleActionsEvent, GetPanelTitleActionsEvent, GetPageTitleActionsEvent, GetPanelFooterActionsEvent, GetMatrixRowActionsEvent, ElementContentVisibilityChangedEvent, GetExpressionDisplayValueEvent, ServerValidateQuestionsEvent, - MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent + MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent, ThemeAppliedEvent } from "./survey-events-api"; import { QuestionMatrixDropdownModelBase } from "./question_matrixdropdownbase"; import { QuestionMatrixDynamicModel } from "./question_matrixdynamic"; @@ -140,7 +140,7 @@ export class SurveyModel extends SurveyElementCore * An event that is raised after a [theme](/form-library/documentation/manage-default-themes-and-styles) is [applied](#applyTheme) to the survey. * @see applyTheme */ - onThemeApplied: EventBase = new EventBase(); + onThemeApplied: EventBase = new EventBase(); //#region Event declarations /** @@ -7353,7 +7353,7 @@ export class SurveyModel extends SurveyElementCore if (!theme) return; Object.keys(theme).forEach((key: keyof ITheme) => { - if (key === "cover") { + if (key === "header") { this.removeLayoutElement("cover"); const newCoverModel = new Cover(); newCoverModel.fromTheme(theme); diff --git a/src/themes.ts b/src/themes.ts index e58f3f4198..a7a3edd9b3 100644 --- a/src/themes.ts +++ b/src/themes.ts @@ -58,7 +58,7 @@ export interface ITheme { /** * An object with survey header settings. */ - cover?: {[index: string]: any}; + header?: {[index: string]: any}; /** * An object with CSS variables. */