Constructor
# new Controller(model, view)
Create a controller.
Parameters:
Name | Type | Description |
---|---|---|
model |
object
|
The model object. |
view |
object
|
The view object. |
Classes
Methods
# buildView(selector)
Build the DOM elements.
Parameters:
Name | Type | Description |
---|---|---|
selector |
string
|
DOM selector to the element, where to mount the app. |
# configurate(data)
Configurate the behavior of the controller.
Derivated controllers can define their own properties by overriding the method propertyNames.
Parameters:
Name | Type | Description |
---|---|---|
data |
object
|
Configuration data as object with key/value pairs. |
# fetchJsonData(url, identifier)
Fetch JSON data from URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
URL to the data source. |
identifier |
any
|
Property which handlers can use to identify the type of data. |
# formatNumber(value, locale, minFractionDigits, maxFractionDigits)
Formats a value for display
Parameters:
Name | Type | Description |
---|---|---|
value |
number
|
The value to format. |
locale |
string
|
An optional locale, i.e. 'us/EN' or 'de/DE'. |
minFractionDigits |
int
|
An optional value for the minium amount of digits. |
maxFractionDigits |
int
|
An optional value for the maxium amount of digits. |
# getComponentById(id)
Get a component by id.
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
Id of component to get. |
# getPropertyNames(customPropertyNames) → {array}
Get property names.
Parameters:
Name | Type | Description |
---|---|---|
customPropertyNames |
array
|
An array with the names of a derived class. |
An array with property names or undefined, if no properties exist.
array
# sendMessageToComponent(id, message)
Send a message to a specific component.
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
The id of the component, which should receive the message. |
message |
any
|
The component is responsible for the interpretation of the message. |
# sendMessageToView(message)
Send a message to the current view.
Parameters:
Name | Type | Description |
---|---|---|
message |
any
|
The component is responsible for the interpretation of the message. |
# setContext(context)
Set new controller context.
Parameters:
Name | Type | Description |
---|---|---|
context |
class
|
The new context to be activated. |
# setProperties(id, data)
Set properties for a single component.
Parameters:
Name | Type | Description |
---|---|---|
id |
int
|
The id of the component to change. |
data |
object
|
The properties to change. |
# static numberToString(value, maxFractionDigits) → {string}
Converts a float to a string with a maximum of fractional digits.
Parameters:
Name | Type | Description |
---|---|---|
value |
number
|
The value to convert. |
maxFractionDigits |
int
|
An optional value for the maxium amount of decimal digits. |
A string representing the number with specified decimal digits.
string