Class: wcMenu

wcMenu

The menu management class.


new wcMenu(container, options)

Parameters:
Name Type Argument Description
container external:jQuery~Object | external:jQuery~Selector | external:domNode The container element.
options wcMenu~Options <optional>
Custom options.
Source: menu.js, line 11

Methods


function addOption(categoryName, name, options) > Boolean

Adds a new file menu and/or toolbar option.

Parameters:
Name Type Description
categoryName String The top level category to place this option in the menu.
name String The name for the option.
options wcMenu~MenuOptions Custom options for the menu item.
Returns: Boolean

Success or failure.

Source: menu.js, line 134

function addSpacer(categoryName, name) > Boolean

Adds a spacer to a menu list.

Parameters:
Name Type Description
categoryName String The top level category to place this spacer in the menu.
name Number The name of the menu option, the spacer is inserted after.
Returns: Boolean

Success or failure.

Source: menu.js, line 407

function addToolbarSpacer(categoryName, name) > Boolean

Adds a spacer to the toolbar.

Parameters:
Name Type Description
categoryName String The top level category to place this spacer in the menu.
name Number The name of the toolbar option, the spacer is inserted after.
Returns: Boolean

Success or failure.

Source: menu.js, line 492

function optionCondition(categoryName, name, description) > Boolean

Replaces the description for an existing option.

Parameters:
Name Type Argument Description
categoryName String The top level category of the option.
name String The name of the option.
description String | wcMenu~MenuDescriptionFunc <optional>
The description to show as a tooltip for this option.
Returns: Boolean

Success or failure.

Source: menu.js, line 779

function optionCondition(categoryName, name, condition) > Boolean

Replaces the condition for an existing option.

Parameters:
Name Type Argument Description
categoryName String The top level category of the option.
name String The name of the option.
condition function <optional>
A function to call during the update to determine if the menu option should be enabled or disabled. Return false to disable the option.
Returns: Boolean

Success or failure.

Source: menu.js, line 924

function optionDisplay(categoryName, name, display) > Boolean

Replaces the display for an existing option.

Parameters:
Name Type Argument Description
categoryName String The top level category of the option.
name String The name of the option.
display wcMenu~MenuDisplayFunc <optional>
A function that returns the display text that should be shown on the menu option item. If not supplied, the default menu name will be applied.
Returns: Boolean

Success or failure.

Source: menu.js, line 625

function optionHotkeys(categoryName, name) > Boolean

Replaces the hotkeys for an existing option.

Parameters:
Name Type Description
categoryName String The top level category of the option.
name String The name of the option.
Returns: Boolean

Success or failure.

Properties:
Name Type Argument Description
hotkeys String <optional>
A string that describes hotkeys for your control, the format is 'Ctrl+Z' or 'Alt+Shift+L,Shift+L' for multiple.
Source: menu.js, line 833

function optionIcon(categoryName, name, icon) > Boolean

Replaces the icon for an existing option.

Parameters:
Name Type Argument Description
categoryName String The top level category of the option.
name String The name of the option.
icon String | wcMenu~MenuIconFunc <optional>
A classname to apply as an icon for the option. If this is a function, it will be called during the update call and should return the icon class.
Returns: Boolean

Success or failure.

Source: menu.js, line 724

function optionOnActivated(categoryName, name, onActivated) > Boolean

Replaces the activation handler for an existing option.

Parameters:
Name Type Description
categoryName String The top level category of the option.
name String The name of the option.
onActivated wcMenu~OnActivation A handler to call when the option is activated.
Returns: Boolean

Success or failure.

Source: menu.js, line 579

function optionToggle(categoryName, name, toggle) > Boolean

Replaces the toggle function for an existing option.

Parameters:
Name Type Argument Description
categoryName String The top level category of the option.
name String The name of the option.
toggle wcMenu~MenuToggleFunc <optional>
A function that returns the toggle state of the menu option item. If not supplied, option will no longer toggle.
Returns: Boolean

Success or failure.

Source: menu.js, line 672

function removeOption(categoryName, name, options) > Boolean

Removes an existing file menu and/or toolbar option.

