### JavaScript Setup Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-fixed-bottom.html Include the necessary JavaScript files for Bootstrap, jQuery, SmartMenus, and the SmartMenus Bootstrap Addon. The order of inclusion is important. ```APIDOC ``` -------------------------------- ### SmartMenus HTML Structure and Initialization Source: https://context7.com/vadikom/smartmenus/llms.txt This example shows the required HTML structure for a SmartMenus navigation, including CSS and JavaScript includes, and basic initialization. ```html ``` -------------------------------- ### CommonJS / npm Usage of SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Load and initialize SmartMenus using CommonJS (npm/Browserify/Webpack). Ensure jQuery, smartmenus, and smartmenus-keyboard are installed as dependencies. ```javascript // package.json dependencies: jquery, smartmenus, smartmenus-keyboard var $ = require('jquery'); require('smartmenus'); require('smartmenus-keyboard'); $(function() { $('#main-menu').smartmenus({ showTimeout: 100 }); }); ``` -------------------------------- ### CSS Transition Animation Example for SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Configure SmartMenus to use CSS transitions for animations by setting durations to 0 and controlling opacity via JavaScript and CSS. ```javascript $('#css-menu').smartmenus({ showDuration: 0, hideDuration: 0, showFunction: function($ul, complete) { $ul.css('opacity', 0).show().animate({ opacity: 1 }, 200, complete); }, hideFunction: function($ul, complete) { $ul.animate({ opacity: 0 }, 150, function() { $ul.hide(); complete(); }); } }); ``` -------------------------------- ### ES6 Modules Usage of SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Import and initialize SmartMenus using ES6 modules with a bundler. Requires jQuery and SmartMenus to be installed. ```javascript import $ from 'jquery'; import 'smartmenus'; $(function() { $('#main-menu').smartmenus(); }); ``` -------------------------------- ### Fade Animation Example for SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Implement a fade-in/fade-out animation for sub-menus using jQuery's fadeIn/fadeOut methods. ```javascript $('#fade-menu').smartmenus({ showFunction: function($ul, complete) { $ul.fadeIn(200, complete); }, hideFunction: function($ul, complete) { $ul.fadeOut(150, complete); } }); ``` -------------------------------- ### Customize Highlight Classes with data-sm-options Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-4-navbar-fixed-top.html Use the `data-sm-options` attribute to pass custom CSS classes for highlighting expanded parent dropdown items. The example sets classes for dark text and a light background. ```html
``` -------------------------------- ### API Methods Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-fixed-bottom.html The SmartMenus Bootstrap Addon provides methods for dynamic initialization. ```APIDOC ## API Methods ### `jQuery.SmartMenus.Bootstrap.init()` Reinitializes the addon. This is useful if you dynamically add any navbars to your page after the initial load and need to apply SmartMenus features to them. All navbars are normally initialized automatically on `domready`. ``` -------------------------------- ### Implement Keyboard Navigation Source: https://context7.com/vadikom/smartmenus/llms.txt Include the keyboard addon script to enable arrow key navigation and optional hotkeys. ```html ``` -------------------------------- ### Initialize SmartMenus with Custom Options Source: https://context7.com/vadikom/smartmenus/llms.txt Initialize SmartMenus with custom configuration options to control behavior like sub-menu offsets and timeouts. The DOM must be ready. ```javascript $(function() { $('#main-menu').smartmenus({ subMenusSubOffsetX: 1, subMenusSubOffsetY: -8, showTimeout: 150, hideTimeout: 300 }); }); ``` -------------------------------- ### Instance Methods Source: https://context7.com/vadikom/smartmenus/llms.txt Methods available on the SmartMenus instance for programmatic control. ```APIDOC ## Instance Methods ### Description Access the SmartMenus instance to call methods directly for programmatic control of menu behavior. ### Methods - **destroy()**: Removes all SmartMenus functionality. - **refresh()**: Refreshes the menu (useful after dynamically adding items). - **disable(noOverlay)**: Disables the menu. If noOverlay is true, disables without showing the overlay. - **enable()**: Enables a disabled menu. - **menuHideAll()**: Hides all visible sub-menus. - **itemActivate($item)**: Programmatically activates a menu item. - **isCollapsible()**: Returns true if the menu is in collapsible (mobile) mode. ``` -------------------------------- ### Initialize SmartMenus with Browserify Source: https://github.com/vadikom/smartmenus/blob/master/README.md Require jQuery, the plugin, and addons in an entry file to initialize the menu on the DOM. ```javascript var jQuery = require('jquery'); require('smartmenus'); require('smartmenus-keyboard'); jQuery(function() { jQuery('#main-menu').smartmenus(); }); ``` -------------------------------- ### Initialize SmartMenus with Options Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/index.html Initializes the SmartMenus plugin on an element with custom sub-menu offset options. Ensure the DOM is ready before calling this. ```javascript $(function() { $('#main-menu').smartmenus({ subMenusSubOffsetX: 1, subMenusSubOffsetY: -8 }); }); ``` -------------------------------- ### Initialize SmartMenus with Default Options Source: https://context7.com/vadikom/smartmenus/llms.txt Use this snippet to initialize the SmartMenus plugin on an element with its default settings. Ensure the DOM is ready before calling. ```javascript $.fn.extend({ smartmenus: function(options) { return this.each(function() { // Plugin logic here }); } }); ``` -------------------------------- ### Initialize SmartMenus with JavaScript Options Source: https://context7.com/vadikom/smartmenus/llms.txt Configure SmartMenus behavior by passing an options object during initialization. This method allows fine-grained control over all aspects of the menu. ```javascript $"#main-menu".smartmenus({ // Popup menu mode (show via popupShow method) isPopup: false, // Sub-menu positioning offsets mainMenuSubOffsetX: 0, // Horizontal offset for first-level subs mainMenuSubOffsetY: 0, // Vertical offset for first-level subs subMenusSubOffsetX: 0, // Horizontal offset for deeper subs subMenusSubOffsetY: 0, // Vertical offset for deeper subs // Sub-menu dimensions subMenusMinWidth: '10em', // Minimum width (CSS unit) subMenusMaxWidth: '20em', // Maximum width (CSS unit) // Sub-menu indicators subIndicators: true, // Show sub-menu arrow indicators subIndicatorsPos: 'append', // Position: 'append' or 'prepend' subIndicatorsText: '', // Text content for indicator span // Scrolling for long sub-menus scrollStep: 30, // Pixels per scroll step scrollAccelerate: true, // Enable scroll acceleration // Timing showTimeout: 250, // Delay before showing sub-menus (ms) hideTimeout: 500, // Delay before hiding sub-menus (ms) showDuration: 0, // Animation duration for showing hideDuration: 0, // Animation duration for hiding // Click behavior showOnClick: false, // Show first-level subs on click only hideOnClick: true, // Hide subs on outside click/tap noMouseOver: false, // Disable hover activation // Viewport handling keepInViewport: true, // Auto-reposition to stay in viewport keepHighlighted: true, // Keep parent items highlighted // Current item marking markCurrentItem: false, // Auto-mark current page item markCurrentTree: true, // Mark ancestor items too // Direction rightToLeftSubMenus: false, // RTL sub-menu positioning bottomToTopSubMenus: false, // Bottom-to-top sub-menus // Mobile/collapsible behavior collapsibleBehavior: 'default', // Options: 'default', 'toggle', 'link', // 'accordion', 'accordion-toggle', 'accordion-link' // Custom animation functions showFunction: null, hideFunction: function($ul, complete) { $ul.fadeOut(200, complete); }, collapsibleShowFunction: function($ul, complete) { $ul.slideDown(200, complete); }, collapsibleHideFunction: function($ul, complete) { $ul.slideUp(200, complete); } }); ``` -------------------------------- ### Define package.json for Browserify Source: https://github.com/vadikom/smartmenus/blob/master/README.md Specify dependencies for a project using SmartMenus and the keyboard addon via npm. ```json { "name": "myapp-using-smartmenus", "version": "1.0.0", "license": "MIT", "dependencies": { "jquery": ">=2.1.3", "smartmenus": ">=1.1.0", "smartmenus-keyboard": ">=0.4.0" }, "devDependencies": { "browserify": ">=9.0.3" } } ``` -------------------------------- ### jQuery.SmartMenus.Bootstrap.init() Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar.html Reinitializes the SmartMenus Bootstrap addon. This is useful when navbars are added to the DOM dynamically after the initial page load. ```APIDOC ## jQuery.SmartMenus.Bootstrap.init() ### Description Reinitializes the SmartMenus Bootstrap addon. This method is useful if you add any navbars dynamically on your page and need to initialize them, as all navbars are normally initialized on DOM ready. ### Method JavaScript Method ### Usage `jQuery.SmartMenus.Bootstrap.init();` ``` -------------------------------- ### Initialize SmartMenus with Keyboard Hotkey Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/keyboard-navigation.html Initializes SmartMenus with specific offsets and sets a keyboard hotkey for menu navigation. The hotkey is configured using a key code and a modifier string. ```javascript $(function() { $('#main-menu').smartmenus({ subMenusSubOffsetX: 1, subMenusSubOffsetY: -8 }); $('#main-menu').smartmenus('keyboardSetHotkey', '123', 'shiftKey'); }); ``` -------------------------------- ### AMD Usage of SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Load and initialize SmartMenus using AMD (RequireJS). Ensure jQuery is loaded before SmartMenus. ```javascript define(['jquery', 'smartmenus'], function($) { $(function() { $('#main-menu').smartmenus(); }); }); ``` -------------------------------- ### Initialize SmartMenus Bootstrap Addon Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-fixed-top.html Call `jQuery.SmartMenus.Bootstrap.init()` to reinitialize the addon, which is useful for dynamically added navbars. ```javascript jQuery.SmartMenus.Bootstrap.init() ``` -------------------------------- ### Integrate with Bootstrap 4 Source: https://context7.com/vadikom/smartmenus/llms.txt Use the Bootstrap 4 addon for zero-configuration integration with standard navbar structures. ```html ``` -------------------------------- ### Static Methods Source: https://context7.com/vadikom/smartmenus/llms.txt Global operations provided by the $.SmartMenus object. ```APIDOC ## Static Methods ### Description SmartMenus provides static methods on the $.SmartMenus object for global operations across all menu instances. ### Methods - **$.SmartMenus.hideAll()**: Hides all sub-menus in all SmartMenus instances on the page. - **$.SmartMenus.destroy()**: Destroys all SmartMenus instances on the page. ``` -------------------------------- ### Include Bootstrap CSS Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-fixed-bottom.html Link to the Bootstrap core CSS file. Ensure this is included for proper styling. ```html ``` -------------------------------- ### Configure SmartMenus with Data Attributes Source: https://context7.com/vadikom/smartmenus/llms.txt Specify SmartMenus options directly on the menu element using the `data-sm-options` attribute for declarative configuration. Initialization then uses these attributes by default. ```html ``` -------------------------------- ### Include Bootstrap and SmartMenus CSS Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-static-top.html Include these CSS files in your HTML head to enable Bootstrap styling and SmartMenus Bootstrap Addon functionality. No further configuration is needed for basic usage. ```html ``` ```html ``` -------------------------------- ### Options Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-4-navbar.html Additional options that can be configured via the `data-sm-options` attribute. ```APIDOC ## Options ### `bootstrapHighlightClasses` - **Description**: CSS class(es) for highlighting expanded parent dropdown items. - **Default**: `'text-dark bg-light'` - **Usage**: Set via the `data-sm-options` attribute, e.g., `data-sm-options="bootstrapHighlightClasses: 'my-custom-class'"`. [Refer to the SmartMenus documentation for a complete list of available options.](https://www.smartmenus.org/docs/#options) ``` -------------------------------- ### RTL Sub-Menus via Options Source: https://context7.com/vadikom/smartmenus/llms.txt Enable right-to-left sub-menu behavior programmatically using the 'rightToLeftSubMenus' option. ```javascript $('#main-menu').smartmenus({ rightToLeftSubMenus: true }); ``` -------------------------------- ### Configure RequireJS (AMD) for SmartMenus Source: https://context7.com/vadikom/smartmenus/llms.txt Configure RequireJS to load jQuery and the SmartMenus plugin. Used for AMD module systems. ```javascript requirejs.config({ paths: { 'jquery': 'libs/jquery', 'smartmenus': 'jquery.smartmenus.min' } }); ``` -------------------------------- ### API Method Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-4-navbar.html The available API method for interacting with the SmartMenus Bootstrap addon. ```APIDOC ## API ### `jQuery.SmartMenus.Bootstrap.init()` - **Description**: Reinitializes the SmartMenus addon. This is useful if you dynamically add any navbars to your page and need to initialize them at a later time. All navbars are normally initialized on `domready`. - **Usage**: `jQuery.SmartMenus.Bootstrap.init();` ``` -------------------------------- ### Include Bootstrap and SmartMenus JavaScript Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-4-navbar-fixed-top.html Include jQuery, Popper.js, Bootstrap JS, the SmartMenus jQuery plugin, and the SmartMenus Bootstrap 4 Addon in your HTML. Ensure the order is correct. ```html ``` -------------------------------- ### Configure RequireJS for SmartMenus Source: https://github.com/vadikom/smartmenus/blob/master/README.md Define the path for the SmartMenus plugin to ensure addons can resolve the module name correctly. ```javascript requirejs.config({ "paths": { 'smartmenus': 'jquery.smartmenus.min' } // ... ``` -------------------------------- ### Bottom-to-Top Sub-Menus via Options Source: https://context7.com/vadikom/smartmenus/llms.txt Configure sub-menus to open from bottom-to-top, useful for fixed-bottom navigation bars, using the 'bottomToTopSubMenus' option. ```javascript $('#footer-menu').smartmenus({ bottomToTopSubMenus: true }); ``` -------------------------------- ### API Methods Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-navbar-fixed-top.html The SmartMenus Bootstrap Addon provides the following API method for programmatic control. ```APIDOC ## API The following methods are available: * `jQuery.SmartMenus.Bootstrap.init()` - reinit the addon. Useful if you add any navbars dynamically on your page and need to init them (all navbars are normally initialized ondomready). ``` -------------------------------- ### Configure and Use SmartMenus as a Popup Menu Source: https://context7.com/vadikom/smartmenus/llms.txt Initialize SmartMenus with popup mode enabled and use the popup API to show and hide context or popup menus at specific coordinates. Useful for right-click menus. ```javascript // Initialize as popup menu $('#popup-menu').smartmenus({ isPopup: true, hideOnClick: true }); // Show popup at mouse position on right-click $(document).on('contextmenu', function(e) { e.preventDefault(); $('#popup-menu').smartmenus('popupShow', e.pageX, e.pageY); }); // Hide the popup programmatically $('#popup-menu').smartmenus('popupHide'); // Hide immediately without timeout $('#popup-menu').smartmenus('popupHide', true); ``` -------------------------------- ### keyboardSetHotkey Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/keyboard-navigation.html Sets a hotkey combination to send focus to the menu tree. This allows users to quickly access the menu using a keyboard shortcut. ```APIDOC ## POST /api/smartmenus/keyboardSetHotkey ### Description Sets a hotkey combination that will send focus to the menu tree. ### Method POST ### Endpoint /api/smartmenus/keyboardSetHotkey ### Parameters #### Request Body - **keyCode** (Integer) - Required - The key code for the hotkey. - **modifiers** (String, Array) - Required - The hotkey modifier key. Can be 'ctrlKey', 'shiftKey', 'altKey', 'metaKey', or an array of these. ### Request Example ```json { "keyCode": 123, "modifiers": "shiftKey" } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create Multi-level Navbar with Bootstrap 4 Source: https://github.com/vadikom/smartmenus/blob/master/src/demo/bootstrap-4-navbar.html Replace standard div-based dropdown menus with nested ul/li structures to enable multi-level menu support. ```html