Labs/Jetpack/API: Difference between revisions

< Labs‎ | Jetpack
({{Jetpack/Prototype}})
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Jetpack/Prototype}}
'''WARNING''': This reference is volatile and will change.
'''The Jetpack API reference now seems to be [https://developer.mozilla.org/en/Jetpack here].'''
* [[Labs/Jetpack/API/jetpack|Jetpack Core]]
* [[Labs/Jetpack/API/importing|Importing Code]]
* [[Labs/Jetpack/API/ui|Jetpack UI]]
* [[Labs/Jetpack/API/system|Jetpack System Integration]]
= JetPack API Reference =
= JetPack API Reference =


JetPack is a project to explore new and innovative approaches to extensibility of the browser.
{{:Labs/Jetpack/API/jetpack}}
 
=== <code>jetpack.tabs</code> ===
 
<code>jetpack.tabs</code> is an Array-like object with special tab-related properties.  Each element of the array is a <code>Tab</code> object.
 
'''<code>jetpack.tabs.focused</code>'''
 
This is the <code>Tab</code> object that corresponds to the currently focused/active tab.
 
'''Limitations:''' At present, the <code>tabs</code> array is immutable, which means that destructive methods like <code>splice()</code> won't work on them. All other [https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array Array methods and properties] are available, however.


==== Tab Event Handlers ====


'''Logger'''
Much of what <code>jetpack.tabs</code> 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 <code>jetpack.tabs.onReady()</code>, it's not only set up for all currently open tabs, but when a new tab is created&mdash;in any window&mdash;Jetpack will bind the event handler to it.
Used to output debugging information, it appears in the Javascript Error Console. You can access it from the Tools menu.
* <code>log( message )</code> or <code>log({message: string})</code>. Shows a log message in the Error Console.
* <code>debug( message )</code> or <code>debug({message: string})</code>. Shows a debug message in the Error Console.
* <code>info( message )</code> or <code>info({message: string})</code>. Shows an info message in the Error Console.
* <code>warn( message )</code> or <code>warn({message: string})</code>. Shows a warning in the Error Console.
* <code>error( message )</code> or <code>error({message: string})</code>. Shows an error message in the Error Console.

Latest revision as of 00:39, 5 March 2010

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.


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.