-
Notifications
You must be signed in to change notification settings - Fork 31
Class Reference
-
Component ⇐
EventEmitter
-
Component is a role that determines an aspect of your user interface. It defines what your users see on the page. Every Component includes a set of behaviors, like what happens when a user clicks on a button.
Components should be dummy, in that they should have no memory, or state, of their own. Components know how to draw a user interface and how to handle user input; whose business logic should be delegated to other classes in the system.
-
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.
erste requires you to manually instantiate all the views in your application.
- 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 that will contain other views, and will allow navigation in between them.Also, each multi-view application should have at least one root ViewManager.
-
InfiniteScroll ⇐
Component
-
NavBar ⇐
Component
-
PullToRefresh ⇐
Component
-
Sidebar ⇐
Component
-
TabView ⇐
View
Component is a role that determines an aspect of your user interface. It defines what your users see on the page. Every Component includes a set of behaviors, like what happens when a user clicks on a button.
Components should be dummy, in that they should have no memory, or state, of their own. Components know how to draw a user interface and how to handle user input; whose business logic should be delegated to other classes in the system.
Kind: global class
Extends: EventEmitter
-
Component ⇐
EventEmitter
- new Component()
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
Creates a new View instance. Users should subclass this class to incorporate their own functionality, as the default View instance doesn't provide anything out of the box.
Example
import {Component} from 'erste';
class ButtonWithLabel extends Component {
template() {
return `
<button-with-label>
<h1>Hello world!</h1>
<button>Tap me!</button>
</button-with-label>
`;
}
onTapButton() {
this.$('h1').innerText = 'Thanks for the tap!';
}
get events() {
return {
'tap': {
'button': this.onTapButton
}
}
}
}
The auto-generated, unique id of the Component.
Kind: instance property of Component
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
Kind: instance property of Component
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of Component
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of Component
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of Component
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of Component
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of Component
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of Component
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of Component
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
Kind: instance method of Component
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.
erste requires you to manually instantiate all the views in your application.
Kind: global class
Extends: Component
-
View ⇐
Component
- new View()
-
instance
-
.index :
number
-
.supportsBackGesture :
boolean
-
.hasSidebar :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .onActivation()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
-
.index :
-
static
-
.WIDTH ⇒
number
-
.WIDTH ⇒
Creates a new View instance. Users should subclass this class to incorporate their own functionality, as the default View instance doesn't provide anything out of the box.
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
}
}
}
}
new RootView().render(); // renders into body.
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
The auto-generated, unique id of the Component.
Kind: instance property of View
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
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
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of View
Overrides: tagExtension_
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of View
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of View
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of View
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of View
Overrides: render
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of View
Overrides: onAfterRender
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of View
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
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 that will contain other
views, and will allow navigation in between them.
Also, each multi-view application should have at least one root 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
argument 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
Returns the last view in this ViewManager's history, and null if the history is empty.
This may be used to send messages to whatever the previous View is in the history right before a viewManager.push() call.
Kind: instance method of ViewManager
Kind: instance method of ViewManager
Param | Type | Description |
---|---|---|
view | View |
View instance to pull into the scene. |
[opt_canGoBack] | boolean |
Whether the ViewManager should keep history so that one can go back to the previous View. Has a hard-coded transition effect similar to iOS7+. |
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, and ignores the call if the history is empty.
Has a hard-coded transition effect similar to iOS7+.
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" |
InfiniteScroll ⇐ Component
Kind: global class
Extends: Component
-
InfiniteScroll ⇐
Component
- new InfiniteScroll([opt_el])
-
.endOfListText :
string
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .reset()
- .register(el)
- .showSpinner()
- .showEndOfList()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .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
The auto-generated, unique id of the Component.
Kind: instance property of InfiniteScroll
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
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
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of InfiniteScroll
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of InfiniteScroll
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of InfiniteScroll
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of InfiniteScroll
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of InfiniteScroll
Overrides: render
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of InfiniteScroll
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of InfiniteScroll
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
Kind: instance method of InfiniteScroll
Overrides: dispose
NavBar ⇐ Component
Kind: global class
Extends: Component
-
NavBar ⇐
Component
- new NavBar([opt_config])
-
instance
-
.id ⇒
string
-
.el ⇒
HTMLElement
- .onBackButtonTap()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
-
.id ⇒
-
static
-
.NavBarOptions :
Object
-
.NavBarOptions :
Includes back button for back navigation.
Param | Type | Description |
---|---|---|
[opt_config] | NavBarOptions |
Config parameters to include things like title. |
The auto-generated, unique id of the Component.
Kind: instance property of NavBar
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
Kind: instance property of NavBar
Back button tap event handler.
Kind: instance method of NavBar
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of NavBar
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of NavBar
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of NavBar
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of NavBar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of NavBar
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of NavBar
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of NavBar
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
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
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onShouldRefresh()
- .reset()
- .register(scrollEl, [containerEl])
- .checkShouldRefresh()
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .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
The auto-generated, unique id of the Component.
Kind: instance property of PullToRefresh
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
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
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of PullToRefresh
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of PullToRefresh
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of PullToRefresh
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of PullToRefresh
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of PullToRefresh
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of PullToRefresh
Overrides: onAfterRender
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of PullToRefresh
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
Kind: instance method of PullToRefresh
Overrides: dispose
Sidebar ⇐ Component
Kind: global class
Extends: Component
-
Sidebar ⇐
Component
- .vm
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onSidebarItemTap(e)
-
.template_items() ⇒
string
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
-
.render(rootEl, [opt_index]) ⇒
boolean
- .onAfterRender()
-
.template() ⇒
string
- .dispose()
Kind: instance property of Sidebar
Export:
The auto-generated, unique id of the Component.
Kind: instance property of Sidebar
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
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.
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of Sidebar
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of Sidebar
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of Sidebar
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of Sidebar
Param | Type | Description |
---|---|---|
selector | string |
Selector |
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of Sidebar
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the document.
Kind: instance method of Sidebar
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of Sidebar
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
Kind: instance method of Sidebar
TabView ⇐ View
Kind: global class
Extends: View
-
TabView ⇐
View
-
.views :
Array.<!View>
-
.index :
number
-
.supportsBackGesture :
boolean
-
.hasSidebar :
boolean
-
.id ⇒
string
-
.el ⇒
HTMLElement
-
.mappings :
enum
- .onItemTap(e)
- .activateItem(index)
- .activateItemByName(name)
- .deactivateActiveItem()
-
.template_items() ⇒
string
-
.render(rootEl, [opt_index]) ⇒
boolean
- .onAfterRender()
- .onActivation()
-
.template() ⇒
string
- .tagExtension_()
- .toString()
-
.$$(selector) ⇒
Array.<!Element>
-
.$(selector) ⇒
Element
- .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
The auto-generated, unique id of the Component.
Kind: instance property of TabView
The DOM element of the Component. This is a getter that first
checks whether the component has been rendered as a DOM element, and
returns the HTMLElement
if so. If the component hasn't been rendered
yet, it looks for the element in the DOM. If it's still not yet in the
DOM, it renders the element to a DOM element and returns it accordingly.
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.
Renders the Component into a given parent DOM element and returns the result. May be called with an optional index to indicate where the DOM element of this Component should be inserted in the parent.
Kind: instance method of TabView
Returns: boolean
- Whether the component is rendered. Note that it might
have already been rendered, not as a direct result of this call to
component.render().
Param | Type | Description |
---|---|---|
rootEl | Element |
Root element to render this component in. |
[opt_index] | number |
The index of this component within the parent component. This may be used to render a new child before an existing child in the parent. |
This method is called after a render process either as a direct result of a component.render() call or after the template of this component is inserted into the DOM.
Subclasses should override this method for tasks that should be done when the Component is in the 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
Default template for Components. Returns an empty <div>
by
default and should be overridden to provide actual HTML templates.
A template can also contain another Component directly, as in the example below. This is a very handy way of rendering component hierarchies.
Kind: instance method of TabView
Overrides: template
Example
template() {
this.buttonWithLabel = new ButtonWithLabel();
return `
<div>
<h1>Label</h1>
${this.buttonWithLabel}
</div>
`;
}
Provides template for populating the id
field of a component.
Should not be overridden.
Kind: instance method of TabView
Access: protected
This method makes sure that users can conveniently include Components in the template of an owner component. Whenever a Component is cast to a string, we calculate the template and return it.
Notice that this is only a template, and does not correspond to the actual Component instance. In other words, one can't move a Component instance from a parent to a new parent simply by using its template in the new parent.
Kind: instance method of TabView
Given a query selector, returns an array of child Element
s of this
Component or an empty array if no results are found. This is a
wrapper around el.querySelectorAll
, and conveniently returns an array
instead of a NodeList
, so all array operations work.
Kind: instance method of TabView
Returns: Array.<!Element>
- The list of child Element
s or an empty list
Param | Type | Description |
---|---|---|
selector | string |
Selector to retrieve child Element s |
Given a query selector, returns the first child Element
of this
Component or null if no results are found or the
Component hasn't been rendered yet. This is a wrapper around
el.querySelector
.
Kind: instance method of TabView
Param | Type | Description |
---|---|---|
selector | string |
Selector |
This method should be called when this Component is being removed.
Make sure to override this method in your Components if
they have side effects that should be cleared, e.g. removing event
listeners, and make sure to call super()
.
The base implementation here removes all event listeners attached to this Component and also removes the Component from the ComponentManager. Finally, it removes the DOM element from the document.
Kind: instance method of TabView