new Dependent(args)
Object representing an element that depends on other elements.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | Object with the following keys (all of which are required) Properties
|
- Source:
Members
(static) comparisons
Comparison functions for comparing the value of an element with the specification from the dependency settings. If the object type can't be found in this list, the === operator is used by default.
Properties:
Name | Type | Description |
---|---|---|
RegExp |
function | |
Function |
function | |
Number |
function |
- Source:
Methods
checkConstraints(value, selectoropt, stateopt) → {bool}
Checks whether the value matches the requirements for this constraint.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | Array | object | Either the value of a state or an array/object of constraints. In the latter case, resolving the constraint continues. |
|
selector |
string |
<optional> |
The selector for this constraint. If undefined, there isn't yet a selector that this constraint applies to. In that case, the state key is propagates to a selector and resolving continues. |
state |
Drupal.states.State |
<optional> |
The state to check for this constraint. If undefined, resolving continues. If both selector and state aren't undefined and valid non-numeric strings, a lookup for the actual value of that selector's state is performed. This parameter is not a State object but a pristine state string. |
- Source:
Returns:
true or false, depending on whether this constraint is satisfied.
- Type
- bool
compare(reference, selector, state) → {bool}
Compares a value with a reference value.
Parameters:
Name | Type | Description |
---|---|---|
reference |
object | The value used for reference. |
selector |
string | CSS selector describing the dependee. |
state |
Drupal.states.State | A State object describing the dependee's updated state. |
- Source:
Returns:
true or false.
- Type
- bool
getDependees() → {object}
Gathers information about all required triggers.
- Source:
Returns:
An object describing the required triggers.
- Type
- object
initializeDependee(selector, dependeeStates)
Initializes one of the elements this dependent depends on.
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | The CSS selector describing the dependee. |
dependeeStates |
object | The list of states that have to be monitored for tracking the dependee's compliance status. |
- Source:
reevaluate()
Triggers change events in case a state changed.
- Source:
update(selector, state, value)
Update the value of a dependee's state.
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | CSS selector describing the dependee. |
state |
Drupal.states.state | A State object describing the dependee's updated state. |
value |
string | The new value for the dependee's updated state. |
- Source:
verifyConstraints(constraints, selector) → {bool}
Evaluates child constraints to determine if a constraint is satisfied.
Parameters:
Name | Type | Description |
---|---|---|
constraints |
object | Array | A constraint object or an array of constraints. |
selector |
string | The selector for these constraints. If undefined, there isn't yet a selector that these constraints apply to. In that case, the keys of the object are interpreted as the selector if encountered. |
- Source:
Returns:
true or false, depending on whether these constraints are satisfied.
- Type
- bool