ButtonBrick Class
ButtonBrick is just a Brick with a button inside it. The button can be styled and can be assigned an onClick event. To instantiate, call new on the ButtonBrick prototype.
Imports RAMP Modules:
Uses RAMP Templates:
templates/bricks_template.json
Item Index
Properties
Methods
clear
()
Brick
chainable
Clears the Brick. This is an empty function. Bricks inheriting from this should override and provide their specific implementations.
Returns:
itself
disable
-
disable
-
force
Disables or re-enables the Brick.
Parameters:
Returns:
itself
displayNotice
-
notice
-
[noticeTemplate]
Display a (error) notice on the brick.
Parameters:
Returns:
itself
getData
-
[wrap]
Returns ButtonBrick's data. Pretty useless function when you think of it. Just returns the data of the Brick prototype which is empty.
Parameters:
-
[wrap]
Boolean optionalindicates of the payload should be wrapped with a Brick's id; useful when collection information from several Bricks at once.
Returns:
ButtonBrick's data
new
-
id
-
config
Initializes the ButtonBrick by generating a specified template and setting defaults. Also sets a click listener on the template button. ButtonBrick is a simple button in the Brick container.
Parameters:
-
id
Stringspecified id of the Brick
-
config
Objecta configuration object for the Brick
-
[header]
String optionala Brick header
-
[instructions]
String optionala configuration object for the Brick
-
[required]
Array | Object optionalcollection of rules specifying what external conditions must be valid for the Brick to be enabled
-
[freezeStates]
Array optionala set of rules specifying states Brick should be frozen
-
[baseTemplate]
String optionala base template name to be used
-
[noticeTemplate]
String optionala notice template name to be used
-
[containerClass]
String optionala CSS class of the specific brick container
-
[template]
String optionala name of the specific Brick template
-
[buttonClass]
String optionala CSS class of the button in the ButtonBrick
-
[label]
String optionala button label
-
Returns:
notify
-
eventName
-
data
Notifies a listener of a Brick event.
Parameters:
Returns:
itself
on
-
eventName
-
listener
Sets a listener on the Brick for a specified eventName.
Parameters:
Returns:
itself
Properties
_isFrozen
Boolean
private
Indicates if the Brick is frozen and cannot be interacted with.
Default: false
_listeners
Object
private
A collection of listeners to be notified of specified Brick events.
Default: {}
containerClass
String
private
A CSS class of the MultiBrick container node.
Default: "button-brick-container"
event
Object
A dictionary of possible ButtonBrick events. Add a CLICK event to the default Brick events.
Example:
event: {
CHANGE: "brick/change",
CLICK: "buttonBrick/click"
}
freezeStates
Array
private
A set of rules specifying states Brick should be frozen.
Default: []
Example:
[
Bricks.Brick.state.SUCCESS,
Bricks.Brick.state.ERROR
],
required
Array
A collection of rules specifying what external conditions must be valid for the Brick to be enabled. This is not used directly by the Brick itself, but instead by the external object manipulating a collection of Bricks. Two types of rules possible: "all" and "any". Any additional properties needed can be specified.
Default: null
Example:
[
{
type: "all",
check: ["serviceType", "serviceURL"]
}
]
state
Object
A dictionary of Brick events.
Example:
state: {
SUCCESS: "brick/success",
ERROR: "brick/error",
DEFAULT: "brick/default"
}
template
String
private
A name of the default ButtonBrick template.
Default: "default_button_brick_template"
Events
Bricks.Brick.event.CHANGE
Published whenever a Brick undergoes some change.
Event Payload:
-
data
Objectanything, usually result of calling getData() on the Brick
Bricks.ButtonBrick.event.CLICK
Published whenever a ButtonBrick is clicked.
Event Payload:
-
data
Objectanything, usually result of calling getData() on the Brick