CheckboxGroup Class
Creates a Checkbox group bound from the supplied JArray of input nodes. Optionally, the group is bound to the supplied master input node which acts as a global toggle for the group.
Imports RAMP Modules:
Constructor
CheckboxGroup
-
nodes
-
[options]
Parameters:
-
nodes
JArraya jQuery object representing the checkboxes to be grouped
-
[options]
Object optionalAdditional options
-
[nodeIdAttr]
String optionalName of the "data-" attribute set on the checkbox node to be treated as the checkbox id. If no appropriate "data-" attribute found,
nodeIdAttr
is used directly, failing that, regularid
is used. -
[cssClass]
Object optionalactive
,focus
, andcheck
CSS class to be applied to the Checkbox correspondingly. -
[label]
Object optionalcheck
anduncheck
label texts to be applied to the Checkbox labels. -
[onChnage]
Function optionalA function to be called when the state of the Checkbox changes.
-
[master]
Object optionalAdditional options applied to the master Checkbox.
-
[node]
Object optionalAninput
node to serve as the master Checkbox for the group. -
[cssClass]
Object optionalactive
,focus
, andcheck
CSS class to be applied to the master Checkbox correspondingly. -
[cssClass.active]
Object optionalCSS class to be set when the Checkbox isactive
. -
[cssClass.focus]
Object optionalCSS class to be set when the master Checkbox isfocused
. -
[cssClass.check]
Object optionalCSS class to be set when the master Checkbox ischecked
. -
[label]
Object optionalcheck
anduncheck
label texts to be applied to the master Checkbox labels. -
[label.check]
Object optionalA text to be set as a label when the master Checkbox ischecked
-
[label.uncheck]
Object optionalA text to be set as a label when the master Checkbox isunchecked
-
[onChnage]
Function optionalA function to be called when the state of the master Checkbox changes.
-
-
Returns:
A control objects allowing to toggle individual checkboxes in a group as well as the group as a whole.
Item Index
Methods
Properties
Events
Methods
_checkMaster
()
private
Synchronizes the state of the master Checkbox with the state of the group. All group members checked -> master checked Any of the group members unchecked -> master unchecked
_emit
-
agency
Emits a TOGGLE
event when the checkbox's state is changed.
Parameters:
-
agency
StringSpecified the agency that toggled the Checkbox.
setEachState
-
fcn
Toggle all the checkboxes based on the return value of the given function.
Parameters:
-
fcn
Functiona function that takes a checkbox as an argument and returns true if the given checkbox should be toggled on, false if it should be toggled off
setState
-
state
-
[checkboxId]
Toggles the state of the specified Checkbox. If checkboxId is not supplied, toggles the whole group.
Parameters:
Returns:
CheckboxGroup
Properties
agency
Object
private
An object specifying possible agencies that can affect the Checkbox.
Example:
agency: {
USER: "USER",
CODE: "CODE"
}
cssClass
Object
active
, focus
, and check
CSS class to be applied to the Checkbox correspondingly.
Example:
cssClass: {
active: "active",
focus: "focused",
check: "checked"
}
event
Object
private
Event names published by the Checkbox
Default: null
Example:
{
MEMBER_TOGGLE: "checkbox/toggled",
MASTER_TOGGLE: "checkbox/toggled"
}
label
Object
check
and uncheck
label texts to be applied to the Checkbox labels.
Example:
label: {
check: "check",
uncheck: "unchecked"
}
labelNode
JObject
private
Node of the input checkbox label.
Default: null
master
Object
Options for the master Checkbox.
Example:
master: {
node: null,
checkbox: null,
nodeIdAttr: null,
cssClass: {
active: "active",
focus: "focused",
check: "checked"
},
label: {
check: "checked",
uncheck: "unchecked"
},
onChange: function () { }
}
node
JObject
Node of the input checkbox originally supplied to the Checkbox.
Default: null
nodeIdAttr
String
Name of the "data-*" attribute set on the checkbox node to be treated as the checkbox id.
Default: "id"
nodes
JArray
Nodes of the checkbox nodes originally supplied to the CheckboxGroup.
Default: []
onChnage
Function
A function to be called when the state of the Checkbox changes.
Example:
function () { }
Events
MASTER_TOGGLE
Published whenever the master Checkbox get toggled.
MEMBER_TOGGLE
Published whenever a Checkbox get toggled.
TOGGLE
private
This event is not published by CheckboxGroup. Ignore this.