Classes
- ClientRouter
The client-side implementation of the
Router
interface.
Constants
- CLICK :
string
Name of the event produced when the user clicks the page using the mouse, or touches the page and the touch event is not stopped.
- POP_STATE :
string
Name of the event fired when the user navigates back in the history.
- MOUSE_LEFT_BUTTON :
number
The number used as the index of the mouse left button in DOM
MouseEvent
s.
ClientRouter
The client-side implementation of the Router
interface.
Kind: global class
- ClientRouter
- new ClientRouter(pageManager, factory, dispatcher, window)
- ._window :
Window
- ._boundedHandleClick() :
function
- ._boundedHandlePopState() :
function
- .init()
- .getUrl()
- .getPath()
- .listen()
- .unlisten()
- .redirect()
- .route()
- .handleError()
- .handleNotFound()
- ._handleFatalError(error)
- ._handlePopState(event)
- ._handleClick(event)
- ._getAnchorElement(target) ⇒
Node
- ._isHashLink(targetUrl) ⇒
boolean
- ._isSameDomain([url]) ⇒
boolean
new ClientRouter(pageManager, factory, dispatcher, window)
Initializes the client-side router.
Param | 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. |
clientRouter._window : Window
Helper for accessing the native client-side APIs.
Kind: instance property of ClientRouter
clientRouter._boundedHandleClick() : function
Helper function with right context for binding listener to DOM.
Kind: instance method of ClientRouter
clientRouter._boundedHandlePopState() : function
Helper function with right context for binding listener to DOM.
Kind: instance method of ClientRouter
clientRouter.init()
Kind: instance method of ClientRouter
clientRouter.getUrl()
Kind: instance method of ClientRouter
clientRouter.getPath()
Kind: instance method of ClientRouter
clientRouter.listen()
Kind: instance method of ClientRouter
clientRouter.unlisten()
Kind: instance method of ClientRouter
clientRouter.redirect()
Kind: instance method of ClientRouter
clientRouter.route()
Kind: instance method of ClientRouter
clientRouter.handleError()
Kind: instance method of ClientRouter
clientRouter.handleNotFound()
Kind: instance method of ClientRouter
clientRouter._handleFatalError(error)
Handle a fatal error application state. IMA handle fatal error when IMA handle error.
Kind: instance method of ClientRouter
Param | Type |
---|---|
error | Error |
clientRouter._handlePopState(event)
Handles a popstate event. The method is performed when the active history entry changes.
The navigation will be handled by the router if the event state is defined
and event is not defaultPrevented
.
Kind: instance method of ClientRouter
Param | Type | Description |
---|---|---|
event | PopStateEvent |
The popstate event. |
clientRouter._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.
Kind: instance method of ClientRouter
Param | Type | Description |
---|---|---|
event | MouseEvent |
The click event. |
clientRouter._getAnchorElement(target) ⇒ Node
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.
Kind: instance method of ClientRouter
Param | Type |
---|---|
target | Node |
clientRouter._isHashLink(targetUrl) ⇒ boolean
Tests whether the provided target URL contains only an update of the hash fragment of the current URL.
Kind: instance method of ClientRouter
Returns: boolean
- true
if the navigation to target URL would
result only in updating the hash fragment of the current URL.
Param | Type | Description |
---|---|---|
targetUrl | string |
The target URL. |
clientRouter._isSameDomain([url]) ⇒ boolean
Tests whether the the protocol and domain of the provided URL are the same as the current.
Kind: instance method of ClientRouter
Returns: boolean
- true
if the protocol and domain of the
provided URL are the same as the current.
Param | Type | Default | Description |
---|---|---|---|
[url] | string |
"''" |
The URL. |
Events : enum
Names of the DOM events the router responds to.
Kind: global enum
CLICK : string
Name of the event produced when the user clicks the page using the mouse, or touches the page and the touch event is not stopped.
Kind: global constant
POP_STATE : string
Name of the event fired when the user navigates back in the history.
Kind: global constant
MOUSE_LEFT_BUTTON : number
The number used as the index of the mouse left button in DOM
MouseEvent
s.
Kind: global constant