@@ -85,7 +85,6 @@ import { ProgressButtons } from "./progress-buttons";
8585import { TOCModel } from "./surveyToc" ;
8686import { DomDocumentHelper , DomWindowHelper } from "./global_variables_utils" ;
8787import { ConsoleWarnings } from "./console-warnings" ;
88- import { NavigationActionBar } from "./navigation-bar" ;
8988
9089class SurveyValueGetterContext extends ValueGetterContextCore {
9190 constructor ( private survey : SurveyModel , private valuesHash : HashTable < any > , private variablesHash : HashTable < any > ) {
@@ -1304,8 +1303,7 @@ export class SurveyModel extends SurveyElementCore
13041303 }
13051304 private updateCss ( ) {
13061305 this . rootCss = this . getRootCss ( ) ;
1307- this . navigationBarValue ?. updateCss ( ) ;
1308- this . navigationBarTopValue ?. updateCss ( ) ;
1306+ this . updateNavigationCss ( ) ;
13091307 this . updateCompletedPageCss ( ) ;
13101308 this . updateWrapperFormCss ( ) ;
13111309 }
@@ -1345,6 +1343,45 @@ export class SurveyModel extends SurveyElementCore
13451343 public get bodyContainerCss ( ) : string {
13461344 return this . css . bodyContainer ;
13471345 }
1346+ private get cssNavigationComplete ( ) {
1347+ return this . getNavigationCss (
1348+ this . cssSurveyNavigationButton ,
1349+ this . css . navigation . complete
1350+ ) ;
1351+ }
1352+ private get cssNavigationPreview ( ) {
1353+ return this . getNavigationCss (
1354+ this . cssSurveyNavigationButton ,
1355+ this . css . navigation . preview
1356+ ) ;
1357+ }
1358+ public get cssNavigationEdit ( ) {
1359+ return this . getNavigationCss (
1360+ this . css . navigationButton ,
1361+ this . css . navigation . edit
1362+ ) ;
1363+ }
1364+ private get cssNavigationPrev ( ) {
1365+ return this . getNavigationCss (
1366+ this . cssSurveyNavigationButton ,
1367+ this . css . navigation . prev
1368+ ) ;
1369+ }
1370+ private get cssNavigationStart ( ) {
1371+ return this . getNavigationCss (
1372+ this . cssSurveyNavigationButton ,
1373+ this . css . navigation . start
1374+ ) ;
1375+ }
1376+ private get cssNavigationNext ( ) {
1377+ return this . getNavigationCss (
1378+ this . cssSurveyNavigationButton ,
1379+ this . css . navigation . next
1380+ ) ;
1381+ }
1382+ private get cssSurveyNavigationButton ( ) : string {
1383+ return new CssClassBuilder ( ) . append ( this . css . navigationButton ) . append ( this . css . bodyNavigationButton ) . toString ( ) ;
1384+ }
13481385 @property ( ) completedCss : string ;
13491386 @property ( ) completedBeforeCss : string ;
13501387 @property ( ) loadingBodyCss : string ;
@@ -2200,7 +2237,6 @@ export class SurveyModel extends SurveyElementCore
22002237 this . updateProgressText ( ) ;
22012238 }
22022239 this . navigationBarValue ?. locStrsChanged ( ) ;
2203- this . navigationBarTopValue ?. locStrsChanged ( ) ;
22042240 }
22052241 public getMarkdownHtml ( text : string , name : string , item ?: any ) : string {
22062242 return this . getSurveyMarkdownHtml ( this , text , name , item ) ;
@@ -2639,36 +2675,115 @@ export class SurveyModel extends SurveyElementCore
26392675 . append ( btn ) . toString ( ) ;
26402676 }
26412677
2642- public get cssNavigationEdit ( ) {
2643- return this . getNavigationCss (
2644- this . css . navigationButton ,
2645- this . css . navigation . edit
2646- ) ;
2647- }
2648-
2649- private navigationBarValue : NavigationActionBar ;
2650- public get navigationBar ( ) : NavigationActionBar {
2678+ private navigationBarValue : ActionContainer ;
2679+ public get navigationBar ( ) : ActionContainer {
26512680 if ( ! this . navigationBarValue ) {
26522681 this . navigationBarValue = this . createNavigationBar ( ) ;
2682+ this . navigationBarValue . locOwner = this ;
2683+ this . updateNavigationCss ( ) ;
26532684 }
26542685 return this . navigationBarValue ;
26552686 }
2656- public createNavigationBarCallback : ( ) => NavigationActionBar ;
2657- protected createNavigationBar ( ) : NavigationActionBar {
2687+ public createNavigationBarCallback : ( ) => ActionContainer ;
2688+ protected createNavigationBar ( ) : ActionContainer {
26582689 if ( this . createNavigationBarCallback ) return this . createNavigationBarCallback ( ) ;
2659- return new NavigationActionBar ( this ) ;
2690+ const res = new ActionContainer ( ) ;
2691+ res . setItems ( this . createNavigationActions ( ) ) ;
2692+ return res ;
26602693 }
26612694 /**
26622695 * Adds a custom navigation item similar to the Previous Page, Next Page, and Complete buttons. Accepts an object described in the [IAction](https://surveyjs.io/Documentation/Library?id=IAction) help section.
26632696 *
26642697 * [View Demo](https://surveyjs.io/form-library/examples/survey-changenavigation/ (linkStyle))
26652698 */
26662699 public addNavigationItem ( val : IAction ) : Action {
2700+ if ( ! val . component ) {
2701+ val . component = "sv-nav-btn" ;
2702+ }
2703+ if ( ! val . innerCss ) {
2704+ val . innerCss = this . cssSurveyNavigationButton ;
2705+ }
2706+ const originalActionFunc = val . action ;
2707+ val . action = ( ) => {
2708+ this . waitAndExecute ( ( ) => originalActionFunc ( ) ) ;
2709+ } ;
26672710 return this . navigationBar . addAction ( val ) ;
26682711 }
26692712 private removeNavigationItem ( id : string ) : void {
26702713 this . navigationBarValue ?. removeActionById ( id ) ;
26712714 }
2715+ private _updateNavigationItemCssCallback : ( ) => void ;
2716+ protected createNavigationActions ( ) : Array < IAction > {
2717+ const defaultComponent = "sv-nav-btn" ;
2718+ const navStart = new Action ( {
2719+ id : "sv-nav-start" ,
2720+ visible : < any > new ComputedUpdater < boolean > ( ( ) => this . isStartPageActive ) ,
2721+ visibleIndex : 10 ,
2722+ locTitle : this . locStartSurveyText ,
2723+ action : ( ) => this . start ( ) ,
2724+ component : defaultComponent
2725+ } ) ;
2726+ const navPrev = new Action ( {
2727+ id : "sv-nav-prev" ,
2728+ visible : < any > new ComputedUpdater < boolean > ( ( ) => this . isShowPrevButton ) ,
2729+ visibleIndex : 20 ,
2730+ data : {
2731+ mouseDown : ( ) => this . navigationMouseDown ( ) ,
2732+ } ,
2733+ locTitle : this . locPagePrevText ,
2734+ action : ( ) => this . performPrevious ( ) ,
2735+ component : defaultComponent
2736+ } ) ;
2737+ const navNext = new Action ( {
2738+ id : "sv-nav-next" ,
2739+ visible : < any > new ComputedUpdater < boolean > ( ( ) => this . isShowNextButton ) ,
2740+ visibleIndex : 30 ,
2741+ data : {
2742+ mouseDown : ( ) => this . nextPageMouseDown ( ) ,
2743+ } ,
2744+ locTitle : this . locPageNextText ,
2745+ action : ( ) => this . nextPageUIClick ( ) ,
2746+ component : defaultComponent
2747+ } ) ;
2748+ const navPreview = new Action ( {
2749+ id : "sv-nav-preview" ,
2750+ visible : < any > new ComputedUpdater < boolean > ( ( ) => this . isPreviewButtonVisible ) ,
2751+ visibleIndex : 40 ,
2752+ data : {
2753+ mouseDown : ( ) => this . navigationMouseDown ( ) ,
2754+ } ,
2755+ locTitle : this . locPreviewText ,
2756+ action : ( ) => this . showPreview ( ) ,
2757+ component : defaultComponent
2758+ } ) ;
2759+ const navComplete = new Action ( {
2760+ id : "sv-nav-complete" ,
2761+ visible : < any > new ComputedUpdater < boolean > ( ( ) => this . isCompleteButtonVisible ) ,
2762+ visibleIndex : 50 ,
2763+ data : {
2764+ mouseDown : ( ) => this . navigationMouseDown ( ) ,
2765+ } ,
2766+ locTitle : this . locCompleteText ,
2767+ action : ( ) => this . taskManager . waitAndExecute ( ( ) => this . tryComplete ( ) ) ,
2768+ component : defaultComponent
2769+ } ) ;
2770+ this . _updateNavigationItemCssCallback = ( ) => {
2771+ navStart . innerCss = this . cssNavigationStart ;
2772+ navPrev . innerCss = this . cssNavigationPrev ;
2773+ navNext . innerCss = this . cssNavigationNext ;
2774+ navPreview . innerCss = this . cssNavigationPreview ;
2775+ navComplete . innerCss = this . cssNavigationComplete ;
2776+ } ;
2777+ return [ navStart , navPrev , navNext , navPreview , navComplete ] ;
2778+ }
2779+ private updateNavigationCss ( ) {
2780+ const val = this . navigationBarValue ;
2781+ if ( ! ! val ) {
2782+ val . cssClasses = this . css . actionBar ;
2783+ val . containerCss = this . css . footer ;
2784+ ! ! this . _updateNavigationItemCssCallback && this . _updateNavigationItemCssCallback ( ) ;
2785+ }
2786+ }
26722787 /**
26732788 * Gets or sets a caption for the Start button.
26742789 *
0 commit comments