Class ExitThisPage

Exit this page component

Hierarchy (view full)

Constructors

Properties

$button: HTMLAnchorElement
$indicatorContainer: HTMLElement = null
$module: HTMLElement
$overlay: HTMLElement = null
$skiplinkButton: HTMLAnchorElement = null
$updateSpan: HTMLElement = null
i18n: I18n
keypressCounter: number = 0
keypressTimeoutId: number = null
lastKeyWasModified: boolean = false
timeoutMessageId: number = null
timeoutTime: number = 5000
defaults: ExitThisPageConfig = ...

Exit this page default config

moduleName: string = 'govuk-exit-this-page'

Name for the component used when initialising using data-module attributes.

schema: Readonly<{
    properties: {
        i18n: {
            type: "object";
        };
    };
}> = ...

Exit this page config schema

Methods

  • Private

    Initiates the redirection away from the current page. Includes the loading overlay functionality, which covers the current page with a white overlay so that the contents are not visible during the loading process. This is particularly important on slow network connections.

    Returns void

  • Private

    Pre-activation logic for when the button is clicked/activated via mouse or pointer.

    We do this to differentiate it from the keyboard activation event because we need to run e.preventDefault as the button or skiplink are both links and we want to apply some additional logic in exitPage before navigating.

    Parameters

    • event: MouseEvent

      mouse click event

    Returns void

  • Private

    Logic for the 'quick escape' keyboard sequence functionality (pressing the Shift key three times without interruption, within a time limit).

    Parameters

    • event: KeyboardEvent

      keyup event

    Returns void

  • Private

    Reset the page using the EtP button

    We use this in situations where a user may re-enter a page using the browser back button. In these cases, the browser can choose to restore the state of the page as it was previously, including restoring the 'ghost page' overlay, the announcement span having it's role set to "alert" and the keypress indicator still active, leaving the page in an unusable state.

    By running this check when the page is shown, we can programatically restore the page and the component to a "default" state

    Returns void

  • Private

    Starts the 'quick escape' keyboard sequence timer.

    This can be invoked several times. We want this to be possible so that the timer is restarted each time the shortcut key is pressed (e.g. the user has up to n seconds between each keypress, rather than n seconds to invoke the entire sequence.)

    Returns void