nw-skeleton

Class: MenuHelper

mainScript. MenuHelper

MenuHelper class - handles and manages app menus and tray

Extends

Methods

_doLog(message, type, data, forceToWindow){undefined}

Parameters

Name Type Description
message string Message to be logged
type string Type of log message (debug, info, warning, error, group, groupCollaped, groupend)
data array An array of data strings that are to be applied to logging message
forceToWindow Boolean Flag to force logging to main window console

Return

Logs data to console

addBoundMethods(){undefined}

Return

Method that sets up this.boundMethods property by binding this objects functions to itself to be used as event listener handlers

createDirFileRecursive(fileName, mode, options, data){Boolean}

Parameters

Name Type Description
fileName string Absolute path to file
mode Number Octal mode definition (i.e. 0o775)
options Object Options object for fs.writeFileSync
data string Data to write to file

Return

Creates directory (recursive) and writes file to it

createDirRecursive(directory, mode){Boolean}

Parameters

Name Type Description
directory string Absolute directory path
mode Number Octal mode definition (i.e. 0o775)

Return

Creates directory recursively

finalize(){Boolean}

Return

Finalizes current class instance, setting up any additional properties etc. Entire app structure, including frontend app is available here

formatTimeNormalize(date, options, includeDate, omitSeconds){string}

Parameters

Name Type Description
date Date Date value to format
options Object Date format options
includeDate Boolean Flag to indicate whether to include date
omitSeconds Boolean Flag to indicate whether to omit seconds

Return

Format time normalized (Y-m-d H:i:s format)

getAppMenuItem(menuItemIndex, menuItems){Object|undefined}

Parameters

Name Type Description
menuItemIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')
menuItems Array.<Object> Optional menuItems array (for nested calls)

Return

Returns app menu item by its index

getChainLabelPath(itemChain, labelPaths){Array.<string>}

Parameters

Name Type Description
itemChain array Menu item chain, containing all parent items up to current menu item
labelPaths Array.<string> Array of menu labels

Return

Returns array of labels containing all parent labels up to current menu item label

getConfig(name, defaultValue){mixed}

Parameters

Name Type Description
name string String representing path to requested var (i.e. 'appConfig.appInfo.name')
defaultValue mixed Default value to be returned if configuration var is not found

Return

Returns configuration var value

getHelper(name){Object}

Parameters

Name Type Description
name string Name of the helper

Return

Returns instance of helper object based on passed parameter (or false if helper can't be found)

getMenuItem(menuItemIndex){Object}

Parameters

Name Type Description
menuItemIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')

Return

Gets menu item by its index

getMenuItemChain(menuItemIndex, parentIndex){Object}

Parameters

Name Type Description
menuItemIndex string Menu item index
parentIndex string Menu item parent index

Return

Gets menu item by its parent index, returning children as well

getMenuItemLabelPaths(menuItemIndex){Array.<string>}

Parameters

Name Type Description
menuItemIndex string Menu item index in format parentIndex_menuIndex (i.e '1_2')

Return

Returns array of labels containing all parent labels up to current menu item label

getMenuItemMethodName(menuItemIndex){string}

Parameters

Name Type Description
menuItemIndex string Menu item index in format parentIndex_menuIndex (i.e '1_2')

Return

Returns listener method name for current menu item

getStateVar(varPath, defaultValue){mixed}

Parameters

Name Type Description
varPath string String representing path to requested var (i.e. 'appData.appMainData.cancelable')
defaultValue mixed Default value to be returned if appState var is not found

Return

Returns appState var value

getTrayMenuItem(menuItemIndex, menuItems){Object|undefined}

Parameters

Name Type Description
menuItemIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')
menuItems Array.<Object> Optional menuItems array (for nested calls)

Return

Returns tray menu item by its index

handleMenuClick(menuIndex){mixed}

Parameters

Name Type Description
menuIndex string Menu item index in format parentIndex_menuIndex (i.e '1_2')

Return

Handles click on menu items

handleTrayClick(trayMenuItem){mixed}

Parameters

Name Type Description
trayMenuItem string Tray menu item index in format parentIndex_menuIndex (i.e '1_2')

Return

Handles click on tray menu items

initializeAppMenuItem(menuItemData, menuIndex){Object}

Parameters

Name Type Description
menuItemData Object Menu item data
menuIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')

Return

Initializes single app menu item

initializeAppMenuItemData(menuItemData, menuIndex){Array.<Object>}

Parameters

Name Type Description
menuItemData Object Menu item data from configuration
menuIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')

Return

Initializes single app menu item data using configuration data

initializeLogging(){BaseClass}

Return

Determines whether logging for this class is regulated through configuration, setting the logging by it (or warning if there are no configuration settings for this class)

log(message, type, data, force, forceToWindow){undefined}

Parameters

Name Type Description
message string Message to be logged
type string Type of log message (debug, info, warning, error, group, groupCollaped, groupend)
data array An array of data strings that are to be applied to logging message
force Boolean Flag to force logging output even if config does not allow it
forceToWindow Boolean Flag to force logging to main window console

Return

Logs message to console or stdout

printLog(message, type){undefined}

Parameters

Name Type Description
message string Message to print
type string Type of message

Return

Prints message to stdout with newline appended

updateAppMenuItem(menuItemIndex, menuItemUpdates){Object}

Parameters

Name Type Description
menuItemIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')
menuItemUpdates Object Object with values to update

Return

Updates app menu item for given menuIndex by merging it with menuItemUpdates

updateTrayMenuItem(menuItemIndex, menuItemUpdates){Object}

Parameters

Name Type Description
menuItemIndex string Menu index in format parentIndex_menuIndex (i.e '1_2')
menuItemUpdates Object Object with values to update

Return

Updates tray menu item for given menuIndex by merging it with menuItemUpdates