Labs/Jetpack/API
HEY
This page is relevant to the experimental Jetpack Prototype, which has been superseded by the Jetpack SDK.
WARNING: This reference is volatile and will change.
The Jetpack API reference now seems to be here.
Contents
JetPack API Reference
The jetpack
Namespace
The jetpack
namespace is available to all Jetpack Features, and is the main point of contact for Features with the rest of Firefox. The API is intended as a lightweight backwards-compatible facade to the underlying Mozilla platform, which means that if you write a Feature using the Jetpack library, you shouldn't have to change your code as Firefox continues to evolve.
For now, it has the following properties:
-
tabs
provides access to all open tabs (irrespective of window). -
statusBar
lets you add or modify to Firefox's status bar at the bottom of Firefox browser windows. -
lib
gives access to small libraries for the web, providing encapsulated and easy-to-use ways of accessing services like Twitter, Flickr, Delicious, and so forth. Eventually you'll be able to import libraries from anywhere, but the default ones will be code reviewed by Mozilla.
jetpack.tabs
jetpack.tabs
is an Array-like object with special tab-related properties. Each element of the array is a Tab
object.
jetpack.tabs.focused
This is the Tab
object that corresponds to the currently focused/active tab.
Limitations: At present, the tabs
array is immutable, which means that destructive methods like splice()
won't work on them. All other Array methods and properties are available, however.
Tab Event Handlers
Much of what jetpack.tabs
is useful for is setting up event handlers. The wonderful thing about these event handlers is that they handle all the difficult edge cases for you. When you create an event handler using an event binder function such as jetpack.tabs.onReady()
, it's not only set up for all currently open tabs, but when a new tab is created—in any window—Jetpack will bind the event handler to it.