Expand all

mw.guidedTour.StepBuilder

A builder for defining a step of a guided tour

Constructor

new mw.guidedTour.StepBuilder(tour, stepSpec) #

Constructs a StepBuilder

Parameters:

Name Type Description
tour mw.guidedTour.Tour

Tour the corresponding Step belongs to

stepSpec Object

See {mw.guidedTour.TourBuilder#step} for details.

Source:

Throws:

On invalid step name

Type
mw.guidedTour.TourDefinitionError

Methods

back(backValue) → {mw.guidedTour.StepBuilder}staticchainable #

Tell the step how to determine the back step Calling 'back' in the tour definition now automatically creates a back button if one isn't specified already.

Invalid values or return values from the callback (a step name that does not refer to a valid step, a StepBuilder that is not part of the same tour) will cause an mw.guidedTour.TourDefinitionError exception to be thrown when the step is requested.

Parameters:

Name Type Description
backValue mw.guidedTour.StepBuilder | string | function

Value used to determine the back step. Either:

  • a mw.guidedTour.StepBuilder; the corresponding step is always back; this must belong to the same tour
  • a step name as string; the corresponding step is always back
  • a Function that returns one of the above; this allows the back step to vary dynamically
Source:

Returns:

Type
mw.guidedTour.StepBuilder

Throws:

If this direction callback has has already been set

Type
mw.guidedTour.TourDefinitionError

Tell the step how to determine the back step Calling 'back' in the tour definition now automatically creates a back button if one isn't specified already.

next(nextValue) → {mw.guidedTour.StepBuilder}staticchainable #

Tell the step how to determine the next step. Calling 'next' in the tour definition now automatically creates a next button if one isn't specified already.

Invalid values or return values from the callback (a step name that does not refer to a valid step, a StepBuilder that is not part of the same tour) will cause an mw.guidedTour.TourDefinitionError exception to be thrown when the step is requested.

Parameters:

Name Type Description
nextValue mw.guidedTour.StepBuilder | string | function

Value used to determine the next step. Either:

  • a mw.guidedTour.StepBuilder; the corresponding step is always next; this must belong to the same tour
  • a step name as string; the corresponding step is always next
  • a Function that returns one of the above; this allows the next step to vary dynamically
Source:

Returns:

Type
mw.guidedTour.StepBuilder

Throws:

If this direction callback has has already been set

Type
mw.guidedTour.TourDefinitionError
Tell the step how to determine the next step.

transition(callback) → {mw.guidedTour.StepBuilder}staticchainable #

Tell the step what to do at possible transition points, such as when hooks and events that are being listened to fire.

The passed in callback is called to check whether the tour should move to a new step. The callback can return the step to move to, as a mw.guidedTour.StepBuilder or a step name. It may also return two special values:

  • gt.TransitionAction.HIDE - Hides the tour, but keeps the stored user state
  • gt.TransitionAction.END - Ends the tour, clearing the user state

The callback may also return nothing. In that case, it will not transition.

Invalid return values from the callback (a step name that does not refer to a valid step, a StepBuilder that is not part of the same tour, or a number that is not a valid TransitionAction) will cause a mw.guidedTour.TourDefinitionError exception to be thrown when the tour checks to see if it should transition.

Parameters:

Name Type Description
callback function

Callback called to determine whether to transition, and if so what to do (either move to another step or do a TransitionAction)

Properties:
Name Type Description
transitionEvent mw.guidedTour.TransitionEvent

Event that triggered the check; see mw.guidedTour.TransitionEvent for fields

return mw.guidedTour.StepBuilder | mw.guidedTour.TransitionAction | string

Step to move to, as StepBuilder or step name, a mw.guidedTour.TransitionAction for a special action, or falsy for no requested transition (see above).

Source:

Returns:

Type
mw.guidedTour.StepBuilder

Throws:

If StepBuilder.transition() has already been called, or callback is not a function

Type
mw.guidedTour.TourDefinitionError

Tell the step what to do at possible transition points, such as when hooks and events that are being listened to fire.