I have several very similar commands. So I'd like to make a base
command with shared functionality, and the rest of commands should
“inherit” from it.
Test code:
var MyCommands = {};
MyCommands['stub-command'] = {
author: {
name: "Eugene Janusov",
email: "
esy...@gmail.com"
},
preview: function(pblock, directObject) {
displayMessage('::: ' + this.test());
},
execute: function(directObject) {},
test: function() {
return '[' +
this.name + '] [' +
this.author.name + ']';
}
};
MyCommands['test-command'] = jQuery.extend({}, MyCommands['stub-
command'], {
name: 'test-command'
});
CmdUtils.CreateCommand(MyCommands['test-command']);
displayMessage('::: ' + MyCommands['test-command'].test());
MyCommands['test-command'].preview();
The last two lines work perfectly, display
::: [test-commands] [Eugene Janusov]
>>> [test-commands] [Eugene Janusov]
But as soon as I start to use `test-command', I get the following
message:
>>> [] [Eugene Janusov]
Seems like Ubiquity calls preview() in some special context.
Is there any way to “extend” commands?