Currently there's no way of inheriting from/extending commands in the
way you've described here. However, you could just split the shared code
into its own function in the global scope of the feed, and have the
commands use that. Since each command feed is executed in its own
sandbox, you won't need to worry about naming collisions with other
command feeds.
Command object introspection is a bit impossible to do at the moment, as
everything gets wrapped in one or two extra layers before being put into
the resulting command object. Its something that needs fixed sometime.
- Blair
On 3/01/2009 6:20 PM, Eugene Janusov wrote:
> 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: "[email protected]"
> },
>
> 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?
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---