new bajaux/util/SaveCommand()
A Command for saving a Widget.
Extends
Methods
-
getAccelerator()
-
Return the accelerator for the Command or null if
nothing is defined.- Inherited From:
- See:
Returns:
The accelerator or null if nothing is defined.
- Type
- Object
-
getDescriptionFormat()
-
Get the unformatted description of the command.
- Inherited From:
Returns:
- Type
- String
-
getDisplayNameFormat()
-
Return the format display name of the command.
- Inherited From:
Returns:
- Type
- String
-
getFlags()
-
Get this command's flags.
- Inherited From:
Returns:
- Type
- Number
-
getFunction()
-
Return the raw function associated with this command.
- Inherited From:
Returns:
- Type
- function
-
getIcon()
-
Return the Command's icon.
- Inherited From:
Returns:
- Type
- String
-
getId()
-
Return a unique numerical id for the Command.
This is id unique to every Command object created.
- Inherited From:
-
hasFlags(flags)
-
Check to see if this command's flags match any of the bits of the
input flags.Parameters:
Name Type Description flags
Number The flags to check against
- Inherited From:
Returns:
- Type
- Boolean
-
invoke()
-
Invoke the Command. Triggers a
bajaux:invokecommand
orbajaux:failcommand
event, as appropriate.Arguments can be passed into
invoke()
that will be passed into the
function's Command Handler.- Inherited From:
Returns:
A promise object that will be resolved (or rejected)
once the Command's function handler has finished invoking.- Type
- Promise
-
isCommand()
-
Always returns true.
- Inherited From:
-
isEnabled()
-
Gets this command's enabled status.
- Inherited From:
Returns:
- Type
- Boolean
-
isLoading()
-
Return true if the Command is still loading.
- Inherited From:
Returns:
true if still loading.
- Type
- Boolean
-
isToggleCommand()
-
Always returns false.
- Inherited From:
-
jq()
-
- Overrides:
- See:
-
- module:/bajaux/commands/Command
-
loading()
-
Return the loading promise for the Command.
The returned promise will be resolved once the Command
has finished loading.- Inherited From:
Returns:
The promise used for loading a Command.
- Type
- Promise
-
merge(cmd)
-
Attempt to merge this command with another command, and return a new
Command that does both tasks. If the two commands are mutually
incompatible, return a falsy value.Parameters:
Name Type Description cmd
module:bajaux/commands/Command - Inherited From:
Returns:
Example
Here is an example to show the basic concept. Commands that simply add two numbers together can easily be merged together thanks to the associative property.
var AddCommand = function AddCommand(inc) { this.$inc = inc; Command.call(this, { displayName: 'Add ' + inc + ' to the given number', func: function (num) { return num + inc; } }); }; AddCommand.prototype = Object.create(Command.prototype); AddCommand.prototype.merge = function (cmd) { if (cmd instanceof AddCommand) { return new AddCommand(this.$inc + cmd.$inc); } }; var addOneCommand = new AddCommand(1), addFiveCommand = new AddCommand(5), addSixCommand = addOneCommand.merge(addFiveCommand); addSixCommand.invoke(10) .then(function (result) { console.log('is 16? ', result === 16); });
-
off( [event] [, handler])
-
Unregister a function callback handler for the specified event.
Parameters:
Name Type Argument Description event
String <optional>
The name of the event to unregister.
If name isn't specified, all events for the Command will be unregistered.handler
function <optional>
The function to unregister. If
not specified, all handlers for the event will be unregistered.- Inherited From:
-
on(event, handler)
-
Register a function callback handler for the specified event.
Parameters:
Name Type Description event
String The event id to register the function for.
handler
function The event handler to be called when the event is fired.
- Inherited From:
-
setAccelerator(acc)
-
Set the accelerator information for the Command.
Parameters:
Name Type Description acc
Object | String | Number | null | undefined The accelerator keyboard information. This can
be a keyCode number, a character (i.e. 'a') or an Object that contains the accelerator information.
If no accelerator should be used the null/undefined should be specified.Properties
Name Type Argument Description keyCode
String | Number The key code of the accelerator. This can be a character
code number or a character (i.e. 'a').ctrl
Boolean <optional>
true
if the control key needs to be pressed.shift
Boolean <optional>
true
if the shift key needs to be pressed.alt
Boolean <optional>
true
if the alt key needs to be pressed.meta
Boolean <optional>
true
if a meta key needs to be pressed. -
setDescriptionFormat(description)
-
Set the description format of the command. Triggers a
bajaux:changecommand
event.Parameters:
Name Type Description description
String the command description - supports baja Format
syntax- Inherited From:
-
setDisplayNameFormat(displayName)
-
Set the display name format of the command. Triggers a
bajaux:changecommand
event.Parameters:
Name Type Description displayName
String display name - supports baja Format syntax
- Inherited From:
-
setEnabled(enabled)
-
Sets this command's enabled status. Triggers a
bajaux:changecommand
event.Parameters:
Name Type Description enabled
Boolean - Inherited From:
-
setFlags(flags)
-
Set this command's flags.
Parameters:
Name Type Description flags
Number - Inherited From:
-
setFunction(func)
-
Set the Command's function handler.
Parameters:
Name Type Description func
function The new function handler for the command.
- Inherited From:
-
setIcon(icon)
-
Sets the icon for this Command. Triggers a
bajaux:changecommand
event.Parameters:
Name Type Description icon
String The Command's icon.
- Inherited From:
-
toDescription()
-
Access the Command's description.
In order to access the description, a promise will be returned
that will be resolved once the command has been loaded and
the description has been found.- Inherited From:
Returns:
Promise to be resolved with the description
- Type
- Promise
-
toDisplayName()
-
Access the Command's display name.
In order to access the display name, a promise will be returned
that will be resolved once the command has been loaded and
the display name has been found.- Inherited From:
Returns:
Promise to be resolved with the display name
- Type
- Promise
-
trigger(name)
-
Triggers an event from this Command.
Parameters:
Name Type Description name
String - Inherited From:
-
visit(func)
-
Visit this Command with the specified function.
Parameters:
Name Type Description func
function Will be invoked with this
Command passed in as an argument.- Inherited From: