Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.5 Author Tutorial

52 bytes added, 23:33, 29 August 2009
Made the code modern (and actually work), part 2.
The input objects that our <code>suggest()</code> method generates are the same objects that will eventually get passed in to the <code>execute()</code> and <code>preview()</code> methods of any commands that use this noun type.
=== Switching Tabs: The Command ===
Now that we are armed with the tab noun-type, it is easy to make the tab-switching command. Again, we use FUEL to focus the selected tab.
<pre>
CmdUtils.CreateCommand({
names: ["switch tab"],
arguments: {object: noun_type_tab},
execute: functiontab_execute( arguments args) { // must be delayed because Ubiquity restores the focus on close Utils.setTimeout(function delayedFocus() { var tabName tab = argumentsargs.object.textdata; var tabs = noun_type_tab tab._window._window.getTabsfocus(); tabs[tabName]._window tab.focus(); tabs[tabName].focus(}, 99);
},
preview: functiontab_preview( pblock, arguments args) { var tabName = argumentsargs.object.text; if( tabName.length > 1 ){ var msg = "Changes to <b style=\"color:yellow\"strong>${tab}</bstrong> tab."; pblock.innerHTML = _(msg, {tab: tabName}); } else pblock.innerHTML = _("Switch to a tab by name.");
}
});
</pre>
73
edits

Navigation menu