Labs/Jetpack/JEP/23: Difference between revisions

From MozillaWiki
< Labs‎ | Jetpack‎ | JEP
Jump to navigation Jump to search
(Created page with '{{draft}} == JEP 10 - Panels == * Champion: Aza Raskin <aza at mozilla dot com> * Status: Implementing * Type: API Track * Created: 21 Aug 2009 * Reference Implementation: None…')
 
No edit summary
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{draft}}
{{draft}}


== JEP 10 - Panels ==
'''CONSIDER THE FOLLOWING''': ''We could augment our implementation of this UI mechanism by including aspects of [http://www.clientcide.com/wiki/cnet-libraries/07-ui/07.5-stickywin.pointytip  '''Clientcide's PointyTips''']. I believe it may help us cover a broader set of use-cases.''
 
 
 
DISCUSSION: Should we pursue an implementation that closely mirrors this existing venture into similar territory?  - 
 
== JEP 23 - Panels ==


* Champion: Aza Raskin <aza at mozilla dot com>
* Champion: Aza Raskin <aza at mozilla dot com>
Line 15: Line 21:
This JEP describes the API for creating style-able rich content panels (windows) that float above the browser window.
This JEP describes the API for creating style-able rich content panels (windows) that float above the browser window.


Many extensions use floating panels as a way to present rich information over chrome/content both for anti-spoofing reasons as well as to not inject information into the DOM.
An example of this kind of functionality is shown in the popular add-on, TwitterFox:
 
http://img.skitch.com/20090821-rbhrm8ddj2xk6f88uy66gdf97h.jpg
 
=== Proposal  ===
 
Panel access will live at <code>jetpack.panel</code>.  


==== Panel overview  ====


=== Proposal ===
Most of the action occurs in <code>jetpack.panel.open(...)</code>, which returns a Panel object, which can then be manipulated.


Clipboard access will live at <code>jetpack.panel</code>.
===== Opening a Panel =====


==== Setting the clipboard ====
''CONSIDER: Here are some additional and alternate options from an existing implementation that is quite mature: [http://clientcide.com/docs/UI/StickyWin '''StickyWin Documentation''']''


<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
jetpack.clipboard.set( content )
myPanel = jetpack.panel.open(...);
jetpack.clipboard.set( content, flavor )
</pre>
</pre>


*'''content''': The content to put on the clipboard. If no other arguments are supplied, the content is assumed to be of flavor "plain". For now, this can only be text or an image. In the future, it can be anything that is place-able on the system clipboard.
'''Optional Arguments'''
*'''flavor''': A Jetpack clipboard flavor (see below).
 
* '''url'''/'''html''': You can have one of either a url or an html parameter. The url (either absolute or relative) is what the content of the panel shows. Html, on the other hand, is the manually created html to be displayed. Works just like the slidebar.
* '''style''': Is either an inline CSS style for the panel (transparency, rounded corners, color, etc.), or a url that points to a CSS file.
* '''width'''/'''height''': Defaults to 320x240 pixels.
* '''transient''': A bool that defaults to true. A transient panel is one that disappears when you click outside the panel, a key press goes someplace that isn't the panel, or the escape key is pressed. A non-transient panel must be dismissed explicitly.
* '''restoreFocus''': A bool that defaults to true. When the panel is closed, if true, then Jetpack refocuses last element that had focus in the browser. If false, nothing will be in focus.
* '''takeFocus''': A bool that defaults to true. If this is true, then the currently focused element in the browser will be blur'ed whenever the popup is opened because the popup will be given focus.
* '''anchor''': The anchor determines where to anchor the panel. Takes a chrome or content-space DOM element or null. Defaults to null (which means to positioning it in screen coordinates).
* '''align''': Where and how to locate the panel. This is a string that consists of a description of the placement. For example, "bottom left with anchor top left". The string is always of the form "bottom/top/middle left/right/center with anchor bottom/top/middle left/right/center". Other offsets are handled via margin/padding in the style option. To have a centered panel in the middle of the screen, you'd <code>{anchor: null, align: "middle center with anchor middle center"}</code>.
 
http://img.skitch.com/20090825-1cjrtq1ppxc3gpgxh3u637ebjf.jpg
 
===== The Panel Object =====


'''Examples'''
The <code>Panel</code> type is returned by a call to <code>jetpack.panel.open(...)</code>. Once you have a Panel object, you can manipulate that panel in numerous ways.


<pre class="brush:js;toolbar:false;">
'''Inherited'''
jetpack.clipboard.set('hello');
 
jetpack.clipboard.set('<b>Hello</b>', 'html');
* All of the properties of the window object currently used by Firefox for panels?
 
'''Methods'''
 
* <code>myPanel.close()</code>: Closes the panel. All internal panel state is lost.
* <code>myPanel.hide()</code>: Hides the panel temporarily. If the window/object that the panel is anchored to moves while the panel is hidden, upon show it too has moved accordingly.
* <code>myPanel.show()</code>: Undoes the <code>hide()</code> operation.
 
'''Properties'''
 
* <code>myPanel.contentDocument</code>: A pointer to the content document of the rich data window being displayed in the panel.
* <code>myPanel.contentWindow</code>: A pointer to the containing window of the document being displayed by the panel.
 
===== Examples =====
 
This is an example extension to load the mobile version of Reddit in a panel, when a statusbar icon is clicked.
 
<pre class="brush:js;">
function openRedditPanel( anchor ){
  jetpack.panels.open({
    url: "http://m.reddit.com",
    anchor: anchor,
    align: "bottom right with anchor top right"
  });
}
 
jetpack.statusBar.append({
  html: "Reddit",
  onReady: function(widget) {
    $(widget).click(function(){
      openRedditPanel(widget);
    });
  },
});
</pre>
</pre>
==== Reference Material ====
From the XUL reference guide:
* [https://developer.mozilla.org/en/XUL/PopupGuide/Panels Panels]
* [https://developer.mozilla.org/en/XUL/PopupGuide/OpenClose Opening/Closing Panels]
* [https://developer.mozilla.org/en/XUL/PopupGuide/Positioning Position Panels]

Latest revision as of 18:35, 18 November 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.

CONSIDER THE FOLLOWING: We could augment our implementation of this UI mechanism by including aspects of Clientcide's PointyTips. I believe it may help us cover a broader set of use-cases.


DISCUSSION: Should we pursue an implementation that closely mirrors this existing venture into similar territory? -

JEP 23 - Panels

  • Champion: Aza Raskin <aza at mozilla dot com>
  • Status: Implementing
  • Type: API Track
  • Created: 21 Aug 2009
  • Reference Implementation: None
  • Relevant Bugs:
  • JEP Index

Introduction and Rationale

This JEP describes the API for creating style-able rich content panels (windows) that float above the browser window.

An example of this kind of functionality is shown in the popular add-on, TwitterFox:

20090821-rbhrm8ddj2xk6f88uy66gdf97h.jpg

Proposal

Panel access will live at jetpack.panel.

Panel overview

Most of the action occurs in jetpack.panel.open(...), which returns a Panel object, which can then be manipulated.

Opening a Panel

CONSIDER: Here are some additional and alternate options from an existing implementation that is quite mature: StickyWin Documentation

myPanel = jetpack.panel.open(...);

Optional Arguments

  • url/html: You can have one of either a url or an html parameter. The url (either absolute or relative) is what the content of the panel shows. Html, on the other hand, is the manually created html to be displayed. Works just like the slidebar.
  • style: Is either an inline CSS style for the panel (transparency, rounded corners, color, etc.), or a url that points to a CSS file.
  • width/height: Defaults to 320x240 pixels.
  • transient: A bool that defaults to true. A transient panel is one that disappears when you click outside the panel, a key press goes someplace that isn't the panel, or the escape key is pressed. A non-transient panel must be dismissed explicitly.
  • restoreFocus: A bool that defaults to true. When the panel is closed, if true, then Jetpack refocuses last element that had focus in the browser. If false, nothing will be in focus.
  • takeFocus: A bool that defaults to true. If this is true, then the currently focused element in the browser will be blur'ed whenever the popup is opened because the popup will be given focus.
  • anchor: The anchor determines where to anchor the panel. Takes a chrome or content-space DOM element or null. Defaults to null (which means to positioning it in screen coordinates).
  • align: Where and how to locate the panel. This is a string that consists of a description of the placement. For example, "bottom left with anchor top left". The string is always of the form "bottom/top/middle left/right/center with anchor bottom/top/middle left/right/center". Other offsets are handled via margin/padding in the style option. To have a centered panel in the middle of the screen, you'd {anchor: null, align: "middle center with anchor middle center"}.

20090825-1cjrtq1ppxc3gpgxh3u637ebjf.jpg

The Panel Object

The Panel type is returned by a call to jetpack.panel.open(...). Once you have a Panel object, you can manipulate that panel in numerous ways.

Inherited

  • All of the properties of the window object currently used by Firefox for panels?

Methods

  • myPanel.close(): Closes the panel. All internal panel state is lost.
  • myPanel.hide(): Hides the panel temporarily. If the window/object that the panel is anchored to moves while the panel is hidden, upon show it too has moved accordingly.
  • myPanel.show(): Undoes the hide() operation.

Properties

  • myPanel.contentDocument: A pointer to the content document of the rich data window being displayed in the panel.
  • myPanel.contentWindow: A pointer to the containing window of the document being displayed by the panel.
Examples

This is an example extension to load the mobile version of Reddit in a panel, when a statusbar icon is clicked.

function openRedditPanel( anchor ){
  jetpack.panels.open({
    url: "http://m.reddit.com",
    anchor: anchor,
    align: "bottom right with anchor top right"
  });
}

jetpack.statusBar.append({
  html: "Reddit",
  onReady: function(widget) {
    $(widget).click(function(){
      openRedditPanel(widget);
    });
  },
});

Reference Material

From the XUL reference guide: