Class core.StepIterator
Defined in: StepIterator.js.
Constructor Attributes | Constructor Name and Description |
---|---|
core.StepIterator(filter, iterator)
Creates a helper class for navigating by steps.
|
Method Attributes | Method Name and Description |
---|---|
advanceStep(direction)
Advance the iterator by one step in the specified direction.
|
|
<inner> |
Return the container for the current position.
|
<inner> |
isStep()
Returns true if the current iterator position is accepted by the supplied filter
|
leftNode()
Return the node to the left of the current iterator position.
|
|
<inner> |
nextStep()
Move to the next step.
|
<inner> |
offset()
Get the current unfiltered DOM offset of the underlying iterator
|
<inner> |
Move to the previous step.
|
restore(snapshot)
Restore the step iterator back to a specific position.
|
|
If the current position is not on a valid step, this function will move the iterator
to the closest previous step.
|
|
If the current position is not a valid step, move to the next step.
|
|
If the current position is not a valid step, move to the previous step.
|
|
<inner> |
setPosition(newContainer, newOffset)
Sets the position of the underlying iterator
|
snapshot()
Store a snapshot of the current step iterator position.
|
Class Detail
core.StepIterator(filter, iterator)
Creates a helper class for navigating by steps. Instances of this class are intended to be VERY
short-lived, and makes no guarantees about proper behaviour if the DOM or supplied filter is
modified during the lifetime of the object.
- Parameters:
- {!core.PositionFilter} filter
- Filter to apply to the iterator positions
- {!core.PositionIterator} iterator
- Substree to search for step within. Generally a paragraph or document root
Method Detail
{!boolean}
advanceStep(direction)
Advance the iterator by one step in the specified direction.
- Parameters:
- {!core.StepDirection} direction
- Returns:
- {!boolean}
<inner>
{!Element|!Text}
container()
Return the container for the current position.
- Returns:
- {!Element|!Text}
<inner>
{!boolean}
isStep()
Returns true if the current iterator position is accepted by the supplied filter
- Returns:
- {!boolean}
{?Node}
leftNode()
Return the node to the left of the current iterator position.
See PositionIterator.leftNode
- Returns:
- {?Node}
<inner>
{!boolean}
nextStep()
Move to the next step. Returns false if no step exists
- Returns:
- {!boolean}
<inner>
{!number}
offset()
Get the current unfiltered DOM offset of the underlying iterator
- Returns:
- {!number}
<inner>
{!boolean}
previousStep()
Move to the previous step. Returns false if no step exists
- Returns:
- {!boolean}
{undefined}
restore(snapshot)
Restore the step iterator back to a specific position. The input to this is
expected to be the direct result of a snapshot call.
- Parameters:
- {!core.StepIterator.StepSnapshot} snapshot
- Returns:
- {undefined}
{!boolean}
roundToClosestStep()
If the current position is not on a valid step, this function will move the iterator
to the closest previous step. If there is no previous step, it will advance to the next
closest step.
- Returns:
- {!boolean} Returns true if the iterator ends on a valid step
{!boolean}
roundToNextStep()
If the current position is not a valid step, move to the next step.
If there is no next step, returns false.
- Returns:
- {!boolean} Returns true if the iterator ends on a valid step
{!boolean}
roundToPreviousStep()
If the current position is not a valid step, move to the previous step.
If there is no previous step, returns false.
- Returns:
- {!boolean} Returns true if the iterator ends on a valid step
<inner>
{!boolean}
setPosition(newContainer, newOffset)
Sets the position of the underlying iterator
- Parameters:
- {!Node} newContainer
- {!number} newOffset
- Returns:
- {!boolean}
{!core.StepIterator.StepSnapshot}
snapshot()
Store a snapshot of the current step iterator position. Intended to be used
in conjunction with restore to be able to save & restore a particular position.
Note, the returned type should be treated as an opaque token, as the data structure
is allowed to change at any moment.
- Returns:
- {!core.StepIterator.StepSnapshot}