Navigation System Reference

Table of Contents


Introduction

The MVCS page navigation system consists of three parts: a nav object, a nav controller page, and a Nav Component. The nav object provides methods and properties to control page navigation, the nav page provides state variables and Model computations in support of page navigation, and the Nav Component provides the navigation "chrome" and an area to display the selected page.

Page types

The navigation system manages a page stack, representing a stack of pages from the bottommost to the topmost. All the pages on the stack remain open, but only the topmost one is active. See Page Overview for a description of page open and active states. There are three types of pages:

It is possible for the same page to appear more than once in the stack as one or more popup pages or as a base page and popup pages. Overlay pages typically appear only at the top of the stack.

The navigation system supports two styles of base page navigation:

Navigation style is controlled by setting the value of the nav_style state variable. The position of the tab is controlled by setting the value of the nav_tabFooter state variable.

Dark mode

The normal presentation style is a dark font color on a light background. If the nav_darkMode state variable value is true, then the presentation is a light font color on a dark background.

Initialization

When the application starts up, it specifies the navigation layout by calling ctl.startApp(info). The info.template property includes the Nav component. The Nav component's attributes set the menu layout and initial starting page. Note that it's possible for the application to not use the Nav component, in which case it must provide its own navigation. For example:

ctl.startApp({
	deviceType: deviceType(),
	title: 'Example 1',
	id: 'Example1',
	template: tml`<Nav layout=${['adder', 'set']} startPage=adder />`
});

The nav page provides several state variables that other pages can use to control nav page characteristics or to trigger Model or View actions:

Page histogram

The nav page maintains a special state variable, nav_pageHistogram, that contains a histogram of page opened per session.

Exported identifiers

Syntax

import {nav} from 'common/mvcs/export.js';

The nav object provides methods and properties to control page navigation.


The nav object contains both methods and data properties to control navigation. The methods are:

basePage()

Syntax

nav.basePage(pageId, arg)

Open pageId as a base page that replaces the current base page. The arg parameter is passed to the page's open() method. This must only be called when there are no popup or overlay pages.

Parameters


currentPageId()

Syntax

nav.currentPageId()`

Returns the page ID of the currently active page on top of the page stack.

Return value

A page ID string.


help()

Syntax

nav.help(pageId)

Opens the Help page as a popup page with pageId as the help topic.

Parameters


lockPage()

Syntax

nav.lockPage(pageId)

The lockPage() method opens pageId as a base page and locks the navigation so that the base page can't change. This is used to lock the Terms of Use page until it is acknowledged. The lock is released by the the unlockPage() method

Parameters


isPopup()

Syntax

nav.isPopup()

nav.isPopup() returns true if the current top page is a popup or overlay page. It returns false if the current page is a base page. It is possible for the same page to be on the page stack more than once and this method can help distinguish pages invoked as a popup page versus as a base page.

Return value

A boolean value.


popupDone()

Syntax

nav.popupDone()

Closes the current top popup or overlay page. This must only be called whent here is a popup page on the page stack. On normal popup pages popupDone() is called automatically when the user clicks the "Done" button. On overlay pages, the page must call popupDone() when the the page is dismissed.


popupPage()

Syntax

nav.popupPage(pageId, arg)

Open pageId as a popup page. The arg parameter is passed to the page's open() method.

Parameters


overlayPage()

Syntax

nav.overlayPage(pageId, arg)

Open pageId as an overlay page. The arg parameter is passed to the page's open() method.

Parameters


unlockPage()

Syntax

nav.unlockPage()

The unlockPage() method clears the page lock initiated by the lockPage() method. It releases the lock and resets the base page to the previous value or the starting page. This is used to unlock the Terms of Use page when it is acknowledged.


Syntax

tml`
	<Nav startPage=myStartPageId layout=myPageLayout />
`

The Nav component provides the View infrastructure for standard MVCS page navigation. It displays the "chrome" that provides navigation elements and an area to display selected pages.

The layout attribute is an array that contains the page ID strings of the menu. The array can also contain an object that contains a group title and another sub-array of page IDs in the group. The layout is used to set the tab or slide-in menus. The startPage attribute sets the initially selected page.

Note that it is possible for the application

Attributes