Constructor
new StepsController(model, circular, initialStep)
Create a controller
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
model |
Array.<string> | Array.<Object> | Step items. Properties
|
||||||
circular |
boolean | Allow circular step indexing. |
||||||
initialStep |
string | The name of the step to start at. |
Properties:
Name | Type | Description |
---|---|---|
steps |
Array.<string> | Array.<Object> | Step items. |
currentStep |
string | The name of the active step item. |
circular |
boolean | If circular indexing is enabled. |
Members
currentIndex
Get the 0 based index of active step.
currentStepIndex
Get the 1 based index of active step.
currentStepNode
Get the active step item.
firstStepName
Get the name for the first step item.
length
Get the length of steps.
Methods
activate(step) → {boolean}
Set current step by name.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
step |
string | Object |
Properties
|
Returns:
If step is activated, without error.
- Type
- boolean
getIndex(nameQuery) → {number}
Get the 1 based index of the step by name.
Parameters:
Name | Type | Description |
---|---|---|
nameQuery |
string | The name of the step to check. |
Returns:
The index of the step if available.
- Type
- number
incrementIndex(increment) → {number}
Increment the index. Note: If in circular mode, it will always return an in bounds index.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
increment |
number | 1 | The value to increment by. |
Returns:
The index after increment.
- Type
- number
init()
Required by Alpine for automatic execution.
isActive(name) → {boolean}
Validate if step is active by name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name of step to check. |
Returns:
If the step is active.
- Type
- boolean
pickNext() → {boolean|string}
Get the next available step item. Note: If in circular mode, it will always return a step.
Returns:
The next step if available or false.
- Type
- boolean | string
pickPrevious() → {boolean|string}
Get the previous available step item. Note: If in circular mode, it will always return a step.
Returns:
The previous step if available or false.
- Type
- boolean | string
transitionTo(to) → {boolean}
Activate step by name.
Parameters:
Name | Type | Description |
---|---|---|
to |
string | Name of step to activate. |
Returns:
If the step was activated.
- Type
- boolean
transitionToNext() → {boolean}
Activate the next step.
Returns:
If the next step is activated.
- Type
- boolean
transitionToPrevious() → {boolean}
Activate the previous step.
Returns:
If the previous step is activated.
- Type
- boolean