-
Notifications
You must be signed in to change notification settings - Fork 31
Class Reference
-
View ⇐
Component
-
The default view class for all the views in an erste application. A View is simply a Component with additional convenience features. For example, a View renders to
document.body
by default, whereas a Component silently ignores the call if no root is provided. Also, regardless of the template, aview
attribute is added to the root DOM elements of each View, so that uniform styling across all views is possible without much heavy-lifting.For implementing full-screen, navigable views, users should subclass View.
- ViewManager
-
This class handles view transitions and view history in a consistent manner similar to
NavigationController
s in other frameworks. An instance of this class should be used by views who would like to contain other views.Also, each multi-view application should have at least one ViewManager.
-
Component ⇐
EventEmitter
-
InfiniteScroll ⇐
Component
-
NavBar ⇐
Component
-
PullToRefresh ⇐
Component
-
Sidebar ⇐
Component
-
TabView ⇐
View
View ⇐ Component
The default view class for all the views in an erste application. A
View is simply a Component with additional
convenience features. For example, a View renders to document.body
by default, whereas a Component silently ignores the call if no root
is provided. Also, regardless of the template, a view
attribute is added
to the root DOM elements of each View, so that uniform styling
across all views is possible without much heavy-lifting.
For implementing full-screen, navigable views, users should subclass View.
Kind: global class
Extends: Component
-
View ⇐
Component
- new View()
-
instance
-
.index :
number
-
.supportsBackGesture :
boolean
-
.hasSidebar :
boolean
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .onActivation()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
-
.index :
-
static
-
.WIDTH ⇒
number
-
.WIDTH ⇒
View constructor. erste requires you to manually instantiate all the views in your application.
Example
class RootView extends erste.View {
template() {
return `
<root-view>
<h1>Hello world!</h1>
<button>Click me!</button>
</root-view>
`;
}
onTapButton() {
this.$('h1').innerText = 'Thanks for the tap!';
}
get events() {
return {
'tap': {
'button': this.onTapButton
}
}
}
}
View index in z-axis. This is used as the Z-value for initial translate3d CSS declaration.
Kind: instance property of View
Determines whether the view should support back gestures to go back in history of a ViewManager.
Kind: instance property of View
Determines whether the view allows swipe / drag gestures to reveal an associated sidebar. This lets the view manager orchestrate the touch gestures for revealing the sidebar menu.
Kind: instance property of View
Kind: instance property of View
Access: protected
Kind: instance property of View
Access: protected
Kind: instance property of View
Kind: instance property of View
This method is called after the view is activated by a ViewManager, i.e.,
either pull
ed or set as the current view using
setCurrentView.
Subclasses should override this method for tasks that should be done when the View is in viewport, such as updating information, etc.
Kind: instance method of View
Kind: instance method of View
Overrides: tagExtension_
Access: protected
Kind: instance method of View
Kind: instance method of View
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of View
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of View
Overrides: render
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of View
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of View
Overrides: onAfterRender
Kind: instance method of View
Overrides: template
Call when removing this Component from memory
Kind: instance method of View
Returns the width of the viewport in pixels.
Kind: static property of View
Returns: number
- The device width.
This class handles view transitions and view history in a consistent
manner similar to NavigationController
s in other frameworks.
An instance of this class should be used by views who would like to contain
other views.
Also, each multi-view application should have at least one ViewManager.
Kind: global class
-
ViewManager
- new ViewManager([opt_root])
-
instance
-
.history :
Array.<!View>
-
.currentView :
View
-
.getLastViewInHistory() ⇒
View
- .pull(view, [opt_canGoBack])
-
.canGoBack() ⇒
boolean
- .push()
- .setCurrentView(view, [opt_noDispose])
- .toggleSidebar()
-
.history :
-
static
-
.State :
enum
-
.State :
ViewManager constructor. At least one ViewManager should be present in all multi-view erste applications.
Param | Type | Description |
---|---|---|
[opt_root] |
Element | View
|
Root element for this ViewManager. Default is document.body . Can also be a View, in which case the root element will be the el of the aforementioned View. In this case, the View instance should be rendered before any view interactions are done via viewManager.pull or other ViewManager methods. |
Array of views stored in memory. When
viewManager.pull is called with the second
parameter set to true
, meaning the user should be able to go back,
the current view is pushed to this array.
When it's time to reset the history, all views in history are disposed.
Kind: instance property of ViewManager
viewManager.currentView : View
Current active view.
Kind: instance property of ViewManager
viewManager.getLastViewInHistory() ⇒ View
Kind: instance method of ViewManager
Kind: instance method of ViewManager
Param | Type | Description |
---|---|---|
view | View |
View to pull into view. |
[opt_canGoBack] | boolean |
Whether this view keeps history so that one can go back to the previous view. |
Returns true if there is one or more views in history, returns false otherwise.
Kind: instance method of ViewManager
Returns: boolean
- Whether the view manager can push current view.
Switches to the previous view if there's one.
Kind: instance method of ViewManager
Makes a given view the foremost view without animations and with disposing previous views in history.
Kind: instance method of ViewManager
Noalias:
Param | Type | Description |
---|---|---|
view | View |
The view to set as the foremost view. |
[opt_noDispose] | boolean |
Whether to dispose the current view. |
Toggles the sidebar on or off according to its current state. This is to be used for a menu button, for example.
Kind: instance method of ViewManager
View manager states.
Kind: static enum of ViewManager
Properties
Name | Type | Default |
---|---|---|
DEFAULT | string |
"default" |
STARTED_GESTURE | string |
"started" |
CLOSING_SIDEBAR | string |
"closingSidebar" |
OPENING_SIDEBAR | string |
"openingSidebar" |
SIDEBAR_OPEN | string |
"sidebarOpen" |
GOING_TO_BACK_VIEW | string |
"going" |
Kind: global class
Extends: EventEmitter
-
Component ⇐
EventEmitter
- new Component()
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
Component is a role that determines your user interface. It defines what your users see on the page. Component includes a lot of predefined behaviors, like what happens when a user clicks on a button. Components are extremely dummy, in that they have no memory, or state, of their own. They know how to draw a user interface and how to handle user input; which they delegate to the Representatives.
Kind: instance property of Component
Access: protected
Kind: instance property of Component
Access: protected
Kind: instance property of Component
Kind: instance property of Component
Kind: instance method of Component
Access: protected
Kind: instance method of Component
Kind: instance method of Component
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of Component
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of Component
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of Component
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of Component
Kind: instance method of Component
Call when removing this Component from memory
Kind: instance method of Component
InfiniteScroll ⇐ Component
Kind: global class
Extends: Component
-
InfiniteScroll ⇐
Component
- new InfiniteScroll([opt_el])
-
.endOfListText :
string
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .reset()
- .register(el)
- .showSpinner()
- .showEndOfList()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
InfiniteScrollComponent is a small component which checks the scroll position of a given DOM element, and if it's in an appropriate position, fires a LOAD event for the parent component to act upon. When the parent component is done loading new items, it should reset this InfiniteScrollComponent with the reset() method.
Param | Type | Description |
---|---|---|
[opt_el] | Element |
Optional element to track its scroll. |
Message to show when no more items are available to load.
Kind: instance property of InfiniteScroll
Kind: instance property of InfiniteScroll
Access: protected
Kind: instance property of InfiniteScroll
Access: protected
Kind: instance property of InfiniteScroll
Kind: instance property of InfiniteScroll
Resets the component state to default. This should be used to signal the end of loading so that this component can again check for loading.
Kind: instance method of InfiniteScroll
Registers an element to track its scroll. This can be used for lazily introducing an element to track.
Kind: instance method of InfiniteScroll
Param | Type | Description |
---|---|---|
el | Element |
Element to track. |
Shows spinner during load.
Kind: instance method of InfiniteScroll
Shows end of list message if no more items are available.
Kind: instance method of InfiniteScroll
Kind: instance method of InfiniteScroll
Access: protected
Kind: instance method of InfiniteScroll
Kind: instance method of InfiniteScroll
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of InfiniteScroll
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of InfiniteScroll
Overrides: render
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of InfiniteScroll
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of InfiniteScroll
Kind: instance method of InfiniteScroll
Overrides: template
Call when removing this Component from memory
Kind: instance method of InfiniteScroll
Overrides: dispose
NavBar ⇐ Component
Kind: global class
Extends: Component
-
NavBar ⇐
Component
- new NavBar([opt_config])
-
instance
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .onBackButtonTap()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
-
.template_ :
-
static
-
.NavBarOptions :
Object
-
.NavBarOptions :
Includes back button for back navigation.
Param | Type | Description |
---|---|---|
[opt_config] | NavBarOptions |
Config parameters to include things like title. |
Kind: instance property of NavBar
Access: protected
Kind: instance property of NavBar
Access: protected
Kind: instance property of NavBar
Kind: instance property of NavBar
Back button tap event handler.
Kind: instance method of NavBar
Kind: instance method of NavBar
Access: protected
Kind: instance method of NavBar
Kind: instance method of NavBar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of NavBar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of NavBar
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of NavBar
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of NavBar
Kind: instance method of NavBar
Overrides: template
Call when removing this Component from memory
Kind: instance method of NavBar
Kind: static typedef of NavBar
PullToRefresh ⇐ Component
Kind: global class
Extends: Component
-
PullToRefresh ⇐
Component
- new PullToRefresh([opt_el])
-
.threshold :
number
-
.height :
number
-
.arrowOffset :
number
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onShouldRefresh()
- .reset()
- .register(scrollEl, [containerEl])
- .checkShouldRefresh()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
P2RComponent is a small component which checks the scroll position of a given DOM element, and if it's in an appropriate position, fires a REFRESH event for the parent component to act upon. When the parent component is done with refreshing, it should reset this P2RComponent with the reset() method.
Param | Type | Description |
---|---|---|
[opt_el] | Element |
Optional element to track its scroll. |
Threshold value for the release action. Releases after this threshold will trigger a refresh.
Kind: instance property of PullToRefresh
Height of this component. This setting is used to offset the scroll view while refreshing.
Kind: instance property of PullToRefresh
Start position of the arrow. This is adjusted for a spring-like effect.
Kind: instance property of PullToRefresh
Kind: instance property of PullToRefresh
Access: protected
Kind: instance property of PullToRefresh
Access: protected
Kind: instance property of PullToRefresh
Kind: instance property of PullToRefresh
Kind: instance enum of PullToRefresh
Triggered when the components decides a refresh action. This method should be overridden to, for example, display a spinner animation during refresh.
Kind: instance method of PullToRefresh
Resets the component state to default. This should be used to signal the end of refreshing so that this component can again check for pull to refresh.
Kind: instance method of PullToRefresh
Registers an element to track its scroll. This can be used for lazily introducing an element to track.
Kind: instance method of PullToRefresh
Param | Type | Description |
---|---|---|
scrollEl | Element |
Element to track. |
[containerEl] | Element |
Element to offset during activity. |
If in an appropriate state, checks if the scroll position is right and if so triggers a refresh event.
Kind: instance method of PullToRefresh
Kind: instance method of PullToRefresh
Access: protected
Kind: instance method of PullToRefresh
Kind: instance method of PullToRefresh
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of PullToRefresh
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of PullToRefresh
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of PullToRefresh
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of PullToRefresh
Overrides: onAfterRender
Kind: instance method of PullToRefresh
Overrides: template
Call when removing this Component from memory
Kind: instance method of PullToRefresh
Overrides: dispose
Sidebar ⇐ Component
Kind: global class
Extends: Component
-
Sidebar ⇐
Component
- .vm
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onSidebarItemTap(e)
-
.template_items() ⇒
string
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .render([opt_base], [opt_index])
- .onBeforeRender()
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
Kind: instance property of Sidebar
Export:
Kind: instance property of Sidebar
Access: protected
Kind: instance property of Sidebar
Access: protected
Kind: instance property of Sidebar
Kind: instance property of Sidebar
Dom mapping.
Kind: instance enum of Sidebar
Dispatches a switch view event to listeners and toggles the sidebar of the view manager that is responsible for this sidebar.
Kind: instance method of Sidebar
Param | Type | Description |
---|---|---|
e | Object |
Tap event. |
Kind: instance method of Sidebar
Returns: string
- Returns the items for the sidebar.
Kind: instance method of Sidebar
Access: protected
Kind: instance method of Sidebar
Kind: instance method of Sidebar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of Sidebar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of Sidebar
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of Sidebar
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of Sidebar
Kind: instance method of Sidebar
Overrides: template
Call when removing this Component from memory
Kind: instance method of Sidebar
TabView ⇐ View
Kind: global class
Extends: View
-
TabView ⇐
View
-
.views :
Array.<!View>
-
.index :
number
-
.supportsBackGesture :
boolean
-
.hasSidebar :
boolean
-
.template_ :
string
-
.rendered_ :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onItemTap(e)
- .activateItem(index)
- .activateItemByName(name)
- .deactivateActiveItem()
-
.template_items() ⇒
string
- .render([opt_base], [opt_index])
- .onAfterRender()
- .onActivation()
-
.template() ⇒
string
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .onBeforeRender()
- .dispose()
-
.views :
Kind: instance property of TabView
View index in z-axis. This is used as the Z-value for initial translate3d CSS declaration.
Kind: instance property of TabView
Determines whether the view should support back gestures to go back in history of a ViewManager.
Kind: instance property of TabView
Determines whether the view allows swipe / drag gestures to reveal an associated sidebar. This lets the view manager orchestrate the touch gestures for revealing the sidebar menu.
Kind: instance property of TabView
Kind: instance property of TabView
Access: protected
Kind: instance property of TabView
Access: protected
Kind: instance property of TabView
Kind: instance property of TabView
Dom mappings.
Kind: instance enum of TabView
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
e | Object |
Item touch event handler. |
Adds active class to item.
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
index | number |
Index of the item to be active. |
Activates a tab bar item with a given name. If an item for the given the name isn't found, does nothing.
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
name | string |
Name for the tab bar item. |
Removes active class of active item.
Kind: instance method of TabView
Kind: instance method of TabView
Returns: string
- Template for tab bar items.
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
[opt_base] | Element |
Base element |
[opt_index] | number |
Base element |
Method called after a render process. Called automatically after each render. Subclasses should override this method for tasks that should be done when the View is in document.
Kind: instance method of TabView
Overrides: onAfterRender
This method is called after the view is activated by a ViewManager, i.e.,
either pull
ed or set as the current view using
setCurrentView.
Subclasses should override this method for tasks that should be done when the View is in viewport, such as updating information, etc.
Kind: instance method of TabView
Kind: instance method of TabView
Overrides: template
Kind: instance method of TabView
Access: protected
Kind: instance method of TabView
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Method called before a render process. Called automatically before each render. Subclasses should override this method for tasks that should be done right before the View enters the document.
Kind: instance method of TabView
Call when removing this Component from memory
Kind: instance method of TabView