***************** foundation-wizard ***************** A wizard is a user interaction that is defined by a sequence of predefined steps. Usually it is used in conjunction with a form. Markup ====== .foundation-wizard ------------------ Indicates the element is a wizard. A wizard MUST NOT be nested inside another wizard. Selector Rule:: .foundation-wizard .foundation-wizard-step ----------------------- Indicates the element is a step of a wizard. It MUST be a descendant of ``.foundation-wizard`` element. Selector Rule:: .foundation-wizard .foundation-wizard-step [data-foundation-wizard-step-title] ----------------------------------- Indicates the title of the step. Selector Rule:: .foundation-wizard-step[data-foundation-wizard-step-title] .foundation-wizard-step-active ------------------------------ Indicates the step that is currently active. It MUST be applied to ``.foundation-wizard-step`` element. There MUST be exactly one active step at a time. ``foundation-wizard-stepchange`` event MUST be triggered after moving from one step to another. See ``foundation-wizard-stepchange`` event section for details. Selector Rule:: .foundation-wizard-step.foundation-wizard-step-active [data-foundation-wizard-step-validation] ---------------------------------------- ``false`` to skip validation for this particular step. Otherwise the validation is performed when step change is about to occur. Selector Rule:: .foundation-wizard-step[data-foundation-wizard-step-validation] .foundation-wizard-control ========================== Indicates the element to control the transition from one step to another. The ``.foundation-wizard`` element managed by this control is determined by the closest ancestor (i.e. equivalent using jQuery: ``control.closest(".foundation-wizard")``). Selector Rule:: .foundation-wizard-control [data-foundation-wizard-control-action] ======================================= Indicates the action to take. The valid values are: prev Go to previous step; ``.foundation-wizard-step-active`` and ``foundation-wizard-stepchange`` event MUST be handled accordingly. next Go to next step; ``.foundation-wizard-step-active`` and ``foundation-wizard-stepchange`` event MUST be handled accordingly. cancel Cancel the wizard; the component handling ``foundation-wizard`` is free to decide the behavior of cancel. Selector Rule:: .foundation-wizard-control[data-foundation-wizard-control-action] [data-foundation-wizard-control-src] ==================================== Indicates that upon control activation, additional steps will be fetched and added as the next steps. The valid value is a `URI Template `_, where each HTML input (e.g. ,
Upon clicking next, the value of ``[data-foundation-wizard-control-src]`` is expanded into ``/nextsteps.html?p1=abc&p2=xyz``. Event ===== foundation-wizard-stepchange ---------------------------- This event MUST be triggered after moving from one step to another. It is triggered at ``.foundation-wizard`` element, with the following parameters: .. code-block:: ts interface FoundationWizardStepchangeEvent { /** * @param to The current active step * @param from The previous active step */ (to: Element, from?: Element): void; } Example: .. code-block:: js $(document).on("foundation-wizard-stepchange", ".foundation-wizard", function(e, to, from) {}); AdaptTo Interface ================= type ``foundation-wizard`` condition ``.foundation-wizard`` returned type ``FoundationWizard`` .. code-block:: ts interface FoundationWizard { /** * Toggles the next button. This method will try to find all next buttons of the current step. * * @param enable A boolean value to determine whether the button should be enabled or disabled */ toggleNext(enable: boolean): void; /** * Toggles the prev button. This method will try to find all prev buttons of the current step. * * @param enable A boolean value to determine whether the button should be enabled or disabled */ togglePrev(enable: boolean): void; /** * Toggles the cancel button. This method will try to find all cancel buttons of the current step. * * @param enable A boolean value to determine whether the button should be enabled or disabled */ toggleCancel(enable: boolean): void; /** * Toggle an action button. This method will try to find all buttons of the current step with the given action. * * @param action=prev|next|cancel The action buttons to toggle * @param enable A boolean value to determine whether the button should be enabled or disabled */ toggle(action: string, enable: boolean): void; /** * Go to the next step. This method will show the next step regardless if it's logically make sense or not (e.g. due to validation). * If there is no next step, this method does nothing. */ next(): void; /** * Go to the previous step. This method will show the previous step regardless if it's logically make sense or not. * If there is no previous step, this method does nothing. */ prev(): void; /** * Appends the given array of step elements to the wizard. * * Since the wizard can have complex layout, the exact requirement of structure of the step element (the markup) is decided at the implementation level. * The implementation may transform the element to produce the final step element implementing .foundation-wizard-step. * * @param steps The steps to be appended * @param index The index the step is added. If not passed, the step is added as the last one. */ append(steps: Element[], index?: number): void; /** * Appends the given array of step elements to the wizard after the given reference step. * * Since the wizard can have complex layout, the exact requirement of structure of the step element (the markup) is decided at the implementation level. * The implementation may transform the element to produce the final step element implementing .foundation-wizard-step. * * @param steps The steps to be appended * @param refStep The reference step */ appendAfter(steps: Element[], refStep: Element): void; /** * Removes the given array of step elements from the wizard. * If the current step is removed, the resulting behaviour is undefined. * * @param steps The steps to be removed */ remove(steps: Element[]): void; /** * Returns the previous steps of the given step. */ getPrevSteps(step: Element): Element[]; } Validation ========== ``foundation-wizard`` implementation MUST provide validation of the current step just before changing to a next step depending on the configuration of ``[data-foundation-wizard-step-validation]``. Also, the next button of a step is enabled/disabled according to the validity of the step. Note for this particular feature, since it can be implemented generically to only depend on ``foundation-wizard`` vocabulary, it is provided OOTB. Implementor doesn't need to implement it.