new (require("bajaux/commands/CommandGroup"))(params)
- Description:
A CommandGroup is a container for Commands and other CommandGroups.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | parameters - or just pass the Properties
|
Members
off
- Description:
Unregister a function callback handler for the specified event.
- Source:
- Since:
- Niagara 4.12
Unregister a function callback handler for the specified event.
on
- Description:
Register a function callback handler for the specified event.
- Source:
- Since:
- Niagara 4.12
Register a function callback handler for the specified event.
Methods
add(command) → {module:bajaux/commands/CommandGroup}
- Description:
Add a command to this group. Triggers a
bajaux:changecommandgroupevent. Multiple arguments can be specified to
add many commands at once.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
command |
module:bajaux/commands/Command | The command to add. |
Returns:
Return the CommandGroup instance.
doSort(kids) → {Array|Promise}
- Description:
Does the work of sorting this command group. By default, does nothing.
When overriding this method, be sure to return the sorted array as a
parameter todeferred.resolve.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
kids |
Array | An array of the command group's children - this may |
Returns:
an array containing the sorted children, or
a promise to be resolved with same
- Type
- Array | Promise
filter(options) → {module:bajaux/commands/CommandGroup}
- Description:
Filters the commands in this command group based on the results of
a test function, and returns a new, filtered CommandGroup instance.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | An options object literal Properties
|
Returns:
A filtered command group.
findCommand(id) → {module:bajaux/commands/Command|null}
- Description:
Find a Command in this CommandGroup (or sub CommandGroup) via its id and return it.
- Source:
Example
group.findCommand(DeleteCommand); // returns the first instance of DeleteCommand in the group if present.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
Number | function | an id, filter function, or Command constructor. A filter |
Returns:
return the found Command (or null if nothing found).
- Type
- module:bajaux/commands/Command | null
flatten(options) → {Array}
- Description:
Return a listing of the commands (not command groups) contained within
this group. Can optionally recursively visit down through any
sub-CommandGroups contained in this group (depth first) to return all
commands. Can optionally filter commands by flags as well.
- Source:
Example
cmdGroup.flatten(); // all child commands
cmdGroup.flatten(Command.flags.MENU); // only children with MENU flag
cmdGroup.flatten({ flags: Command.flags.MENU, recurse: true });
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | An options object. Properties
|
Returns:
An array of Commands.
- Type
- Array
get(index) → {module:bajaux/commands/Command|module:bajaux/commands/CommandGroup|null}
- Description:
Return a Command/CommandGroup based upon the index or
null if nothing can be found.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Returns:
getChildren() → {Array}
- Description:
Returns a defensive copy of this group's array of children.
- Source:
Returns:
- Type
- Array
getDisplayNameFormat() → {String}
- Description:
Return the format display name of this command group.
- Source:
Returns:
- Type
- String
getFlags() → {Number}
- Description:
Returns this group's flags.
- Source:
Returns:
- Type
- Number
getIcon() → {String}
- Description:
Return the CommandGroup's icon URI
- Source:
- Since:
- Niagara 4.12
Returns:
- Type
- String
hasFlags(flags)
- Description:
Check to see if this group's flags match any of the bits of the
input flags.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
flags |
Number | The flags to check against |
isCommand()
- Description:
Always returns false.
- Source:
isEmpty()
- Description:
Return true if this CommandGroup doesn't contain any children.
- Source:
Returns:
true if empty.
isLoading() → {boolean}
- Source:
Returns:
true if any of the Commands are still loading.
- Type
- boolean
isToggleCommand()
- Description:
Always returns false.
- Source:
jq(jqDomopt) → {JQuery}
- Description:
If a jQuery DOM argument is specified, this will set the DOM.
If not specified then no DOM will be set.
This method will always return the jQuery DOM associated with this CommandGroup.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
jqDom |
JQuery |
<optional> |
If specified, this will set the jQuery DOM. |
Returns:
A jQuery DOM object for firing events on.
- Type
- JQuery
loading() → {Promise}
- Description:
Return promise that will be resolved once all the Commands in this
group have been loaded.
- Source:
Returns:
A promise that will be resolved once all of the
child Commands have loaded.
- Type
- Promise
merge(group, paramsopt) → {module:bajaux/commands/CommandGroup|null}
- Description:
Merges an input command group with this one, and returns a new
command group with the merged results.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
group |
module:bajaux/commands/CommandGroup | The group to merge with |
|||||||||||
params |
object |
<optional> |
Properties
|
Returns:
the merged group, or
null if the merge could not be completed
- Type
- module:bajaux/commands/CommandGroup | null
remove(command) → {module:bajaux/commands/CommandGroup}
- Description:
Remove a command from this group. Triggers a
bajaux:changecommandgroupevent.
Multiple arguments
can be specified so multiple commands can be removed at once.
- Source:
Example
// Passing an id/index (Number)
commandGroup.remove(0); // Removes the 0 index kid from the group
// Passing a command (module:bajaux/commands/Command)
commandGroup.remove(command); // Removes the matching 'command' from the group
// Passing multiple commands (module:bajaux/commands/Command)
commandGroup.remove(command1, command2); // Removes the matching commands from the group
Parameters:
| Name | Type | Description |
|---|---|---|
command |
module:bajaux/commands/Command | Number | The command or index |
Returns:
Return the CommandGroup instance.
removeAll(options)
- Description:
Remove all children of this command group that match the input flag,
optionally emptying out child groups as well. Triggers a
bajaux:changecommandgroupevent.
- Source:
Example
cmdGroup.removeAll();
cmdGroup.removeAll(Command.flags.MENU_BAR);
cmdGroup.removeAll({ flags: Command.flags.MENU_BAR, recurse: true });
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | An options object Properties
|
setChildren(children)
- Description:
Sets this group's array of commands/groups wholesale. Triggers a
bajaux:changecommandgroupevent.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
children |
Array |
setDisplayNameFormat(displayName)
- Description:
Set the display name format of the command group. Triggers a
bajaux:changecommandgroupevent.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
displayName |
String | display name - supports baja Format syntax |
setFlags(flags)
- Description:
Sets this group's flags. Triggers a
bajaux:changecommandgroupevent.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
flags |
Number |
setIcon(icon)
- Description:
Sets the icon for this CommandGroup. Triggers a
bajaux:changecommandgroupevent.
- Source:
- Since:
- Niagara 4.12
Parameters:
| Name | Type | Description |
|---|---|---|
icon |
String | The CommandButton's icon (either a URI or a module:// ORD string) |
size() → {Number}
- Description:
Return the number of children the CommandGroup has
(this covers both Commands and CommandGroups).
- Source:
Returns:
- Type
- Number
sort() → {Promise}
- Description:
Sorts this command group. Typically will not be overridden; override
doSortinstead. Triggers abajaux:changecommandgroupevent.
- Source:
Returns:
A promise that will be invoked once the CommandGroup
has been sorted.
- Type
- Promise
toDisplayName() → {Promise.<String>}
- Description:
Formats the command's display name.
- Source:
Returns:
Promise to be resolved with the display name
- Type
- Promise.<String>
trigger(name)
- Description:
Triggers an event from this CommandGroup.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
visit(func)
- Description:
Visit through all of the Commands and CommandGroups.
The function passed it will be called for every Command and CommandGroup
found (including this CommandGroup).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
func |
Called for every CommandGroup and Command found. Each |