new ClientRouter(pageManager, factory, dispatcher, window)
Initializes the client-side router.
Parameters:
Name | Type | Description |
---|---|---|
pageManager |
PageManager | The page manager handling UI rendering, and transitions between pages if at the client side. |
factory |
RouteFactory | Factory for routes. |
dispatcher |
Dispatcher | Dispatcher fires events to app. |
window |
Window | The current global client-side APIs provider. |
Members
Methods
-
_getAnchorElement(target)
-
The method determines whether an anchor element or a child of an anchor element has been clicked, and if it was, the method returns anchor element else null.
Parameters:
Name Type Description target
Node Returns:
- Type
- Node
-
_handleClick(event)
-
Handles a click event. The method performs navigation to the target location of the anchor (if it has one).
The navigation will be handled by the router if the protocol and domain of the anchor's target location (href) is the same as the current, otherwise the method results in a hard redirect.
Parameters:
Name Type Description event
MouseEvent The click event.
-
_handleFatalError(error)
-
Handle a fatal error application state. IMA handle fatal error when IMA handle error.
Parameters:
Name Type Description error
Error -
_isHashLink(targetUrl)
-
Tests whether the provided target URL contains only an update of the hash fragment of the current URL.
Parameters:
Name Type Description targetUrl
string The target URL.
Returns:
true
if the navigation to target URL would result only in updating the hash fragment of the current URL.- Type
- boolean
-
_isSameDomain( [url])
-
Tests whether the the protocol and domain of the provided URL are the same as the current.
Parameters:
Name Type Argument Default Description url
string <optional>
'' The URL.
Returns:
true
if the protocol and domain of the provided URL are the same as the current.- Type
- boolean
-
_saveScrollHistory()
-
Save user's scroll state to history.
Replace scroll values in current state for actual scroll values in document.
-
_setAddressBar(url)
-
Sets the provided URL to the browser's address bar by pushing a new state to the history.
The state object pushed to the history will be an object with the following structure:
{url: string
}. Theurl
field will be set to the provided URL.Parameters:
Name Type Description url
string The URL.
-
getPath()
-
-
getUrl()
-
-
handleError()
-
-
handleNotFound()
-
-
init()
-
-
listen()
-
-
redirect()
-
-
route()
-