Labs/Jetpack/JEP/16: Difference between revisions

From MozillaWiki
< Labs‎ | Jetpack‎ | JEP
Jump to navigation Jump to search
(slideBar.append and callback updates)
 
Line 22: Line 22:


Where <tt>options</tt> is a property hash:
Where <tt>options</tt> is a property hash:
* <tt>icon</tt> - icon to show in the SlideBar
* <tt>icon</tt> <i>uri</i> - icon to show in the SlideBar
* <tt>html</tt> - html content for the feature
* <tt>html</tt> <i>text/xml</i> - html content for the feature
* <tt>url</tt> - url to load content for the feature
* <tt>url</tt> <i>uri</i> - url to load content for the feature
* <tt>width</tt> - width of the content area and default size to slide to
* <tt>width</tt> <i>num</i> - width of the content area and selected slide size
* <tt>persist</tt> - default slide behavior when being selected
* <tt>persist</tt> <i>bool</i> - default slide behavior when being selected
* <tt>onClick</tt> - callback when the icon is clicked
* <tt>autoReload</tt> <i>bool</i> - automatically reload content on select
* <tt>onSelect</tt> - callback when the feature is selected
* <tt>onClick</tt> <i>func</i> - callback when the icon is clicked
* <tt>onReady</tt> - callback when the feature is loaded
* <tt>onSelect</tt> <i>func</i> - callback when the feature is selected
* <tt>onReady</tt> <i>func</i> - callback when the feature is loaded


The callbacks are passed a property hash:
The callbacks are passed a property hash:
* <tt>icon</tt> - node representing the icon in the SlideBar
* <tt>icon</tt> - node representing the icon in the SlideBar
* <tt>doc</tt> - document element of the content area
** <tt>icon.reload()</tt> - reload icon to original icon
* <tt>reset()</tt> - reset the icon and content to the original values
* <tt>contentDocument</tt> - document element of the content area
** <tt>contentDocument.reload()</tt> - reload content to original url/html
* <tt>close()</tt> - slide close the SlideBar
* <tt>close()</tt> - slide close the SlideBar
 
* <tt>notify()</tt> - slide open (if necessary) and animate icon in the SlideBar
The object passed to the callback is actually a function, <tt>slide(options)</tt>, where <tt>options</tt> is a property hash:
* <tt>slide(num, { persist: <i>bool</i> })</tt> - slide to the provided size and optionally persist the SlideBar
* <tt>size</tt> - number of pixels to slide
* <tt>persist</tt> - true to keep the SlideBar open


=== Example ===
=== Example ===

Latest revision as of 23:32, 24 June 2009

Draft-template-image.png THIS PAGE IS A WORKING DRAFT Pencil-emoji U270F-gray.png
The page may be difficult to navigate, and some information on its subject might be incomplete and/or evolving rapidly.
If you have any questions or ideas, please add them as a new topic on the discussion page.

JEP 16 - SlideBar

  • Champion: Edward Lee <edilee at mozilla dot com>
  • Status: Implementing
  • Type: API Track
  • Created: 17 June 2009
  • Reference Implementation: jetpack.future.import("slideBar")
  • JEP Index

Introduction and Rationale

SlideBar is a reinvention of the old sidebar feature of browsers. They allow quick access to a wide range of both temporary and permanent information at the side of your browser window.

When a SlideBar feature is selected, its contents will be revealed from behind the current web page.

Proposal

Add new SlideBar features: jetpack.slideBar.append(options)

Where options is a property hash:

  • icon uri - icon to show in the SlideBar
  • html text/xml - html content for the feature
  • url uri - url to load content for the feature
  • width num - width of the content area and selected slide size
  • persist bool - default slide behavior when being selected
  • autoReload bool - automatically reload content on select
  • onClick func - callback when the icon is clicked
  • onSelect func - callback when the feature is selected
  • onReady func - callback when the feature is loaded

The callbacks are passed a property hash:

  • icon - node representing the icon in the SlideBar
    • icon.reload() - reload icon to original icon
  • contentDocument - document element of the content area
    • contentDocument.reload() - reload content to original url/html
  • close() - slide close the SlideBar
  • notify() - slide open (if necessary) and animate icon in the SlideBar
  • slide(num, { persist: bool }) - slide to the provided size and optionally persist the SlideBar

Example

Show mozilla.com in the SlideBar and change the icon when clicked.

jetpack.slideBar.append({
  url: "http://www.mozilla.com/",
  width: 300,
  onClick: function(slide) {
    slide.icon.src = "chrome://branding/content/icon48.png";
  }
});