-
Notifications
You must be signed in to change notification settings - Fork 776
/
survey.ts
7988 lines (7880 loc) · 315 KB
/
survey.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { HashTable, Helpers } from "./helpers";
import { JsonObject, JsonError, Serializer, property, propertyArray } from "./jsonobject";
import { Base, EventBase, ComputedUpdater } from "./base";
import {
ISurvey,
ISurveyData,
ISurveyImpl,
ITextProcessor,
IQuestion,
IPanel,
IElement,
IPage,
ISurveyErrorOwner,
ISurveyElement,
IProgressInfo,
IFindElement,
ISurveyLayoutElement,
IPlainDataOptions,
LayoutElementContainer,
IValueItemCustomPropValues,
ILoadFromJSONOptions
} from "./base-interfaces";
import { SurveyElementCore, SurveyElement } from "./survey-element";
import { surveyCss } from "./defaultCss/defaultV2Css";
import { ISurveyTriggerOwner, SurveyTrigger, Trigger } from "./trigger";
import { CalculatedValue } from "./calculatedValue";
import { PageModel } from "./page";
import { TextPreProcessor, TextPreProcessorValue } from "./textPreProcessor";
import { ProcessValue } from "./conditionProcessValue";
import { dxSurveyService } from "./dxSurveyService";
import { surveyLocalization } from "./surveyStrings";
import { CustomError } from "./error";
import { LocalizableString } from "./localizablestring";
import { StylesManager } from "./stylesmanager";
import { SurveyTimerModel, ISurveyTimerText } from "./surveyTimerModel";
import { IQuestionPlainData, Question } from "./question";
import { QuestionSelectBase } from "./question_baseselect";
import { ItemValue } from "./itemvalue";
import { PanelModelBase, PanelModel, QuestionRowModel } from "./panel";
import {
HtmlConditionItem,
UrlConditionItem,
ExpressionItem,
} from "./expressionItems";
import { ExpressionRunner, ConditionRunner } from "./conditions";
import { settings } from "./settings";
import { isContainerVisible, isMobile, mergeValues, scrollElementByChildId, navigateToUrl, getRenderedStyleSize, getRenderedSize, wrapUrlForBackgroundImage, chooseFiles } from "./utils/utils";
import { SurveyError } from "./survey-error";
import { IAction, Action } from "./actions/action";
import { ActionContainer } from "./actions/container";
import { CssClassBuilder } from "./utils/cssClassBuilder";
import { QuestionPanelDynamicModel } from "./question_paneldynamic";
import { Notifier } from "./notifier";
import {
TriggerExecutedEvent, CompletingEvent, CompleteEvent, ShowingPreviewEvent, NavigateToUrlEvent, CurrentPageChangingEvent, CurrentPageChangedEvent,
ValueChangingEvent, ValueChangedEvent, VariableChangedEvent, QuestionVisibleChangedEvent, PageVisibleChangedEvent, PanelVisibleChangedEvent, QuestionCreatedEvent,
QuestionAddedEvent, QuestionRemovedEvent, PanelAddedEvent, PanelRemovedEvent, PageAddedEvent, ValidateQuestionEvent, SettingQuestionErrorsEvent, ValidatePanelEvent,
ErrorCustomTextEvent, ValidatedErrorsOnCurrentPageEvent, ProcessHtmlEvent, GetQuestionTitleEvent, GetTitleTagNameEvent, GetQuestionNoEvent, ProgressTextEvent,
TextMarkdownEvent, TextRenderAsEvent, SendResultEvent, GetResultEvent, UploadFilesEvent, DownloadFileEvent, ClearFilesEvent, LoadChoicesFromServerEvent,
ProcessTextValueEvent, UpdateQuestionCssClassesEvent, UpdatePanelCssClassesEvent, UpdatePageCssClassesEvent, UpdateChoiceItemCssEvent, AfterRenderSurveyEvent,
AfterRenderHeaderEvent, AfterRenderPageEvent, AfterRenderQuestionEvent, AfterRenderQuestionInputEvent, AfterRenderPanelEvent, FocusInQuestionEvent, FocusInPanelEvent,
ShowingChoiceItemEvent, ChoicesLazyLoadEvent, GetChoiceDisplayValueEvent, MatrixRowAddedEvent, MatrixBeforeRowAddedEvent, MatrixRowRemovingEvent, MatrixRowRemovedEvent,
MatrixAllowRemoveRowEvent, MatrixDetailPanelVisibleChangedEvent, MatrixCellCreatingEvent, MatrixCellCreatedEvent, MatrixAfterCellRenderEvent, MatrixCellValueChangedEvent,
MatrixCellValueChangingEvent, MatrixCellValidateEvent, DynamicPanelModifiedEvent, DynamicPanelRemovingEvent, TimerPanelInfoTextEvent, DynamicPanelItemValueChangedEvent,
DynamicPanelGetTabTitleEvent, DynamicPanelCurrentIndexChangedEvent, IsAnswerCorrectEvent, DragDropAllowEvent, ScrollingElementToTopEvent, GetQuestionTitleActionsEvent,
GetPanelTitleActionsEvent, GetPageTitleActionsEvent, GetPanelFooterActionsEvent, GetMatrixRowActionsEvent, ElementContentVisibilityChangedEvent, GetExpressionDisplayValueEvent,
ServerValidateQuestionsEvent, MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent, ChoicesSearchEvent, OpenFileChooserEvent
} from "./survey-events-api";
import { QuestionMatrixDropdownModelBase } from "./question_matrixdropdownbase";
import { QuestionMatrixDynamicModel } from "./question_matrixdynamic";
import { QuestionFileModel, QuestionFileModelBase } from "./question_file";
import { QuestionMultipleTextModel } from "./question_multipletext";
import { ITheme, ImageFit, ImageAttachment } from "./themes";
import { PopupModel } from "./popup";
import { Cover } from "./header";
import { surveyTimerFunctions } from "./surveytimer";
import { QuestionSignaturePadModel } from "./question_signaturepad";
import { SurveyTaskManagerModel } from "./surveyTaskManager";
import { ProgressButtons } from "./progress-buttons";
import { TOCModel } from "./surveyToc";
import { DomDocumentHelper, DomWindowHelper } from "./global_variables_utils";
/**
* The `SurveyModel` object contains properties and methods that allow you to control the survey and access its elements.
*
* [View Demo](https://surveyjs.io/form-library/examples/nps-question/ (linkStyle))
*/
export class SurveyModel extends SurveyElementCore
implements
ISurvey,
ISurveyData,
ISurveyImpl,
ISurveyTriggerOwner,
ISurveyErrorOwner,
ISurveyTimerText {
public static readonly TemplateRendererComponentName: string =
"sv-template-renderer";
public static get cssType(): string {
return surveyCss.currentType;
}
public static set cssType(value: string) {
StylesManager.applyTheme(value);
}
[index: string]: any;
private static stylesManager: StylesManager = null;
public static platform: string = "unknown";
public get platformName(): string {
return SurveyModel.platform;
}
public notifier: Notifier;
public rootElement: HTMLElement;
/**
* A suffix added to the name of the property that stores comments.
*
* Default value: "-Comment"
*
* Many question types allow respondents to leave comments. To enable this functionality, set a question's [`showCommentArea`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#showCommentArea) property to `true`. Comment values are saved in a separate property. The property name is composed of the question `name` and `commentSuffix`.
*
* Respondents can also leave comments when they select "Other" in choice-based questions, such as Dropdown or Checkboxes. The property name for the comment value is composed according to the same rules. However, you can use the question `name` as a key to store the comment value instead. Disable the [`storeOthersAsComment`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#storeOthersAsComment) property in this case.
*
* [View Demo](https://surveyjs.io/form-library/examples/create-checkboxes-question-in-javascript/ (linkStyle))
*/
public get commentSuffix(): string {
return settings.commentSuffix;
}
public set commentSuffix(val: string) {
settings.commentSuffix = val;
}
public get commentPrefix(): string {
return this.commentSuffix;
}
public set commentPrefix(val: string) {
this.commentSuffix = val;
}
private valuesHash: HashTable<any> = {};
private variablesHash: HashTable<any> = {};
private editingObjValue: Base;
private timerModelValue: SurveyTimerModel;
private navigationBarValue: ActionContainer;
//#region Event declarations
/**
* An event that is raised after a [trigger](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#triggers) is executed.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [Conditional Survey Logic (Triggers)](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-survey-logic-triggers (linkStyle)).
* @see triggers
* @see runTriggers
*/
public onTriggerExecuted: EventBase<SurveyModel, TriggerExecutedEvent> = this.addEvent<SurveyModel, TriggerExecutedEvent>();
/**
* An event that is raised before the survey is completed. Use this event to prevent survey completion.
* @see onComplete
* @see doComplete
* @see allowCompleteSurveyAutomatic
*/
public onCompleting: EventBase<SurveyModel, CompletingEvent> = this.addEvent<SurveyModel, CompletingEvent>();
/**
* An event that is raised after the survey is completed. Use this event to send survey results to the server.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* For an example of how to use the methods described above, refer to the following help topic: [Store Survey Results in Your Own Database](https://surveyjs.io/form-library/documentation/handle-survey-results-store#store-survey-results-in-your-own-database).
*
* > Do not disable the [`showCompletedPage`](https://surveyjs.io/form-library/documentation/surveymodel#showCompletedPage) property if you call one of the `options.showSave...` methods. This is required because the UI that indicates data saving progress is integrated into the complete page. If you hide the complete page, the UI also becomes invisible.
* @see onPartialSend
* @see doComplete
* @see allowCompleteSurveyAutomatic
*/
public onComplete: EventBase<SurveyModel, CompleteEvent> = this.addEvent<SurveyModel, CompleteEvent>();
/**
* An event that is raised before the survey displays a [preview of given answers](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#preview-page). Use this event to cancel the preview.
* @see showPreviewBeforeComplete
* @see showPreview
* @see cancelPreview
*/
public onShowingPreview: EventBase<SurveyModel, ShowingPreviewEvent> = this.addEvent<SurveyModel, ShowingPreviewEvent>();
/**
* An event that is raised before the survey navigates to a specified URL. Use this event to change the URL or cancel the navigation.
* @see navigateToUrl
* @see navigateToUrlOnCondition
*/
public onNavigateToUrl: EventBase<SurveyModel, NavigateToUrlEvent> = this.addEvent<SurveyModel, NavigateToUrlEvent>();
/**
* An event that is raised when the survey [`state`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#state) changes to `"running"`.
* @see firstPageIsStarted
*/
public onStarted: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
/**
* An event that is raised to save incomplete survey results. Enable the [`sendResultOnPageNext`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#sendResultOnPageNext) property for this event to occur.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* Alternatively, you can handle the [`onCurrentPageChanged`](#onCurrentPageChanged) and [`onValueChanged`](#onValueChanged) events, as shown in the following demo: [Continue an Incomplete Survey](https://surveyjs.io/form-library/examples/survey-editprevious/).
*/
public onPartialSend: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
/**
* An event that is raised before the current page is switched.
*
* @see currentPageNo
* @see nextPage
* @see prevPage
**/
public onCurrentPageChanging: EventBase<SurveyModel, CurrentPageChangingEvent> = this.addEvent<SurveyModel, CurrentPageChangingEvent>();
/**
* An event that is raised after the current page is switched.
*
* @see currentPageNo
* @see nextPage
* @see prevPage
*/
public onCurrentPageChanged: EventBase<SurveyModel, CurrentPageChangedEvent> = this.addEvent<SurveyModel, CurrentPageChangedEvent>();
/**
* An event that is raised before a question value is changed.
* @see setValue
*/
public onValueChanging: EventBase<SurveyModel, ValueChangingEvent> = this.addEvent<SurveyModel, ValueChangingEvent>();
/**
* An event that is raised after a question value is changed.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* To handle value changes in matrix cells or panels within a [Dynamic Panel](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model), use the [`onMatrixCellValueChanged`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixCellValueChanged) or [`onDynamicPanelItemValueChanged`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onDynamicPanelItemValueChanged) event.
* @see setValue
*/
public onValueChanged: EventBase<SurveyModel, ValueChangedEvent> = this.addEvent<SurveyModel, ValueChangedEvent>();
/**
* An event that is raised after a [variable](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#variables) or [calculated value](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#calculated-values) is changed.
*
* @see setVariable
* @see calculatedValues
*/
public onVariableChanged: EventBase<SurveyModel, VariableChangedEvent> = this.addEvent<SurveyModel, VariableChangedEvent>();
/**
* An event that is raised after question visibility is changed.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
*/
public onQuestionVisibleChanged: EventBase<SurveyModel, QuestionVisibleChangedEvent> = this.addEvent<SurveyModel, QuestionVisibleChangedEvent>();
public onVisibleChanged: EventBase<SurveyModel, any> = this.onQuestionVisibleChanged;
/**
* An event that is raised after page visibility is changed.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
*/
public onPageVisibleChanged: EventBase<SurveyModel, PageVisibleChangedEvent> = this.addEvent<SurveyModel, PageVisibleChangedEvent>();
/**
* An event that is raised after panel visibility is changed.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
*/
public onPanelVisibleChanged: EventBase<SurveyModel, PanelVisibleChangedEvent> = this.addEvent<SurveyModel, PanelVisibleChangedEvent>();
/**
* An event that is raised when the survey creates any new object derived from [`Question`](https://surveyjs.io/form-library/documentation/api-reference/question).
*
* In a survey, complex elements ([Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/), [Multiple Text](https://surveyjs.io/form-library/examples/questiontype-multipletext/), and [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/)) are composed of questions. Use this event to customize any question regardless of which survey element it belongs to.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
*
* ```js
* import { Model } from "survey-core";
*
* const surveyJson = {
* // ...
* };
* // Create an empty model
* const survey = new Model();
* // Add an event handler
* survey.onQuestionCreated.add((sender, options) => {
* //...
* });
* // Load the survey JSON schema
* survey.fromJSON(surveyJson);
* ```
* @see onQuestionAdded
*/
public onQuestionCreated: EventBase<SurveyModel, QuestionCreatedEvent> = this.addEvent<SurveyModel, QuestionCreatedEvent>();
/**
* An event that is raised when a new question is added to a panel or page.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
*
* ```js
* import { Model } from "survey-core";
*
* const surveyJson = {
* // ...
* };
* // Create an empty model
* const survey = new Model();
* // Add an event handler
* survey.onQuestionAdded.add((sender, options) => {
* //...
* });
* // Load the survey JSON schema
* survey.fromJSON(surveyJson);
* ```
* @see onQuestionCreated
*/
public onQuestionAdded: EventBase<SurveyModel, QuestionAddedEvent> = this.addEvent<SurveyModel, QuestionAddedEvent>();
/**
* An event that is raised after a question is deleted from the survey.
*/
public onQuestionRemoved: EventBase<SurveyModel, QuestionRemovedEvent> = this.addEvent<SurveyModel, QuestionRemovedEvent>();
/**
* An event that is raised when a new panel is added to a page.
*/
public onPanelAdded: EventBase<SurveyModel, PanelAddedEvent> = this.addEvent<SurveyModel, PanelAddedEvent>();
/**
* An event that is raised after a panel is deleted from the survey.
*/
public onPanelRemoved: EventBase<SurveyModel, PanelRemovedEvent> = this.addEvent<SurveyModel, PanelRemovedEvent>();
/**
* An event that is raised when a new page is added to the survey.
* @see PanelModel
*/
public onPageAdded: EventBase<SurveyModel, PageAddedEvent> = this.addEvent<SurveyModel, PageAddedEvent>();
/**
* An event that is raised when a question value is being validated. Use this event to specify a custom error message.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/add-custom-input-validation/ (linkStyle))
* @see onServerValidateQuestions
* @see onValidatePanel
* @see onMatrixCellValidate
* @see onSettingQuestionErrors
*/
public onValidateQuestion: EventBase<SurveyModel, ValidateQuestionEvent> = this.addEvent<SurveyModel, ValidateQuestionEvent>();
/**
* An event that is raised before errors are assigned to a question. Use this event to add/remove/modify errors.
* @see onValidateQuestion
*/
public onSettingQuestionErrors: EventBase<SurveyModel, SettingQuestionErrorsEvent> = this.addEvent<SurveyModel, SettingQuestionErrorsEvent>();
/**
* Use this event to validate data on your server.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/javascript-server-side-form-validation/ (linkStyle))
* @see onValidateQuestion
* @see onValidatePanel
* @see isValidatingOnServer
*/
public onServerValidateQuestions: EventBase<SurveyModel, ServerValidateQuestionsEvent> = this.addEvent<SurveyModel, ServerValidateQuestionsEvent>();
/**
* An event that is raised when a panel is being validated. Use this event to specify a custom error message.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/add-custom-input-validation/ (linkStyle))
* @see onValidateQuestion
* @see onServerValidateQuestions
*/
public onValidatePanel: EventBase<SurveyModel, ValidatePanelEvent> = this.addEvent<SurveyModel, ValidatePanelEvent>();
/**
* An event that is raised to change default error messages.
*/
public onErrorCustomText: EventBase<SurveyModel, ErrorCustomTextEvent> = this.addEvent<SurveyModel, ErrorCustomTextEvent>();
/**
* An event that is raised when the [current page](#currentPage) is being validated. Handle this event to be notified of current page validation.
*/
public onValidatedErrorsOnCurrentPage: EventBase<SurveyModel, ValidatedErrorsOnCurrentPageEvent> = this.addEvent<SurveyModel, ValidatedErrorsOnCurrentPageEvent>();
/**
* An event that is raised when the survey processes HTML content. Handle this event to modify HTML content before displaying.
* @see completedHtml
* @see loadingHtml
* @see QuestionHtmlModel.html
*/
public onProcessHtml: EventBase<SurveyModel, ProcessHtmlEvent> = this.addEvent<SurveyModel, ProcessHtmlEvent>();
/**
* Use this event to change a question's display text.
*/
public onGetQuestionDisplayValue: EventBase<SurveyModel, GetQuestionDisplayValueEvent> = this.addEvent<SurveyModel, GetQuestionDisplayValueEvent>();
/**
* An event that is raised before the survey displays a question title. Handle this event to modify question titles.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* If you want to modify question numbers, handle the [`onGetQuestionNo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onGetQuestionNo) event.
* @see requiredText
*/
public onGetQuestionTitle: EventBase<SurveyModel, GetQuestionTitleEvent> = this.addEvent<SurveyModel, GetQuestionTitleEvent>();
/**
* An event that is raised when the survey calculates heading levels (`<h1>`, `<h2>`, etc.) for a survey, page, panel, and question title. Handle this event to change the heading level of individual titles.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* If you want to specify heading levels for all titles, use the [`titleTags`](https://surveyjs.io/form-library/documentation/api-reference/settings#titleTags) object in [global settings](https://surveyjs.io/form-library/documentation/api-reference/settings).
*
* [View Demo](https://surveyjs.io/form-library/examples/survey-titletagnames/ (linkStyle))
* @see onGetQuestionTitle
* @see onGetQuestionNo
*/
public onGetTitleTagName: EventBase<SurveyModel, GetTitleTagNameEvent> = this.addEvent<SurveyModel, GetTitleTagNameEvent>();
/**
* An event that is raised before the survey calculates a question number. Handle this event to modify question numbers.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* If you want to hide question numbers, disable the [`showQuestionNumbers`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showQuestionNumbers) property.
* @see onGetQuestionTitle
* @see questionStartIndex
*/
public onGetQuestionNo: EventBase<SurveyModel, GetQuestionNoEvent> = this.addEvent<SurveyModel, GetQuestionNoEvent>();
/**
* An event that is raised before the survey displays progress text. Handle this event to change the progress text in code.
* @see showProgressBar
* @see progressBarType
*/
public onProgressText: EventBase<SurveyModel, ProgressTextEvent> = this.addEvent<SurveyModel, ProgressTextEvent>();
/**
* An event that is raised to convert Markdown content to HTML.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/ (linkStyle))
*/
public onTextMarkdown: EventBase<SurveyModel, TextMarkdownEvent> = this.addEvent<SurveyModel, TextMarkdownEvent>();
public onTextRenderAs: EventBase<SurveyModel, TextRenderAsEvent> = this.addEvent<SurveyModel, TextRenderAsEvent>();
/**
* An event that is raised after a request to save survey results on [SurveyJS Service](https://api.surveyjs.io/) has been completed. Use this event to find out if the results have been saved successfully.
*/
public onSendResult: EventBase<SurveyModel, SendResultEvent> = this.addEvent<SurveyModel, SendResultEvent>();
/**
* An event that is raised when the [`getResult(resultId, questionName)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#getResult) method is called. Use this event to obtain answers to an individual question from [SurveyJS Service](https://api.surveyjs.io/).
* @see getResult
*/
public onGetResult: EventBase<SurveyModel, GetResultEvent> = this.addEvent<SurveyModel, GetResultEvent>();
/**
* An event that is raised when Survey Creator opens a dialog window for users to select files.
* @see onUploadFile
* @see uploadFiles
*/
public onOpenFileChooser: EventBase<SurveyModel, OpenFileChooserEvent> = this.addEvent<SurveyModel, OpenFileChooserEvent>();
/**
* An event that is raised when a File Upload or Signature Pad question starts to upload a file. Applies only if [`storeDataAsText`](https://surveyjs.io/form-library/documentation/api-reference/file-model#storeDataAsText) is `false`. Use this event to upload files to your server.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/file-upload/ (linkStyle))
* @see uploadFiles
* @see onDownloadFile
* @see onClearFiles
*/
public onUploadFiles: EventBase<SurveyModel, UploadFilesEvent> = this.addEvent<SurveyModel, UploadFilesEvent>();
/**
* An event that is raised when a File Upload question starts to download a file. Use this event to implement file preview when your server stores only file names.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/store-file-names-in-survey-results/ (linkStyle))
* @see downloadFile
* @see onClearFiles
* @see onUploadFiles
*/
public onDownloadFile: EventBase<SurveyModel, DownloadFileEvent> = this.addEvent<SurveyModel, DownloadFileEvent>();
/**
* An event that is raised when users clear files in a [File Upload](https://surveyjs.io/form-library/documentation/api-reference/file-model) question or clear signature in a [Signature Pad](https://surveyjs.io/form-library/documentation/api-reference/signature-pad-model) question. Use this event to delete files from your server.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/file-delayed-upload/ (linkStyle))
* @see clearFiles
* @see onDownloadFile
* @see onUploadFiles
*/
public onClearFiles: EventBase<SurveyModel, ClearFilesEvent> = this.addEvent<SurveyModel, ClearFilesEvent>();
/**
* An event that is raised after choices are loaded from a server but before they are assigned to a choice-based question, such as [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) or [Checkboxes](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model). Handle this event if you need to modify the loaded choices.
*/
public onLoadChoicesFromServer: EventBase<SurveyModel, LoadChoicesFromServerEvent> = this.addEvent<SurveyModel, LoadChoicesFromServerEvent>();
/**
* An event that is raised after a survey JSON schema is loaded from the [SurveyJS Service](https://api.surveyjs.io). Use this event to modify the loaded schema.
* @see surveyId
* @see clientId
* @see loadSurveyFromService
*/
public onLoadedSurveyFromService: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
/**
* An event that is raised when the survey processes [dynamic texts](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#dynamic-texts) and any text in curly brackets. Use this event, for instance, to substitute parameters in a RESTful URL with real values when you [load choices by URL](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#choicesByUrl).
*/
public onProcessTextValue: EventBase<SurveyModel, ProcessTextValueEvent> = this.addEvent<SurveyModel, ProcessTextValueEvent>();
/**
* An event that is raised before rendering a question. Use it to override default question CSS classes.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
* @see css
*/
public onUpdateQuestionCssClasses: EventBase<SurveyModel, UpdateQuestionCssClassesEvent> = this.addEvent<SurveyModel, UpdateQuestionCssClassesEvent>();
/**
* An event that is raised before rendering a standalone panel and panels within [Dynamic Panel](https://surveyjs.io/form-library/examples/duplicate-group-of-fields-in-form/). Use it to override default panel CSS classes.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
* @see css
*/
public onUpdatePanelCssClasses: EventBase<SurveyModel, UpdatePanelCssClassesEvent> = this.addEvent<SurveyModel, UpdatePanelCssClassesEvent>();
/**
* An event that is raised before rendering a page. Use it to override default page CSS classes.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
* @see css
*/
public onUpdatePageCssClasses: EventBase<SurveyModel, UpdatePageCssClassesEvent> = this.addEvent<SurveyModel, UpdatePageCssClassesEvent>();
/**
* An event that is raised before rendering a choice item in Radio Button Group, Checkboxes, and Dropdown questions. Use it to override default CSS classes applied to choice items.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
* @see css
*/
public onUpdateChoiceItemCss: EventBase<SurveyModel, UpdateChoiceItemCssEvent> = this.addEvent<SurveyModel, UpdateChoiceItemCssEvent>();
/**
* An event that is raised after the survey is rendered to the DOM. Use this event to modify survey markup.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/survey-animation/ (linkStyle))
*/
public onAfterRenderSurvey: EventBase<SurveyModel, AfterRenderSurveyEvent> = this.addEvent<SurveyModel, AfterRenderSurveyEvent>();
public onAfterRenderHeader: EventBase<SurveyModel, AfterRenderHeaderEvent> = this.addEvent<SurveyModel, AfterRenderHeaderEvent>();
/**
* An event that is raised after a page is rendered to the DOM. Use it to modify page markup.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/survey-afterrender/ (linkStyle))
*/
public onAfterRenderPage: EventBase<SurveyModel, AfterRenderPageEvent> = this.addEvent<SurveyModel, AfterRenderPageEvent>();
/**
* An event that is raised after a question is rendered to the DOM. Use it to modify question markup.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/survey-afterrender/ (linkStyle))
*/
public onAfterRenderQuestion: EventBase<SurveyModel, AfterRenderQuestionEvent> = this.addEvent<SurveyModel, AfterRenderQuestionEvent>();
/**
* An event that is raised after a question with a single input field is rendered to the DOM. Use it to modify question markup.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* > This event is not raised for questions without input fields ([HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel), [Image](https://surveyjs.io/form-library/documentation/questionimagemodel)) or questions with multiple input fields ([Matrix](https://surveyjs.io/form-library/documentation/questionmatrixmodel), [Multiple Text](https://surveyjs.io/form-library/documentation/questionmultipletextmodel)).
*/
public onAfterRenderQuestionInput: EventBase<SurveyModel, AfterRenderQuestionInputEvent> = this.addEvent<SurveyModel, AfterRenderQuestionInputEvent>();
/**
* An event that is raised after a panel is rendered to the DOM. Use it to modify panel markup.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* > This event is raised for static [Panels](https://surveyjs.io/form-library/examples/set-properties-on-multiple-questions-using-panel/) as well as panels within a [Dynamic Panel](https://surveyjs.io/form-library/examples/duplicate-group-of-fields-in-form/).
*/
public onAfterRenderPanel: EventBase<SurveyModel, AfterRenderPanelEvent> = this.addEvent<SurveyModel, AfterRenderPanelEvent>();
/**
* An event that is raised when an element (input field, checkbox, radio button) within a question gets focus.
* @see onFocusInPanel
* @see focusFirstQuestionAutomatic
* @see focusQuestion
*/
public onFocusInQuestion: EventBase<SurveyModel, FocusInQuestionEvent> = this.addEvent<SurveyModel, FocusInQuestionEvent>();
/**
* An event that is raised when an element within a panel gets focus.
* @see onFocusInQuestion
* @see focusFirstQuestionAutomatic
* @see focusQuestion
*/
public onFocusInPanel: EventBase<SurveyModel, FocusInPanelEvent> = this.addEvent<SurveyModel, FocusInPanelEvent>();
/**
* An event that is raised before a [choice item](https://surveyjs.io/form-library/documentation/api-reference/questionselectbase#choices) is displayed. Use this event to change the visibility of individual choice items in [Checkboxes](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model), [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model), [Radio Button Group](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model), and other similar question types.
*/
public onShowingChoiceItem: EventBase<SurveyModel, ShowingChoiceItemEvent> = this.addEvent<SurveyModel, ShowingChoiceItemEvent>();
/**
* Use this event to load choice items in [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel) and [Tag Box](https://surveyjs.io/form-library/documentation/questiontagboxmodel) questions on demand.
*
* This event is raised only for those questions that have the [`choicesLazyLoadEnabled`](https://surveyjs.io/form-library/documentation/questiondropdownmodel#choicesLazyLoadEnabled) property set to `true`.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/lazy-loading-dropdown/ (linkStyle))
*/
public onChoicesLazyLoad: EventBase<SurveyModel, ChoicesLazyLoadEvent> = this.addEvent<SurveyModel, ChoicesLazyLoadEvent>();
/**
* An event that is raised each time a search string in a [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) or [Tag Box](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model) question changes. Use this event to implement custom filtering of choice options.
* @see [QuestionDropdownModel.searchEnabled](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model#searchEnabled)
* @see [QuestionDropdownModel.searchMode](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model#searchMode)
*/
public onChoicesSearch: EventBase<SurveyModel, ChoicesSearchEvent> = this.addEvent<SurveyModel, ChoicesSearchEvent>();
/**
* Use this event to load a display text for the [default choice item](https://surveyjs.io/form-library/documentation/questiondropdownmodel#defaultValue) in [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel) and [Tag Box](https://surveyjs.io/form-library/documentation/questiontagboxmodel) questions.
*
* If you load choices from a server (use [`choicesByUrl`](https://surveyjs.io/form-library/documentation/questiondropdownmodel#choicesByUrl) or [`onChoicesLazyLoad`](https://surveyjs.io/form-library/documentation/surveymodel#onChoicesLazyLoad)), display texts become available only when data is loaded, which does not happen until a user opens the drop-down menu. However, a display text for a default choice item is required before that. In this case, you can load data individually for the default item within the `onGetChoiceDisplayValue` event handler.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/lazy-loading-dropdown/ (linkStyle))
*/
public onGetChoiceDisplayValue: EventBase<SurveyModel, GetChoiceDisplayValueEvent> = this.addEvent<SurveyModel, GetChoiceDisplayValueEvent>();
/**
* An event that is raised after a new row is added to a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
*/
public onMatrixRowAdded: EventBase<SurveyModel, MatrixRowAddedEvent> = this.addEvent<SurveyModel, MatrixRowAddedEvent>();
/**
* An event that is raised before a new row is added to a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
*/
public onMatrixRowAdding: EventBase<SurveyModel, MatrixBeforeRowAddedEvent> = this.addEvent<SurveyModel, MatrixBeforeRowAddedEvent>();
/**
* This event is obsolete. Use the [`onMatrixRowAdding`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixRowAdding) event instead.
*/
public onMatrixBeforeRowAdded: EventBase<SurveyModel, MatrixBeforeRowAddedEvent> = this.onMatrixRowAdding;
/**
* An event that is raised before a row is deleted from a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). You can cancel row deletion and clear row data instead.
* @see onMatrixRenderRemoveButton
*/
public onMatrixRowRemoving: EventBase<SurveyModel, MatrixRowRemovingEvent> = this.addEvent<SurveyModel, MatrixRowRemovingEvent>();
/**
* An event that is raised after a row is deleted from a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
* @see onMatrixRenderRemoveButton
*/
public onMatrixRowRemoved: EventBase<SurveyModel, MatrixRowRemovedEvent> = this.addEvent<SurveyModel, MatrixRowRemovedEvent>();
/**
* An event that is raised before rendering the Remove button in a row of a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). Use this event to hide the Remove button for individual matrix rows.
* @see onMatrixRowRemoving
* @see onMatrixRowRemoved
*/
public onMatrixRenderRemoveButton: EventBase<SurveyModel, MatrixAllowRemoveRowEvent> = this.addEvent<SurveyModel, MatrixAllowRemoveRowEvent>();
/**
* This event is obsolete. Use the [`onMatrixRenderRemoveButton`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixRenderRemoveButton) event instead.
*/
public onMatrixAllowRemoveRow: EventBase<SurveyModel, MatrixAllowRemoveRowEvent> = this.onMatrixRenderRemoveButton;
/**
* An event that is raised after the visibility of an [expandable detail section](https://surveyjs.io/form-library/examples/add-expandable-details-section-under-matrix-rows/) is changed. This event can be raised for [Multi-Select](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) and [Dynamic Matrix](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model) questions.
*/
public onMatrixDetailPanelVisibleChanged: EventBase<SurveyModel, MatrixDetailPanelVisibleChangedEvent> = this.addEvent<SurveyModel, MatrixDetailPanelVisibleChangedEvent>();
/**
* An event that is raised before a cell in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) is created. Use this event to change the type of individual matrix cells.
* @see onAfterRenderMatrixCell
*/
public onMatrixCellCreating: EventBase<SurveyModel, MatrixCellCreatingEvent> = this.addEvent<SurveyModel, MatrixCellCreatingEvent>();
/**
* An event that is raised after a cell in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) is created.
* @see onAfterRenderMatrixCell
*/
public onMatrixCellCreated: EventBase<SurveyModel, MatrixCellCreatedEvent> = this.addEvent<SurveyModel, MatrixCellCreatedEvent>();
/**
* An event that is raised for every matrix cell after it is rendered to the DOM.
* @see onMatrixCellCreated
*/
public onAfterRenderMatrixCell: EventBase<SurveyModel, MatrixAfterCellRenderEvent> = this.addEvent<SurveyModel, MatrixAfterCellRenderEvent>();
/**
* This event is obsolete. Use the [`onAfterRenderMatrixCell`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onAfterRenderMatrixCell) event instead.
*/
public onMatrixAfterCellRender: EventBase<SurveyModel, MatrixAfterCellRenderEvent> = this.onAfterRenderMatrixCell;
/**
* An event that is raised after a cell value is changed in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
* @see onMatrixRowAdding
*/
public onMatrixCellValueChanged: EventBase<SurveyModel, MatrixCellValueChangedEvent> = this.addEvent<SurveyModel, MatrixCellValueChangedEvent>();
/**
* An event that is raised before a cell value is changed in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). Use this event to change the cell value.
* @see onMatrixRowAdding
*/
public onMatrixCellValueChanging: EventBase<SurveyModel, MatrixCellValueChangingEvent> = this.addEvent<SurveyModel, MatrixCellValueChangingEvent>();
/**
* An event that is raised for [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) and [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) questions when they validate a cell value. Use this event to display a custom error message based on a condition.
* @see onMatrixRowAdding
*/
public onMatrixCellValidate: EventBase<SurveyModel, MatrixCellValidateEvent> = this.addEvent<SurveyModel, MatrixCellValidateEvent>();
/**
* An event that is raised after a new column is added to a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
*/
public onMatrixColumnAdded: EventBase<SurveyModel, MatrixColumnAddedEvent> = this.addEvent<SurveyModel, MatrixColumnAddedEvent>();
/**
* An event that is raised on adding a new item in Multiple Text question.
*/
public onMultipleTextItemAdded: EventBase<SurveyModel, MultipleTextItemAddedEvent> = this.addEvent<SurveyModel, MultipleTextItemAddedEvent>();
/**
* An event that is raised after a new panel is added to a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
*/
public onDynamicPanelAdded: EventBase<SurveyModel, DynamicPanelModifiedEvent> = this.addEvent<SurveyModel, DynamicPanelModifiedEvent>();
/**
* An event that is raised after a panel is deleted from a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
*/
public onDynamicPanelRemoved: EventBase<SurveyModel, DynamicPanelModifiedEvent> = this.addEvent<SurveyModel, DynamicPanelModifiedEvent>();
/**
* An event that is raised before a panel is deleted from a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question. Use this event to cancel the deletion.
*/
public onDynamicPanelRemoving: EventBase<SurveyModel, DynamicPanelRemovingEvent> = this.addEvent<SurveyModel, DynamicPanelRemovingEvent>();
/**
* An event that is raised every second while the timer is running.
*
* Use the [`timeSpent`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#timeSpent) property to find out how many seconds have elapsed.
* @see maxTimeToFinish
* @see maxTimeToFinishPage
* @see showTimerPanel
* @see startTimer
*/
public onTimer: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
public onTimerPanelInfoText: EventBase<SurveyModel, TimerPanelInfoTextEvent> = this.addEvent<SurveyModel, TimerPanelInfoTextEvent>();
/**
* An event that is raised after an item value is changed in a panel within a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
*/
public onDynamicPanelItemValueChanged: EventBase<SurveyModel, DynamicPanelItemValueChangedEvent> = this.addEvent<SurveyModel, DynamicPanelItemValueChangedEvent>();
/**
* An event that is raised before a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) renders [tab titles](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#templateTabTitle). Use this event to change individual tab titles.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/tabbed-interface-for-duplicate-group-option/ (linkStyle))
*/
public onGetDynamicPanelTabTitle: EventBase<SurveyModel, DynamicPanelGetTabTitleEvent> = this.addEvent<SurveyModel, DynamicPanelGetTabTitleEvent>();
/**
* An event that is raised after the current panel is changed in a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
*/
public onDynamicPanelCurrentIndexChanged: EventBase<SurveyModel, DynamicPanelCurrentIndexChangedEvent> = this.addEvent<SurveyModel, DynamicPanelCurrentIndexChangedEvent>();
/**
* An event that is raised to define whether a question answer is correct. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
*/
public onIsAnswerCorrect: EventBase<SurveyModel, IsAnswerCorrectEvent> = this.addEvent<SurveyModel, IsAnswerCorrectEvent>();
/**
* An event that is raised when users drag and drop survey elements while designing the survey in [Survey Creator](https://surveyjs.io/survey-creator/documentation/overview). Use this event to control drag and drop operations.
* @see isDesignMode
*/
public onDragDropAllow: EventBase<SurveyModel, DragDropAllowEvent> = this.addEvent<SurveyModel, DragDropAllowEvent>();
/**
* An event this is raised before a survey element (usually page) is scrolled to the top. Use this event to cancel the scroll operation.
*/
public onScrollingElementToTop: EventBase<SurveyModel, ScrollingElementToTopEvent> = this.addEvent<SurveyModel, ScrollingElementToTopEvent>();
public onLocaleChangedEvent: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
/**
* An event that allows you to add, delete, or modify actions in a question title.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/survey-titleactions/ (linkStyle))
* @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
*/
public onGetQuestionTitleActions: EventBase<SurveyModel, GetQuestionTitleActionsEvent> = this.addEvent<SurveyModel, GetQuestionTitleActionsEvent>();
/**
* An event that allows you to add, delete, or modify actions in a panel title.
* @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
*/
public onGetPanelTitleActions: EventBase<SurveyModel, GetPanelTitleActionsEvent> = this.addEvent<SurveyModel, GetPanelTitleActionsEvent>();
/**
* An event that allows you to add, delete, or modify actions in a page title.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/modify-titles-of-survey-elements/ (linkStyle))
* @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
*/
public onGetPageTitleActions: EventBase<SurveyModel, GetPageTitleActionsEvent> = this.addEvent<SurveyModel, GetPageTitleActionsEvent>();
/**
* An event that allows you to add, delete, or modify actions in the footer of a [Panel](https://surveyjs.io/form-library/documentation/panelmodel).
* @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
*/
public onGetPanelFooterActions: EventBase<SurveyModel, GetPanelFooterActionsEvent> = this.addEvent<SurveyModel, GetPanelFooterActionsEvent>();
/**
* An event that allows you to add, delete, or modify actions in rows of a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
*
* For information on event handler parameters, refer to descriptions within the interface.
*
* [View Demo](https://surveyjs.io/form-library/examples/employee-information-form/ (linkStyle))
* @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
*/
public onGetMatrixRowActions: EventBase<SurveyModel, GetMatrixRowActionsEvent> = this.addEvent<SurveyModel, GetMatrixRowActionsEvent>();
/**
* An event that is raised after a survey element is [expanded or collapsed](https://surveyjs.io/form-library/documentation/api-reference/question#state).
*/
public onElementContentVisibilityChanged: EventBase<SurveyModel, ElementContentVisibilityChangedEvent> = this.addEvent<SurveyModel, ElementContentVisibilityChangedEvent>();
/**
* An event that is raised before an [Expression](https://surveyjs.io/form-library/documentation/api-reference/expression-model) question displays a value. Use this event to override the display value.
*/
public onGetExpressionDisplayValue: EventBase<SurveyModel, GetExpressionDisplayValueEvent> = this.addEvent<SurveyModel, GetExpressionDisplayValueEvent>();
/**
* An event that is raised after the visibility of a popup is changed. This event can be raised for [Single-](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) and [Multi-Select Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model) questions and [Rating](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model) questions [rendered as drop-down menus](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#displayMode).
*/
public onPopupVisibleChanged: EventBase<SurveyModel, PopupVisibleChangedEvent> = this.addEvent<SurveyModel, PopupVisibleChangedEvent>();
//#endregion
constructor(jsonObj: any = null, renderedElement: any = null) {
super();
if (DomDocumentHelper.isAvailable()) {
SurveyModel.stylesManager = new StylesManager();
}
const htmlCallBack = (str: string): string => { return "<h3>" + str + "</h3>"; };
this.createHtmlLocString("completedHtml", "completingSurvey", htmlCallBack);
this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", htmlCallBack, "completed-before");
this.createHtmlLocString("loadingHtml", "loadingSurvey", htmlCallBack, "loading");
this.createLocalizableString("emptySurveyText", this, true, "emptySurvey");
this.createLocalizableString("logo", this, false);
this.createLocalizableString("startSurveyText", this, false, true);
this.createLocalizableString("pagePrevText", this, false, true);
this.createLocalizableString("pageNextText", this, false, true);
this.createLocalizableString("completeText", this, false, true);
this.createLocalizableString("previewText", this, false, true);
this.createLocalizableString("editText", this, false, true);
this.createLocalizableString("questionTitleTemplate", this, true);
this.timerModelValue = new SurveyTimerModel(this);
this.timerModelValue.onTimer = (page: PageModel): void => {
this.doTimer(page);
};
this.createNewArray(
"pages",
(value: any) => {
this.doOnPageAdded(value);
},
(value: any) => {
this.doOnPageRemoved(value);
}
);
this.createNewArray("triggers", (value: any) => {
value.setOwner(this);
});
this.createNewArray("calculatedValues", (value: any) => {
value.setOwner(this);
});
this.createNewArray("completedHtmlOnCondition", (value: any) => {
value.locOwner = this;
});
this.createNewArray("navigateToUrlOnCondition", (value: any) => {
value.locOwner = this;
});
this.registerPropertyChangedHandlers(["locale"], () => {
this.onSurveyLocaleChanged();
});
this.registerPropertyChangedHandlers(["firstPageIsStarted"], () => {
this.onFirstPageIsStartedChanged();
});
this.registerPropertyChangedHandlers(["mode"], () => {
this.onModeChanged();
});
this.registerPropertyChangedHandlers(["progressBarType"], () => {
this.updateProgressText();
});
this.registerPropertyChangedHandlers(
["questionStartIndex", "requiredText", "questionTitlePattern"],
() => {
this.resetVisibleIndexes();
}
);
this.registerPropertyChangedHandlers(
["isLoading", "isCompleted", "isCompletedBefore", "mode", "isStartedState", "currentPage", "isShowingPreview"],
() => { this.updateState(); });
this.registerPropertyChangedHandlers(["state", "currentPage", "showPreviewBeforeComplete"],
() => { this.onStateAndCurrentPageChanged(); });
this.registerPropertyChangedHandlers(["logo", "logoPosition"], () => { this.updateHasLogo(); });
this.registerPropertyChangedHandlers(["backgroundImage"], () => { this.updateRenderBackgroundImage(); });
this.registerPropertyChangedHandlers(["renderBackgroundImage", "backgroundOpacity", "backgroundImageFit", "fitToContainer", "backgroundImageAttachment"], () => {
this.updateBackgroundImageStyle();
});
this.registerPropertyChangedHandlers(
["showPrevButton", "showCompleteButton"],
() => { this.updateButtonsVisibility(); });
this.onGetQuestionNo.onCallbacksChanged = () => {
this.resetVisibleIndexes();
};
this.onProgressText.onCallbacksChanged = () => {
this.updateProgressText();
};
this.onTextMarkdown.onCallbacksChanged = () => {
this.locStrsChanged();
};
this.onProcessHtml.onCallbacksChanged = () => {
this.locStrsChanged();
};
this.onGetQuestionTitle.onCallbacksChanged = () => {
this.locStrsChanged();
};
this.onUpdatePageCssClasses.onCallbacksChanged = () => {
this.currentPage && this.currentPage.updateElementCss();
};
this.onUpdatePanelCssClasses.onCallbacksChanged = () => {
this.currentPage && this.currentPage.updateElementCss();
};
this.onUpdateQuestionCssClasses.onCallbacksChanged = () => {
this.currentPage && this.currentPage.updateElementCss();
};
this.onShowingChoiceItem.onCallbacksChanged = () => {
this.rebuildQuestionChoices();
};
this.navigationBarValue = this.createNavigationBar();
this.navigationBar.locOwner = this;
this.onBeforeCreating();
if (jsonObj) {
if (typeof jsonObj === "string" || jsonObj instanceof String) {
jsonObj = JSON.parse(jsonObj as string);
}
if (jsonObj && jsonObj.clientId) {
this.clientId = jsonObj.clientId;
}
this.fromJSON(jsonObj);
if (this.surveyId) {
this.loadSurveyFromService(this.surveyId, this.clientId);
}
}
this.onCreating();
if (!!renderedElement) {
this.render(renderedElement);
}
this.updateCss();
this.setCalculatedWidthModeUpdater();
this.notifier = new Notifier(this.css.saveData);
this.notifier.addAction(this.createTryAgainAction(), "error");
this.onPopupVisibleChanged.add((_, opt) => {
if (opt.visible) {
this.onScrollCallback = () => {
opt.popup.toggleVisibility();
};
} else {
this.onScrollCallback = undefined;
}
});
this.progressBarValue = new ProgressButtons(this);
this.layoutElements.push({
id: "timerpanel",
template: "survey-timerpanel",
component: "sv-timerpanel",
data: this.timerModel
});
this.layoutElements.push({
id: "progress-buttons",
component: "sv-progress-buttons",
data: this.progressBar,
processResponsiveness: width => this.progressBar.processResponsiveness && this.progressBar.processResponsiveness(width)
});
this.layoutElements.push({