Namespace: MenuManager

STX. MenuManager

This namespace is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)

This widget manages menus. First, it ensures that charts do not react to users clicking or tapping on menus that overlap the charting area. Then it also allows users to close menus by tapping outside of the menu area. This is accomplished through the use of invisible, temporary overlay divs. Menu manager is a singleton. It automatically exists and only one is required per page. Simply register your charts with the manager in order for it to automatically engage.


<static> attachColorPicker(colorClick, cpHolder, cb, noMenuBehavior)

Attach a color picker to a div (swatch).

Name Type Description
colorClick object

Should be the swatch DOM element

cpHolder object

Should be a DOM element that contains the color picker. If the color picker is within a dialog or menu then cpHolder should be that dialog or menu in order to assure that the color picker is closed when the menu or dialog is closed

cb function

The callback when the color is selected fc(color)

noMenuBehavior boolean

When set to true bypasses the menuing system, otherwise the color picker is treated as a menu element and will close whenever another menu is opened. Always use noMenuBehavior when the color picker is contained within a parent menu otherwise the color picker could get orphaned on the screen.

<static> cancelSingleClick()

Cancels a single click event that might otherwise have been picked up by a chart object when the user taps on the overlay to close the menu

<static> closeThisMenu()

Close the menu that an element lives in. For instance, when hitting enter in an input box contained within a menu simply send the input box itself in and the library will find and close the menu for you.

<static> destroy()

Clears out the MenuManager, eliminating all stxx references. To destroy the complete chart and related UI use STX.destroy

<static> disableMenus()

Disable the menuing system (for instance when a dialog is open)

<static> enableMenus()

Enable the menuing system (for instance after disabling it)

<static> makeMenus()

Initializes the menuing system. Menus should be of specified format, using class stxMenu to indicate an object that can be clicked to create a menu. class menuOutline should be assigned to a sub-element of the menu that is displayed or hidden. stxToggle should be assigned to any active element of the menu. The code in stxToggle will be run through either eval() or parsing of a JSON string with objects fn for the function name and args as the arguments array. For example, stxToggle='{"fn":"STXUI.changePeriodicity","args":["day"]}' which is the same as stxToggle='STXUI.changePeriodicity(day)' except the former avoids eval and automatically makes the element clicked available as 'this' in the function.

Hides any menus that are currently showing and re-enables touch and mouse events.

Name Type Argument Description
closeAll boolean <optional>

If true then all menus will be closed, otherwise just the top cascading menu will be closed

dontBlur boolean <optional>

Dont blur the currently active element, for instance when you have purposefully focused an element

Turns on a menu and disables touch and mouse events. Typically managed automatically but can be called programatically.

Name Type Description
name string

Name of menu. This should be unique so that clicking one menu will close an already open menu

callback function

This function will be called when the user taps outside of the menu, and passed the name

cascading boolean

Set to true if the menu is a cascade (2nd level) menu

<static> registerChart(stx)

Registers a chart with the menuManager. This should be called for each chart on the screen.

Name Type Description
stx object

The chart object

<static> useOverlays()

Override whether or not to use overlays. If overlays are not enabled then menus will still co-react but no overlay will be generated to allow tapping outside of the menus