### Install Dependencies for Smart Wizard Source: https://github.com/techlab/jquery-smartwizard/blob/master/README.md Provides commands to install the necessary dependencies, jQuery and smartwizard, using npm. Additional commands are included for installing Webpack-related packages if you are using Webpack. ```bash npm i jquery npm i smartwizard // If you are using Webpack, install npm i webpack webpack-cli style-loader css-loader --save-dev ``` -------------------------------- ### Initialize jQuery SmartWizard with Arrows Theme and SlideVertical Transition Source: https://github.com/techlab/jquery-smartwizard/blob/master/examples/multiple.html Initializes the second SmartWizard instance using the 'arrows' theme and a 'slideVertical' transition effect. Similar to the first wizard, it enables navigation buttons and provides custom 'Complete' and 'Cancel' actions. ```javascript function onFinish(){ alert('Finish Clicked'); } function onCancel(elm){ elm.smartWizard("reset"); } $(function() { // Smart Wizard 2 $('#smartwizard2').smartWizard({ selected: 0, theme: 'arrows', transition: { animation:'slideVertical' }, toolbar: { showNextButton: true, showPreviousButton: true, position: 'both', extraHtml: ` ` } }); }); ``` -------------------------------- ### Install Smart Wizard using NPM or Yarn Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Installs the Smart Wizard plugin using either the NPM or Yarn package managers. This is the recommended method for integrating the plugin into your project. ```bash # Using NPM npm install smartwizard # Using Yarn yarn add smartwizard ``` -------------------------------- ### Initialize jQuery SmartWizard with Round Theme and Fade Transition Source: https://github.com/techlab/jquery-smartwizard/blob/master/examples/multiple.html Initializes the first SmartWizard instance with a 'round' theme and 'fade' transition animation. It configures the toolbar to show both next and previous buttons, and includes custom 'Finish' and 'Cancel' buttons with associated JavaScript functions. ```javascript function onFinish(){ alert('Finish Clicked'); } function onCancel(elm){ elm.smartWizard("reset"); } $(function() { // Smart Wizard 1 $('#smartwizard1').smartWizard({ selected: 0, theme: 'round', transition: { animation:'fade' }, toolbar: { showNextButton: true, showPreviousButton: true, position: 'both', extraHtml: ` ` } }); }); ``` -------------------------------- ### Install jQuery Smart Wizard via CDN Source: https://github.com/techlab/jquery-smartwizard/blob/master/README.md Includes HTML snippets for including the Smart Wizard CSS and JavaScript files from jsDelivr and UNPKG CDNs. These are essential for the plugin to function correctly on a webpage. ```html ``` ```html ``` -------------------------------- ### Handle Wizard Initialization and Loading Events Source: https://context7.com/techlab/jquery-smartwizard/llms.txt The `initialized` event fires once when the SmartWizard plugin is first set up. The `loaded` event fires after the initial step has been fully displayed, indicating the wizard is ready for interaction. Both are useful for setup tasks. ```javascript // Fires once during plugin initialization $("#smartwizard").on("initialized", function(e) { console.log("Smart Wizard initialized"); }); // Fires after initial step is loaded and displayed $("#smartwizard").on("loaded", function(e) { console.log("Smart Wizard loaded and ready"); // Safe to interact with wizard here }); ``` -------------------------------- ### Complete Form Validation Example with jQuery SmartWizard Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Provides a full implementation of a multi-step form using jQuery SmartWizard, including validation on step leave, state management for errors, and handling form submission and cancellation. It utilizes HTML5 form validation and custom JavaScript functions. ```javascript $(function() { // Initialize wizard $('#smartwizard').smartWizard({ selected: 0, theme: 'arrows', transition: { animation: 'none' }, toolbar: { position: 'bottom', extraHtml: ` ` }, anchor: { enableDoneState: true, unDoneOnBackNavigation: true } }); // Validation on step leave $("#smartwizard").on("leaveStep", function(e, anchorObject, currentStepIdx, nextStepIdx, stepDirection) { if (stepDirection == 'forward') { let form = document.getElementById('form-' + (currentStepIdx + 1)); if (form && !form.checkValidity()) { form.classList.add('was-validated'); $('#smartwizard').smartWizard("setState", [currentStepIdx], 'error'); $('#smartwizard').smartWizard("fixHeight"); return false; } $('#smartwizard').smartWizard("unsetState", [currentStepIdx], 'error'); } return true; }); // Update UI on step show $("#smartwizard").on("showStep", function(e, anchorObject, stepIndex, stepDirection, stepPosition) { $("#btnFinish").prop('disabled', stepPosition !== 'last'); if (stepPosition === 'last') { showOrderSummary(); } }); }); function onConfirm() { let form = document.getElementById('form-4'); if (form && !form.checkValidity()) { form.classList.add('was-validated'); $('#smartwizard').smartWizard("setState", [3], 'error'); $('#smartwizard').smartWizard("fixHeight"); return false; } $('#smartwizard').smartWizard("unsetState", [3], 'error'); alert('Order placed successfully!'); } function onCancel() { $('#smartwizard').smartWizard("reset"); ['form-1', 'form-2', 'form-3', 'form-4'].forEach(function(id) { var form = document.getElementById(id); if (form) { form.reset(); form.classList.remove('was-validated'); } }); } ``` -------------------------------- ### Manage Step States (setState, unsetState) Source: https://context7.com/techlab/jquery-smartwizard/llms.txt The `setState()` and `unsetState()` methods allow for dynamic manipulation of visual states on specific wizard steps. Available states include `default`, `active`, `done`, `disable`, `hidden`, `error`, and `warning`. This is useful for form validation and guiding user interaction. ```javascript // Set error state on step 2 (0-indexed as 1) $('#smartwizard').smartWizard("setState", [1], 'error'); // Set warning state on multiple steps $('#smartwizard').smartWizard("setState", [2, 3], 'warning'); // Remove error state from step 2 $('#smartwizard').smartWizard("unsetState", [1], 'error'); // Disable specific steps $('#smartwizard').smartWizard("setState", [3], 'disable'); // Hide a step $('#smartwizard').smartWizard("setState", [2], 'hidden'); // Form validation with state management $("#smartwizard").on("leaveStep", function(e, anchorObject, currentStepIdx, nextStepIdx, stepDirection) { if (stepDirection == 'forward') { let form = document.getElementById('form-' + (currentStepIdx + 1)); if (form && !form.checkValidity()) { form.classList.add('was-validated'); $('#smartwizard').smartWizard("setState", [currentStepIdx], 'error'); return false; // Prevent navigation } $('#smartwizard').smartWizard("unsetState", [currentStepIdx], 'error'); } return true; }); ``` -------------------------------- ### Configure jQuery SmartWizard with All Options Source: https://github.com/techlab/jquery-smartwizard/blob/master/README.md This JavaScript snippet demonstrates how to initialize the jQuery SmartWizard plugin with all available configuration options. It covers settings for step selection, theming, navigation, animations, toolbar, anchor navigation, keyboard controls, language, and step states. Ensure jQuery and the SmartWizard plugin are included before this script. ```javascript $('#smartwizard').smartWizard({ selected: 0, // Initial selected step, 0 = first step theme: 'basic', // theme for the wizard, related css need to include for other than basic theme justified: true, // Nav menu justification. true/false autoAdjustHeight: true, // Automatically adjust content height backButtonSupport: true, // Enable the back button support enableUrlHash: true, // Enable selection of the step based on url hash transition: { animation: 'none', // Animation effect on navigation, none|fade|slideHorizontal|slideVertical|slideSwing|css(Animation CSS class also need to specify) speed: '400', // Animation speed. Not used if animation is 'css' easing: '', // Animation easing. Not supported without a jQuery easing plugin. Not used if animation is 'css' prefixCss: '', // Only used if animation is 'css'. Animation CSS prefix fwdShowCss: '', // Only used if animation is 'css'. Step show Animation CSS on forward direction fwdHideCss: '', // Only used if animation is 'css'. Step hide Animation CSS on forward direction bckShowCss: '', // Only used if animation is 'css'. Step show Animation CSS on backward direction bckHideCss: '', // Only used if animation is 'css'. Step hide Animation CSS on backward direction }, toolbar: { position: 'bottom', // none|top|bottom|both showNextButton: true, // show/hide a Next button showPreviousButton: true, // show/hide a Previous button extraHtml: '' // Extra html to show on toolbar }, anchor: { enableNavigation: true, // Enable/Disable anchor navigation enableNavigationAlways: false, // Activates all anchors clickable always enableDoneState: true, // Add done state on visited steps markPreviousStepsAsDone: true, // When a step selected by url hash, all previous steps are marked done unDoneOnBackNavigation: false, // While navigate back, done state will be cleared enableDoneStateNavigation: true // Enable/Disable the done state navigation }, keyboard: { keyNavigation: true, // Enable/Disable keyboard navigation(left and right keys are used if enabled) keyLeft: [37], // Left key code keyRight: [39] // Right key code }, lang: { // Language variables for button next: 'Next', previous: 'Previous' }, disabledSteps: [], // Array Steps disabled errorSteps: [], // Array Steps error warningSteps: [], // Array Steps warning hiddenSteps: [], // Hidden steps getContent: null // Callback function for content loading }); ``` -------------------------------- ### jQuery SmartWizard Initialization and Options Source: https://github.com/techlab/jquery-smartwizard/blob/master/README.md This section details how to initialize the SmartWizard plugin and provides a comprehensive list of configuration options for customizing its behavior and appearance. ```APIDOC ## Initialize SmartWizard with Options ### Description Initializes the SmartWizard plugin on a target element and configures its behavior using a set of options. ### Method JavaScript (jQuery Plugin) ### Endpoint N/A (Client-side JavaScript) ### Parameters #### Initialization Options - **selected** (number) - Optional - Initial selected step, 0 = first step. - **theme** (string) - Optional - Theme for the wizard. Requires corresponding CSS. - **justified** (boolean) - Optional - Nav menu justification. - **autoAdjustHeight** (boolean) - Optional - Automatically adjust content height. - **backButtonSupport** (boolean) - Optional - Enable the back button support. - **enableUrlHash** (boolean) - Optional - Enable selection of the step based on URL hash. - **transition** (object) - Optional - Animation effect on navigation. - **animation** (string) - Optional - Animation effect: 'none', 'fade', 'slideHorizontal', 'slideVertical', 'slideSwing', 'css'. - **speed** (string) - Optional - Animation speed (in ms). Not used if animation is 'css'. - **easing** (string) - Optional - Animation easing. Requires a jQuery easing plugin. - **prefixCss** (string) - Optional - CSS prefix for 'css' animation. - **fwdShowCss** (string) - Optional - Step show CSS animation on forward direction. - **fwdHideCss** (string) - Optional - Step hide CSS animation on forward direction. - **bckShowCss** (string) - Optional - Step show CSS animation on backward direction. - **bckHideCss** (string) - Optional - Step hide CSS animation on backward direction. - **toolbar** (object) - Optional - Toolbar configuration. - **position** (string) - Optional - Toolbar position: 'none', 'top', 'bottom', 'both'. - **showNextButton** (boolean) - Optional - Show/hide the Next button. - **showPreviousButton** (boolean) - Optional - Show/hide the Previous button. - **extraHtml** (string) - Optional - Extra HTML to show in the toolbar. - **anchor** (object) - Optional - Anchor navigation configuration. - **enableNavigation** (boolean) - Optional - Enable/Disable anchor navigation. - **enableNavigationAlways** (boolean) - Optional - Make all anchors clickable always. - **enableDoneState** (boolean) - Optional - Add done state to visited steps. - **markPreviousStepsAsDone** (boolean) - Optional - Mark previous steps as done when a step is selected by URL hash. - **unDoneOnBackNavigation** (boolean) - Optional - Clear done state when navigating back. - **enableDoneStateNavigation** (boolean) - Optional - Enable/Disable navigation using done state. - **keyboard** (object) - Optional - Keyboard navigation configuration. - **keyNavigation** (boolean) - Optional - Enable/Disable keyboard navigation (left/right keys). - **keyLeft** (array) - Optional - Array of key codes for the left arrow key. - **keyRight** (array) - Optional - Array of key codes for the right arrow key. - **lang** (object) - Optional - Language variables for buttons. - **next** (string) - Optional - Text for the Next button. - **previous** (string) - Optional - Text for the Previous button. - **disabledSteps** (array) - Optional - Array of step indices that are disabled. - **errorSteps** (array) - Optional - Array of step indices that have errors. - **warningSteps** (array) - Optional - Array of step indices that have warnings. - **hiddenSteps** (array) - Optional - Array of step indices that are hidden. - **getContent** (function) - Optional - Callback function for content loading. ### Request Example ```javascript $('#smartwizard').smartWizard({ selected: 0, theme: 'basic', justified: true, autoAdjustHeight: true, backButtonSupport: true, enableUrlHash: true, transition: { animation: 'none', speed: '400' }, toolbar: { position: 'bottom', showNextButton: true, showPreviousButton: true }, anchor: { enableNavigation: true, enableNavigationAlways: false, enableDoneState: true, markPreviousStepsAsDone: true, unDoneOnBackNavigation: false, enableDoneStateNavigation: true }, keyboard: { keyNavigation: true, keyLeft: [37], keyRight: [39] }, lang: { next: 'Next', previous: 'Previous' }, disabledSteps: [], errorSteps: [], warningSteps: [], hiddenSteps: [], getContent: null }); ``` ### Response N/A (This is a client-side initialization) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Retrieve Wizard Options and Step Info (getOptions, getStepInfo) Source: https://context7.com/techlab/jquery-smartwizard/llms.txt The `getOptions()` method returns an object containing the current configuration settings of the SmartWizard, while `getStepInfo()` provides details about the current step and the total number of steps. These methods are useful for inspecting the wizard's state and updating the UI accordingly. ```javascript // Get all current options var options = $('#smartwizard').smartWizard("getOptions"); console.log('Current theme:', options.theme); console.log('Animation:', options.transition.animation); // Get current step information var stepInfo = $('#smartwizard').smartWizard("getStepInfo"); console.log('Current step:', stepInfo.currentStep); console.log('Total steps:', stepInfo.totalSteps); // Update UI with step info $("#smartwizard").on("showStep", function(e, anchorObject, stepIndex, stepDirection, stepPosition) { let stepInfo = $('#smartwizard').smartWizard("getStepInfo"); $("#sw-current-step").text(stepInfo.currentStep + 1); $("#sw-total-step").text(stepInfo.totalSteps); }); ``` -------------------------------- ### getOptions() and getStepInfo() Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Retrieves the current wizard configuration options and detailed information about the wizard's steps, including the current step and total number of steps. ```APIDOC ## getOptions() and getStepInfo() ### Description Retrieves current wizard configuration and step information. `getOptions()` returns an object with all current settings, while `getStepInfo()` provides details about the current step and the total number of steps. ### Method `jQuery.fn.smartWizard("getOptions")` `jQuery.fn.smartWizard("getStepInfo")` ### Parameters None ### Request Example ```javascript // Get all current options var options = $('#smartwizard').smartWizard("getOptions"); console.log('Current theme:', options.theme); console.log('Animation:', options.transition.animation); // Get current step information var stepInfo = $('#smartwizard').smartWizard("getStepInfo"); console.log('Current step:', stepInfo.currentStep); console.log('Total steps:', stepInfo.totalSteps); // Update UI with step info $("#smartwizard").on("showStep", function(e, anchorObject, stepIndex, stepDirection, stepPosition) { let stepInfo = $('#smartwizard').smartWizard("getStepInfo"); $("#sw-current-step").text(stepInfo.currentStep + 1); $("#sw-total-step").text(stepInfo.totalSteps); }); ``` ### Response * **getOptions()**: Returns an object containing the current wizard configuration options. * **getStepInfo()**: Returns an object with `currentStep` (number) and `totalSteps` (number). ``` -------------------------------- ### Programmatically Navigate to a Specific Step Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Demonstrates how to programmatically control the wizard's current step using the `goToStep` method. It supports optional forcing of navigation, bypassing restrictions and marking previous steps as done. ```javascript // Navigate to step 3 (0-indexed) $('#smartwizard').smartWizard("goToStep", 2); // Force navigation to step 4, marking all previous steps as done $('#smartwizard').smartWizard("goToStep", 3, true); // Example: Go to step button implementation $('#btn-go-to').on('click', function() { var stepNumber = parseInt($('#step-selector').val()) - 1; $('#smartwizard').smartWizard("goToStep", stepNumber); }); // Force navigation example with confirmation $('#btn-go-to-forced').on('click', function() { var stepNumber = parseInt($('#step-selector').val()) - 1; $('#smartwizard').smartWizard("goToStep", stepNumber, true); }); ``` -------------------------------- ### setOptions(options) Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Dynamically updates wizard configuration options after initialization. This is useful for changing themes, animations, or toolbar positions on the fly. ```APIDOC ## setOptions(options) ### Description Dynamically updates wizard configuration options after initialization. This method allows for real-time adjustments to the wizard's appearance and behavior. ### Method `jQuery.fn.smartWizard("setOptions", options)` ### Parameters * **options** (object) - Required - An object containing the options to update. Refer to the plugin's initialization options for available properties. ### Request Example ```javascript // Change theme dynamically $('#smartwizard').smartWizard("setOptions", { theme: 'dots' }); // Update multiple options $('#smartwizard').smartWizard("setOptions", { theme: 'round', justified: false, transition: { animation: 'slideHorizontal', speed: '300' }, toolbar: { position: 'both' } }); // Theme selector implementation $('#theme_selector').on('change', function() { $('#smartwizard').smartWizard("setOptions", { theme: $(this).val() }); }); // Animation selector implementation $('#animation').on('change', function() { $('#smartwizard').smartWizard("setOptions", { transition: { animation: $(this).val() } }); }); ``` ### Response None ``` -------------------------------- ### Basic Smart Wizard Initialization and HTML Structure Source: https://context7.com/techlab/jquery-smartwizard/llms.txt Demonstrates the fundamental HTML structure required for Smart Wizard and its basic JavaScript initialization. This includes the wizard container, navigation list, content panels, and optional progress bar. ```html
${data.package.description}
${data.package.description}
Created by ${data.package.author.name}