### MasterPage Script and Link Definitions
Source: https://www.smartmenus.org/docs
These are example script and link definitions for a MasterPage, using Page.ResolveURL for correct path resolution. They include jQuery, jQuery UI, Smartmenus core, and Smartmenus theme CSS.
```html
" rel="stylesheet" type="text/css" />
" rel="stylesheet" type="text/css" media="screen" />
" rel="stylesheet" type="text/css" media="screen" />
```
--------------------------------
### beforefirstshow Event
Source: https://www.smartmenus.org/docs
Fired only once for each sub menu, right before it's shown for the first time. You could use it, for example, for some initialization tasks that need to be called just once. You can cancel the event with `return false` and the sub menu will not be shown.
```APIDOC
## beforefirstshow Event
### Description
Fired only once for each sub menu, right before it's shown for the first time. You could use it, for example, for some initialization tasks that need to be called just once. You can cancel the event with `return false` and the sub menu will not be shown.
### Cancelable
Yes
### Arguments
- **e** (jQuery.Event) - The jQuery.Event object.
- **menu** (HTMLElement) - The sub menu `
');
// refresh the menu after the DOM operations
$menu.smartmenus('refresh');
```
```
--------------------------------
### Apply main menu classes
Source: https://www.smartmenus.org/docs
Use the required sm class for all menus, and optionally add sm-vertical for vertical layouts.
```html
...
```
```html
...
```
--------------------------------
### Set menu options with data-sm-options
Source: https://www.smartmenus.org/docs
Apply to the root
element to override JavaScript initialization options. Values must be valid JSON.
```html
...
```
--------------------------------
### SmartMenus Configuration Options
Source: https://www.smartmenus.org/docs
A comprehensive list of configuration options for customizing SmartMenus behavior.
```APIDOC
## SmartMenus Configuration Options
### Description
Configuration options for the SmartMenus library to control menu behavior, animations, and display logic.
### Options
- **bootstrapHighlightClasses** (String) - CSS class(es) for highlighting expanded parent dropdown items. Default: 'text-dark bg-light'.
- **bottomToTopSubMenus** (Boolean) - Determines if sub menus display from bottom to top. Default: false.
- **collapsibleBehavior** (String) - Parent items behavior in collapsible (mobile) view. Values: 'default', 'toggle', 'link', 'accordion', 'accordion-toggle', 'accordion-link'. Default: 'default'.
- **collapsibleHideDuration** (Integer) - Duration for hide animation for collapsible sub menus. Default: 0.
- **collapsibleHideFunction** (Function) - Custom function to use when hiding a collapsible sub menu. Default: function($ul, complete) { $ul.slideUp(200, complete); }.
- **collapsibleShowDuration** (Integer) - Duration for show animation for collapsible sub menus. Default: 0.
- **collapsibleShowFunction** (Function) - Custom function to use when showing a collapsible sub menu. Default: function($ul, complete) { $ul.slideDown(200, complete); }.
- **hideDuration** (Integer) - Duration in milliseconds for hide animation. Default: 0.
- **hideFunction** (Function) - Custom function to use when hiding a sub menu. Default: function($ul, complete) { $ul.fadeOut(200, complete); }.
- **hideOnClick** (Boolean) - Determines whether to hide sub menus on click/tap anywhere on the page. Default: true.
- **hideTimeout** (Integer) - Timeout in milliseconds before hiding sub menus on mouseout/focusout. Default: 500.
- **isPopup** (Boolean) - Determines whether the menu is a popup menu or a permanent menu bar. Default: false.
- **keepHighlighted** (Boolean) - Determines whether all ancestor items of the current sub menu should be kept highlighted. Default: true.
- **keepInViewport** (Boolean) - Determines whether the sub menus should be repositioned to stay in the viewport. Default: true.
- **mainMenuSubOffsetX** (Integer) - Horizontal offset in pixels for first-level sub menus. Default: 0.
- **mainMenuSubOffsetY** (Integer) - Vertical offset in pixels for first-level sub menus. Default: 0.
- **markCurrentItem** (Boolean) - Automatically add 'current' class to the item linking to the current page URL. Default: false.
- **markCurrentTree** (Boolean) - Automatically add 'current' class to all ancestor items. Default: true.
- **noMouseOver** (Boolean) - Disables mouseover interaction. Default: false.
```
--------------------------------
### Handle First Submenu Show Event
Source: https://www.smartmenus.org/docs
Fired only once for each submenu, right before it's shown for the first time. Useful for one-time initialization tasks. Can be canceled.
```javascript
$("#main-menu").on("beforefirstshow.smapi", function(e, menu) {});
```
--------------------------------
### Global Methods
Source: https://www.smartmenus.org/docs
These methods are global for all menu instances initialized on the page.
```APIDOC
## Global Methods
### destroy
Destroys all menu instances initialized on the page and cleans up all associated resources.
### Method
`$.SmartMenus.destroy()`
### Description
This method should be called when you want to completely remove all SmartMenus instances from the page and free up memory.
### Code Example
```javascript
$.SmartMenus.destroy();
```
### hideAll
Hides (resets) all sub menus of all menu instances on the page.
### Method
`$.SmartMenus.hideAll()`
### Description
Use this method to close all currently open sub menus across all SmartMenus instances on the page.
### Code Example
```javascript
$.SmartMenus.hideAll();
```
```
--------------------------------
### Basic HTML Menu Structure
Source: https://www.smartmenus.org/docs
Define your menu using a standard unordered list with the 'sm' class. Add theme classes like 'sm-blue' for styling.
```html
```
--------------------------------
### SmartMenus Configuration Options
Source: https://www.smartmenus.org/docs
Configuration options for SmartMenus plugin.
```APIDOC
## SmartMenus Configuration Options
This section details the various configuration options available for the SmartMenus jQuery plugin.
### Configuration Options
- **overlapControlsInIE** (Boolean) - Optional - Determines whether the script should make sure the sub menus appear on top of special OS controls in Internet Explorer. Deprecated and removed in v1.1.0. Default: `true`
- **rightToLeftSubMenus** (Boolean) - Optional - Determines whether the sub menus should be displayed from right to left instead of left to right. Default: `false`
- **scrollAccelerate** (Boolean) - Optional - Determines whether to accelerate scrolling or use a fixed step for long sub menus that do not fully fit in the viewport height. Default: `true`
- **scrollStep** (Integer) - Optional - Step in pixels when scrolling long sub menus that do not fit in the viewport height. Default: `30`
- **showDuration** (Integer) - Optional - The duration in milliseconds for show animation. Set it to 0 for no animation. Default: `0`
- **showFunction** (null, Function) - Optional - Custom function to use when showing a sub menu. Default: `null`. Example: `showFunction: function($ul, complete) { $ul.fadeIn(250, complete); }`
- **showOnClick** (Boolean) - Optional - Determines whether to show the first-level sub menus onclick instead of onmouseover. Default: `false`
- **showTimeout** (Integer) - Optional - The timeout in milliseconds before showing the sub menus on mouseover/focusin. Default: `250`
- **subIndicators** (Boolean) - Optional - Determines whether to create sub menu indicators. Default: `true`
- **subIndicatorsPos** (String) - Optional - Position of the sub menu indicator `` relative to the menu item content. Possible values: `'prepend'`, `'append'`. Default: `'append'`
- **subIndicatorsText** (String) - Optional - A text string to be added in the sub menu indicator ``. Default: `''`
- **subMenusMaxWidth** (String) - Optional - Max-width for the sub menus in any valid CSS unit. Default: `'20em'`
- **subMenusMinWidth** (String) - Optional - Min-width for the sub menus in any valid CSS unit. Default: `'10em'`
- **subMenusSubOffsetX** (Integer) - Optional - Allows setting a horizontal offset in pixels from the default position for the second+ level sub menus. Default: `0`
- **subMenusSubOffsetY** (Integer) - Optional - Allows setting a vertical offset in pixels from the default position for the second+ level sub menus. Default: `0`
```
--------------------------------
### Create CleanMenu Class (VB.NET)
Source: https://www.smartmenus.org/docs
This VB.NET class generates a clean, nested unordered list from the site map, suitable for navigation menus. It requires the Microsoft.VisualBasic namespace.
```vbnet
Imports Microsoft.VisualBasic
Partial Public Class CleanMenu
Inherits System.Web.UI.MasterPage
Private SitemapValue As String
Protected Property CleanMenu() As String
Get
Return SitemapValue
End Get
Set(value As String)
SitemapValue = value
End Set
End Property
Public Sub New(ByVal NavgiationListID As String, ByVal NavigationListClass As String)
SitemapValue = GenerateSitemap(NavgiationListID, NavigationListClass)
End Sub
Public Function GetCleanMenu() As String
Return SitemapValue
End Function
Private Function GenerateSitemap(ByVal NavgiationListID As String, ByVal NavigationListClass As String) As String
Dim sb As New StringBuilder
' Examine the RootNode, and navigate the SiteMap relative to it.
sb.Append("
")
' What nodes are children of the RootNode?
If (SiteMap.RootNode.HasChildNodes) Then
Dim rootNodesChildrenEnumerator As IEnumerator = SiteMap.RootNode.ChildNodes.GetEnumerator()
Dim node As SiteMapNode
While (rootNodesChildrenEnumerator.MoveNext())
node = CType(rootNodesChildrenEnumerator.Current, SiteMapNode)
If node.Url IsNot Nothing Then
sb.Append("
" & rootNodesChildrenEnumerator.Current.ToString() & vbCrLf)
End If
sb.Append(vbTab & List_Childnodes(CType(rootNodesChildrenEnumerator.Current, SiteMapNode)))
sb.Append("
")
End While
End If
sb.Append("
")
Return sb.ToString
End Function
Private Function List_Childnodes(Current_Node As SiteMapNode) As String
Dim sb As New StringBuilder
' What nodes are children of the function parameter?
If (Current_Node.HasChildNodes) Then
Dim childNodesEnumerator As IEnumerator = Current_Node.ChildNodes.GetEnumerator()
sb.Append(vbTab & "
")
While (childNodesEnumerator.MoveNext())
' Prints the Title of each node.
Dim node As SiteMapNode = CType(childNodesEnumerator.Current, SiteMapNode)
sb.Append(vbTab & "
" & vbCrLf)
End If
Return sb.ToString
End Function
End Class
```
--------------------------------
### Initialize SmartMenus with jQuery
Source: https://www.smartmenus.org/docs
Initialize the SmartMenus plugin on your menu element using jQuery's document ready function.
```javascript
$(function() {
$('#main-menu').smartmenus();
});
```
--------------------------------
### Enable RTL Support
Source: https://www.smartmenus.org/docs
Apply the sm-rtl class to the root ul element to enable right-to-left text support.
```html
...
...
```
--------------------------------
### Configure collapsibleShowFunction
Source: https://www.smartmenus.org/docs
Customizes the show animation for collapsible sub menus. Ensure the complete() callback is executed after the animation finishes.
```javascript
collapsibleShowFunction: function($ul, complete) { $ul.slideDown(250, complete); }
```
--------------------------------
### Show a Popup Menu
Source: https://www.smartmenus.org/docs
Shows a popup menu instance at specified coordinates. This method is only applicable to menus initialized with `isPopup: true`.
```javascript
// show the popup at left:100px;top:100px;
$('#popup-menu').smartmenus('popupShow', '100px', '100px');
// show the popup right below some target element
var $targetElm = $('#targetElm'),
targetOffset = $targetElm.offset();
$('#popup-menu').smartmenus('popupShow', targetOffset.left, targetOffset.top + $targetElm.outerHeight());
```
--------------------------------
### Include SmartMenus CSS Files
Source: https://www.smartmenus.org/docs
Include the core SmartMenus CSS and an optional theme like 'sm-blue' in the head section of your HTML.
```html
```
--------------------------------
### SmartMenus Initialization Script
Source: https://www.smartmenus.org/docs
This JavaScript code initializes the SmartMenus plugin on an element with the ID 'NavigationMenu'. Ensure jQuery is loaded before this script.
```javascript
$(function () {
$("#NavigationMenu").smartmenus();
});
```
--------------------------------
### beforeshow Event
Source: https://www.smartmenus.org/docs
Fired right before a sub menu is shown. You can cancel the event with `return false` and the sub menu will not be shown.
```APIDOC
## beforeshow Event
### Description
Fired right before a sub menu is shown. You can cancel the event with `return false` and the sub menu will not be shown.
### Cancelable
Yes
### Arguments
- **e** (jQuery.Event) - The jQuery.Event object.
- **menu** (HTMLElement) - The sub menu `
` element.
### Code Example
```javascript
$("#main-menu").on("beforeshow.smapi", function(e, menu) {});
```
```
--------------------------------
### Handle Submenu Shown Event
Source: https://www.smartmenus.org/docs
Fired right after a sub menu is shown.
```javascript
$("#main-menu").on("show.smapi", function(e, menu) {});
```
--------------------------------
### activate Event
Source: https://www.smartmenus.org/docs
Fired when an item is activated, right before its sub menu (if the item has a sub menu) is shown. You can cancel the event with `return false` and the item's sub menu will not be shown.
```APIDOC
## activate Event
### Description
Fired when an item is activated, right before its sub menu (if the item has a sub menu) is shown. You can cancel the event with `return false` and the item's sub menu will not be shown.
### Cancelable
Yes
### Arguments
- **e** (jQuery.Event) - The jQuery.Event object.
- **item** (HTMLElement) - The menu item `` element.
### Code Example
```javascript
$("#main-menu").on("activate.smapi", function(e, item) {});
```
```
--------------------------------
### Include SmartMenus JavaScript Files
Source: https://www.smartmenus.org/docs
Include jQuery and the SmartMenus jQuery plugin JS files before the closing