Reusable Accessible Mapping Platform

API Docs for: 5.2.0
Show:

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:

Array
Checkbox

Constructor

CheckboxGroup

(
  • nodes
  • [options]
)
CheckboxGroup

Parameters:

  • nodes JArray

    a jQuery object representing the checkboxes to be grouped

  • [options] Object optional

    Additional options

    • [nodeIdAttr] String optional

      Name 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, regular id is used.

    • [cssClass] Object optional

      active, focus, and check CSS class to be applied to the Checkbox correspondingly.

      • [active] Object optional
        CSS class to be set when the Checkbox is active.
      • [focus] Object optional
        CSS class to be set when the Checkbox is focused.
      • [check] Object optional
        CSS class to be set when the Checkbox is checked.
    • [label] Object optional

      check and uncheck label texts to be applied to the Checkbox labels.

      • [check] Object optional
        A text to be set as a label when the Checkbox is checked
      • [uncheck] Object optional
        A text to be set as a label when the Checkbox is unchecked
    • [onChnage] Function optional

      A function to be called when the state of the Checkbox changes.

    • [master] Object optional

      Additional options applied to the master Checkbox.

      • [node] Object optional
        An input node to serve as the master Checkbox for the group.
      • [cssClass] Object optional
        active, focus, and check CSS class to be applied to the master Checkbox correspondingly.
      • [cssClass.active] Object optional
        CSS class to be set when the Checkbox is active.
      • [cssClass.focus] Object optional
        CSS class to be set when the master Checkbox is focused.
      • [cssClass.check] Object optional
        CSS class to be set when the master Checkbox is checked.
      • [label] Object optional
        check and uncheck label texts to be applied to the master Checkbox labels.
      • [label.check] Object optional
        A text to be set as a label when the master Checkbox is checked
      • [label.uncheck] Object optional
        A text to be set as a label when the master Checkbox is unchecked
      • [onChnage] Function optional
        A function to be called when the state of the master Checkbox changes.

Returns:

CheckboxGroup:

A control objects allowing to toggle individual checkboxes in a group as well as the group as a whole.

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
)
private

Emits a TOGGLE event when the checkbox's state is changed.

Parameters:

  • agency String

    Specified the agency that toggled the Checkbox.

setEachState

(
  • fcn
)
chainable

Toggle all the checkboxes based on the return value of the given function.

Parameters:

  • fcn Function

    a 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]
)
chainable

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:287

Toggles the state of the specified Checkbox. If checkboxId is not supplied, toggles the whole group.

Parameters:

  • state Boolean

    Specifies the state of the checkbox: true, false

  • [checkboxId] String optional

    Specifies the checkbox to toggle.

Returns:

CheckboxGroup

validate

() Checkbox chainable

Validates that the checkbox node is in fact in dom. If not, set checkbox's state to "checkbox-invalid" to prevent any interactions.

Returns:

Checkbox:

Control object for chaining

Properties

agency

Object private

An object specifying possible agencies that can affect the Checkbox.

Example:

 agency: {
                          USER: "USER",
                          CODE: "CODE"
                      }
                    

cssClass

Object

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:93

active, focus, and check CSS class to be applied to the Checkbox correspondingly.

Example:

 cssClass: {
                         active: "active",
                         focus: "focused",
                         check: "checked"
                     }
                    

event

Object private

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:354

Event names published by the Checkbox

Default: null

Example:

 {
                         MEMBER_TOGGLE: "checkbox/toggled",
                         MASTER_TOGGLE: "checkbox/toggled"
                     }
                    

id

String

Id of the Checkbox as specified by nodeIdAttr.

Default: null

label

Object

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:112

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

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:75

Name of the "data-*" attribute set on the checkbox node to be treated as the checkbox id.

Default: "id"

nodes

Array

An array of the Checkbox object belonging to the body of the group.

Default: []

nodes

JArray

Nodes of the checkbox nodes originally supplied to the CheckboxGroup.

Default: []

onChnage

Function

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:129

A function to be called when the state of the Checkbox changes.

Example:

 function () { }
                    

state

Boolean | String

State of the Checkbox: true | false or INVALID

Default: null

Events

MASTER_TOGGLE

Published whenever the master Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      master Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox

MEMBER_TOGGLE

Published whenever a Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox

TOGGLE

private

Inherited from Checkbox but overwritten in src\js\RAMP\Utils\checkboxGroup.js:368

This event is not published by CheckboxGroup. Ignore this.