new Surface(id)
Surface class representing the references to elements on the page that
can potentially be updated by
App.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Members
-
<static, non-null> DEFAULT :String
-
Holds the default surface name. Elements on the page must contain a child element containing the default content, this element must be as following: Example:
The default content is relevant for the initial page content. When a screen doesn't provide content for the surface the default content is restored into the page.Default surface content.Type:
- String
- Default Value:
-
- default
-
<protected> activeChild :Element
-
Holds the active child element.
Type:
- Element
- Default Value:
-
- null
-
<protected> defaultChild :Element
-
Holds the default child element.
Type:
- Element
- Default Value:
-
- null
-
<protected> element :Element
-
Holds the element with the specified surface id, if not found creates a new element with the specified id.
Type:
- Element
- Default Value:
-
- null
-
<protected> id :String
-
Holds the surface id.
Type:
- String
- Default Value:
-
- null
-
transitionFn
-
Holds the default transitionFn for the surfaces.
- Default Value:
-
- null
Methods
-
<static> defaultTransition( [from] [, to])
-
Holds the default transition for all surfaces. Each surface could have its own transition. Example:
surface.setTransitionFn(function(from, to) { if (from) { from.style.display = 'none'; from.classList.remove('flipped'); } if (to) { to.style.display = 'block'; to.classList.add('flipped'); } return null; });Parameters:
Name Type Argument Description fromElement <optional>
<nullable>
The visible surface element. toElement <optional>
<nullable>
The surface element to be flipped. -
addContent(screenId, opt_content)
-
Adds screen content to a surface. If content hasn't been passed, see if an element exists in the DOM that matches the id. By convention, the element should already be nested in the right element and should have an id that is a concatentation of the surface id + '-' + the screen id.
Parameters:
Name Type Description screenIdstring The screen id the content belongs too. opt_contentstring | Element The string content or element to add be added as surface content. Returns:
- Type
- Element
-
createChild(screenId)
-
Creates child node for the surface.
Parameters:
Name Type Description screenIdstring The screen id. Returns:
- Type
- Element
-
getChild(screenId)
-
Gets child node of the surface.
Parameters:
Name Type Description screenIdstring The screen id. Returns:
- Type
- Element
-
getElement()
-
Gets the surface element from element, and sets it to the el property of the current instance.
this.elementwill be used.Returns:
The current surface element.- Type
- Element
-
getId()
-
Gets the surface id.
Returns:
- Type
- String
-
getTransitionFn()
-
Gets the surface transition function. See
Surface.defaultTransition.Returns:
The transition function.- Type
- function
-
maybeWrapContentAsDefault_()
-
If default child is missing, wraps surface content as default child. If surface have static content, make sure to place a
surfaceId-defaultelement inside surface, only contents inside the default child will be replaced by navigation. -
remove(screenId)
-
Removes screen content from a surface.
Parameters:
Name Type Description screenIdstring The screen id to remove. -
setId(id)
-
Sets the surface id.
Parameters:
Name Type Description idstring -
setTransitionFn( [transitionFn])
-
Sets the surface transition function. See
Surface.defaultTransition.Parameters:
Name Type Argument Description transitionFnfunction <optional>
<nullable>
The transition function. -
show(screenId)
-
Shows screen content from a surface.
Parameters:
Name Type Description screenIdString The screen id to show. Returns:
Pauses the navigation until it is resolved.- Type
- CancellablePromise
-
toString()
-
Returns:
- Type
- String
-
transition( [from] [, to])
-
Invokes the transition function specified on
transitionattribute.Parameters:
Name Type Argument Description fromElement <optional>
<nullable>
toElement <optional>
<nullable>
Returns:
This can return a promise, which will pause the navigation until it is resolved.- Type
- CancellablePromise