Parameters:
Name Type Description
categoryName String The top level category to place this option in the menu.
name String The name to display for the option.
options wcMenu~MenuOptions Custom options for the menu item.
Returns: Boolean

Success or failure.

Source: menu.js, line 349

function removeSpacer(categoryName, name) > Boolean

Removes an existing spacer from the menu list.

Parameters:
Name Type Description
categoryName String The top level category where this spacer can be found.
name Number The name of the menu option to remove the spacer from.
Returns: Boolean

Success or failure.

Source: menu.js, line 449

function removeToolbarSpacer(categoryName, name) > Boolean

Removes an existing spacer from the toolbar.

Parameters:
Name Type Description
categoryName String The top level category where this spacer can be found.
name Number The name of the toolbar option to remove the spacer from.
Returns: Boolean

Success or failure.

Source: menu.js, line 536

function update()

Updates dynamic menus, if you've assigned options.manualUpdate = false, then you will need to call this yourself.

Source: menu.js, line 54

function version(tag) > String

Gets, or Sets the version tag to display in the right margin of the menu bar.

Parameters:
Name Type Argument Description
tag String <optional>
The version tag.
Returns: String
Source: menu.js, line 120

Type Definitions


inner typedef var MenuOptions

Custom options for a menu option.

Type: Object
Properties:
Name Type Argument Description
toggle wcMenu~MenuToggleFunc <optional>
A function that returns the current toggle state of the option.
display wcMenu~MenuDisplayFunc <optional>
A function that returns the display text that should be shown on the menu option item. If not supplied, the default menu name will be applied.
icon String | wcMenu~MenuIconFunc <optional>
A classname to apply as an icon for the option. If this is a function, it will be called during the update call and should return the icon class.
description String | wcMenu~MenuDescriptionFunc <optional>
The description to show as a tooltip for this option.
itemIndex Number <optional>
An insertion index to insert the item within the menu category, default is to append to the end.
categoryIndex Number <optional>
If this creates a new category, it will be inserted at this index in the top level menu.
toolbarIndex Boolean <optional>
If supplied, creates a toolbar button for this option and inserts it in the tab bar at the specified index. -1 will append it to the end.
hotkeys String <optional>
A string that describes hotkeys for your control, the format is 'Ctrl+Z' or 'Alt+Shift+L,Shift+L' for multiple.
condition function <optional>
A function to call during the update to determine if the menu option should be enabled or disabled. Return false to disable the option.
Source: menu.jsdoc, line 44

inner typedef var Options

Menu options.

Type: Object
Properties:
Name Type Argument Default Description
outer external:jQuery~Object | external:jQuery~Selector | external:domNode <optional>
'body' The outer container element, this is your main container area for the entire window.
data Object <optional>
A custom data object that will be passed to all event handlers.
manualUpdate Boolean <optional>
Set true if you want to handle the menu update yourself.
version String <optional>
A version tag to display in the right margin of the menu bar.
Source: menu.jsdoc, line 1

inner typedef function MenuDescriptionFunc(data) > String

A callback that retrieves the description string for a menu option.

Parameters:
Name Type Description
data Object The custom data object from wcMenu~Options.
Returns: String
Source: menu.jsdoc, line 37

inner typedef function MenuDisplayFunc(data) > String

A callback that retrieves the display text for the menu option.

Parameters:
Name Type Description
data Object The custom data object from wcMenu~Options.
Returns: String
Source: menu.jsdoc, line 16

inner typedef function MenuIconFunc(data) > String

A callback that retrieves the icon class for a menu option.

Parameters:
Name Type Description
data Object The custom data object from wcMenu~Options.
Returns: String
Source: menu.jsdoc, line 30

inner typedef function MenuToggleFunc(data) > String

A callback that retrieves the current toggle state of the menu option.

Parameters:
Name Type Description
data Object The custom data object from wcMenu~Options.
Returns: String
Source: menu.jsdoc, line 23

inner typedef function OnActivation(data)

On click handler for menu and toolbar options.

Parameters:
Name Type Description
data Object The custom data object from wcMenu~Options.
Source: menu.jsdoc, line 10