module:bajaux/commands/ToggleCommandGroup

module:bajaux/commands/ToggleCommandGroup

new (require("bajaux/commands/ToggleCommandGroup"))(params)

Description:
  • ToggleCommandGroup is a special CommandGroup that behaves like a radio button group.

Source:
Extends:
Examples
new ToggleCommandGroup({
  commands: [
    {
      module: "mymodule",
      lex: "mycommand1",
      value: 0
    },
    {
      module: "mymodule",
      lex: "mycommand2",
      value: 1
    },
    {
      module: "mymodule",
      lex: "mycommand3",
      value: 2
    }
  ],
  onChange: function (value) {
    // receives the values specified above.
    switch (value) {
      case 0:
      case 1:
      case 2:
    }
  }
});

Use a flat style for your toggle button group.

var buttonGroup = new CommandButtonGroup();
return buttonGroup.initialize(dom, { toggleGroup: true })
  .then(function () {
    return buttonGroup.load(toggleCommandGroup);
  });
Parameters:
Name Type Description
params object
Properties
Name Type Description
onChange function

provide a callback function that can work with the selected value

commands Array

An array of objects, each of which will pass through to making a
ToggleCommand. See module:bajaux/commands/Command for all acceptable parameters.
Pass an optional "value" parameter to a command configuration object to associate a value with it.

Extends

Members

off

Description:
  • Unregister a function callback handler for the specified event.

Source:
Since:
  • Niagara 4.12
Inherited From:

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
Inherited From:

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:changecommandgroup event. Multiple arguments can be specified to
    add many commands at once.

Source:
Inherited From:
Parameters:
Name Type Description
command module:bajaux/commands/Command

The command to add.

Returns:

Return the CommandGroup instance.

Type
module:bajaux/commands/CommandGroup

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 to deferred.resolve.

Source:
Inherited From:
Parameters:
Name Type Description
kids Array

An array of the command group's children - this may
include commands or sub-CommandGroups.

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:
Inherited From:
Parameters:
Name Type Description
options Object

An options object literal

Properties
Name Type Attributes Description
include function <optional>

A function that will receive a
command object and return true or false depending on whether to include
that command in the filtered results. If omitted, defaults to always
return true.

flags Number <optional>

A number containing flag bits to test on
each command. If omitted, defaults to Command.flags.ALL.

Returns:

A filtered command group.

Type
module:bajaux/commands/CommandGroup

findCommand(id) → {module:bajaux/commands/Command|null}

Description:
  • Find a Command in this CommandGroup (or sub CommandGroup) via its id and return it.

Source:
Inherited From:
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
function receives a Command instance and returns a boolean result - the first Command passing
the filter will be returned. If passing a Command constructor, the first Command that is an
instance of that constructor will be returned.

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:
Inherited From:
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
Name Type Attributes Description
flags Number <optional>

flags Used to filter commands. If omitted,
includes all commands regardless of flags.

recurse Boolean <optional>

true if should recurse down through any
sub-groups.

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:
Inherited From:
Parameters:
Name Type Description
index Number
Returns:
Type
module:bajaux/commands/Command | module:bajaux/commands/CommandGroup | null

getChildren() → {Array}

Description:
  • Returns a defensive copy of this group's array of children.

Source:
Inherited From:
Returns:
Type
Array

getDisplayNameFormat() → {String}

Description:
  • Return the format display name of this command group.

Source:
Inherited From:
Returns:
Type
String

getFlags() → {Number}

Description:
  • Returns this group's flags.

Source:
Inherited From:
Returns:
Type
Number

getIcon() → {String}

Description:
  • Return the CommandGroup's icon URI

Source:
Since:
  • Niagara 4.12
Inherited From:
Returns:
Type
String

getSelected() → {module:bajaux/commands/ToggleCommand}

Description:
  • Get the selected command

Source:
Returns:

The selected ToggleCommand

Type
module:bajaux/commands/ToggleCommand

getSelectedValue() → {any}

Description:
  • Get the selected value if available

Source:
Returns:

If a 'value' parameter is set it will be returned

Type
any

hasFlags(flags)

Description:
  • Check to see if this group's flags match any of the bits of the
    input flags.

Source:
Inherited From:
Parameters:
Name Type Description
flags Number

The flags to check against

isCommand()

Description:
  • Always returns false.

Source:
Inherited From:

isEmpty()

Description:
  • Return true if this CommandGroup doesn't contain any children.

Source:
Inherited From:
Returns:

true if empty.

isLoading() → {boolean}

Source:
Inherited From:
Returns:

true if any of the Commands are still loading.

Type
boolean

isToggleCommand()

Description:
  • Always returns false.

Source:
Inherited From:

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:
Inherited From:
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:
Inherited From:
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:
Inherited From:
Parameters:
Name Type Attributes Description
group module:bajaux/commands/CommandGroup

The group to merge with
this one

params object <optional>
Properties
Name Type Attributes Default Description
mergeCommands boolean <optional>
true

set to false to cause commands
to be merged by a simple instanceof check, and all child commands of this
group will be included; otherwise, only commands whose merge() function
returns a new Command will be included

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:changecommandgroup event.
    Multiple arguments
    can be specified so multiple commands can be removed at once.

Source:
Inherited From:
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
of the Command to remove.

Returns:

Return the CommandGroup instance.

Type
module:bajaux/commands/CommandGroup

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:changecommandgroup event.

Source:
Inherited From:
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
Name Type Attributes Description
flags Number <optional>

Flags to use to filter commands. Only
children that match one of these flags will be removed.
If omitted, defaults to Command.flags.ALL meaning all
children will be removed.

recurse Boolean <optional>

true if should also empty out any
sub-groups.

setChildren(children)

Description:
  • Sets this group's array of commands/groups wholesale. Triggers a
    bajaux:changecommandgroup event.

Source:
Inherited From:
Parameters:
Name Type Description
children Array

setDisplayNameFormat(displayName)

Description:
  • Set the display name format of the command group. Triggers a
    bajaux:changecommandgroup event.

Source:
Inherited From:
Parameters:
Name Type Description
displayName String

display name - supports baja Format syntax

setFlags(flags)

Description:
  • Sets this group's flags. Triggers a bajaux:changecommandgroup event.

Source:
Inherited From:
Parameters:
Name Type Description
flags Number

setIcon(icon)

Description:
  • Sets the icon for this CommandGroup. Triggers a bajaux:changecommandgroup event.

Source:
Since:
  • Niagara 4.12
Inherited From:
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:
Inherited From:
Returns:
Type
Number

sort() → {Promise}

Description:
  • Sorts this command group. Typically will not be overridden; override
    doSort instead. Triggers a bajaux:changecommandgroup event.

Source:
Inherited From:
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:
Inherited From:
Returns:

Promise to be resolved with the display name

Type
Promise.<String>

trigger(name)

Description:
  • Triggers an event from this CommandGroup.

Source:
Inherited From:
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:
Inherited From:
Parameters:
Name Type Description
func

Called for every CommandGroup and Command found. Each
Command/CommandGroup is passed in as the first argument to the function.
If the function returns a false value then iteration stops.