Dandonkulous (talk | contribs) |
Dandonkulous (talk | contribs) |
||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{draft}} | {{draft}} | ||
== JEP 33 - | == JEP 33 - Gadget == | ||
* Champion: Daniel Buchner <daniel@mozilla.com> | * Champion: Daniel Buchner <daniel@mozilla.com> | ||
Line 7: | Line 7: | ||
* Type: API Track | * Type: API Track | ||
* Created: 2 Dec 2009 | * Created: 2 Dec 2009 | ||
* Reference Implementation: | * Reference Implementation: new Gadget({options}) | ||
* [[Labs/Jetpack/JEPs|JEP Index]] | * [[Labs/Jetpack/JEPs|JEP Index]] | ||
=== Introduction and Rationale === | === Introduction and Rationale === | ||
Gadget for Jetpack is a crucial API enhancement that allows developers using the Jetpack extension development platform to extend the reach and scope of what is able to be accomplished with Jetpack. The magic of Gadget is the ability for developers to create what will appear to the user to be desktop applications with only HTML, JavaScript, and CSS. | |||
=== Proposal === | === Proposal === | ||
A new | Each Gadget will be run in a separate OS process. Upon installation, the Jetpack will auto-create a shortcut for the Gadget in the Start Menu > Programs > Firefox Gadgets directory as well as an entry in the Jetpack Gadget Launcher (see screenshot for details). | ||
<code> | |||
Outstanding Issues: | |||
* How does the add and remove Gadgets mechanism effect its changes? | |||
* What method will we use to start-up a Gadget (shortcut target param?) | |||
* What's the UI/user-flow for modifying settings and other user options. | |||
A new Gadget instantiation: | |||
<code>new Gadget({options})</code> | |||
Where <tt>options</tt> is an object: | Where <tt>options</tt> is an object: | ||
Properties | Properties | ||
* <tt>icon</tt> <i>uri</i> - icon to show in the title bar section of the | * <tt>title</tt> <i>uri</i> - Title that appears in the title bar of Gadget | ||
* <tt>html</tt> <i>text/ | * <tt>icon</tt> <i>uri</i> - icon to show in the title bar section of the Gadget | ||
* <tt>desktopIcon</tt> <i>uri</i> - icon that will be used for the auto-created desktop shortcut | |||
* <tt>html</tt> <i>text/html</i> - html content for the feature | |||
* <tt>url</tt> <i>uri</i> - url to load content for the feature | * <tt>url</tt> <i>uri</i> - url to load content for the feature | ||
* <tt>width</tt> <i>num</i> - initial width of the | * <tt>width</tt> <i>num</i> - initial width of the Gadget (defaults: 320px - standard smartphone width resolution) | ||
* <tt>height</tt> <i>num</i> - initial height of the | * <tt>height</tt> <i>num</i> - initial height of the Gadget (defaults: 480px - standard smartphone height resolution) | ||
* <tt> | * <tt>maxWidth</tt> <i>num</i> - maximum width of the Gadget | ||
* <tt>allowMaximize</tt> <i>bool</i> - specifies whether or not a | * <tt>maxHeight</tt> <i>num</i> - minimum width of the Gadget | ||
* <tt>allowResize</tt> <i>bool</i> - specifies whether or not a user can resize a | * <tt>allowMaximize</tt> <i>bool</i> - specifies whether or not a Gadget will have the ability to maximize | ||
* <tt>allowResize</tt> <i>bool</i> - specifies whether or not a user can resize a Gadget | |||
Events | Events | ||
* <tt>onFocus</tt> <i>func</i> - event triggered when the | * <tt>onFocus</tt> <i>func</i> - event triggered when the Gadget is focused | ||
* <tt>onBlur</tt> <i>func</i> - event triggered when the | * <tt>onBlur</tt> <i>func</i> - event triggered when the Gadget losses focus | ||
* <tt>onReady</tt> <i>func</i> - event triggered when the | * <tt>onReady</tt> <i>func</i> - event triggered when the Gadget is ready for manipulation or content injection | ||
* <tt>onMinimize</tt> <i>func</i> - event triggered when the | * <tt>onMinimize</tt> <i>func</i> - event triggered when the Gadget is minimized to the task bar | ||
* <tt>onMaximize</tt> <i>func</i> - event triggered when the | * <tt>onMaximize</tt> <i>func</i> - event triggered when the Gadget is maximized | ||
* <tt>onRestore</tt> <i>func</i> - event triggered when the | * <tt>onRestore</tt> <i>func</i> - event triggered when the Gadget is restored from the task bar | ||
All events are passed the following property hash: | All events are passed the following property hash: | ||
* <tt>icon</tt> - a pointer to the icon used in the | * <tt>icon</tt> - a pointer to the icon used in the Gadget title bar. | ||
* <tt>icon.toDefault()</tt> - reloads icon to original icon | |||
* <tt>contentDocument</tt> - document element of the content area | * <tt>contentDocument</tt> - document element of the content area | ||
* <tt>position</tt> - an object that includes the | * <tt>position</tt> - an object that includes the Gadget's position on the screen: {x: 400, y: 500} | ||
* <tt>location</tt> - the URL of the window, http://, chrome:// | * <tt>location</tt> - the URL of the Gadget's window object, http://, chrome:// | ||
=== Example === | === Example === | ||
Show mozilla.com in a | Show mozilla.com in a Gadget and change the background color of the document when clicked. | ||
<pre class="brush:js;toolbar:false;"> | <pre class="brush:js;toolbar:false;"> | ||
new Gadget({, | |||
url: "http://www.mozilla.com/", | url: "http://www.mozilla.com/", | ||
width: 300, | width: 300, | ||
onFocus: function( | onFocus: function(gadget) { | ||
gadget.contentWindow.document.body.style.background = '#ffffff'; | |||
}, | }, | ||
onBlur: function(){ | onBlur: function(gadget){ | ||
gadget.contentWindow.document.body.style.background = '#ff0000'; | |||
} | } | ||
}); | }); | ||
</pre> | </pre> |
Latest revision as of 18:52, 29 December 2009
JEP 33 - Gadget
- Champion: Daniel Buchner <daniel@mozilla.com>
- Status: Concept
- Type: API Track
- Created: 2 Dec 2009
- Reference Implementation: new Gadget({options})
- JEP Index
Introduction and Rationale
Gadget for Jetpack is a crucial API enhancement that allows developers using the Jetpack extension development platform to extend the reach and scope of what is able to be accomplished with Jetpack. The magic of Gadget is the ability for developers to create what will appear to the user to be desktop applications with only HTML, JavaScript, and CSS.
Proposal
Each Gadget will be run in a separate OS process. Upon installation, the Jetpack will auto-create a shortcut for the Gadget in the Start Menu > Programs > Firefox Gadgets directory as well as an entry in the Jetpack Gadget Launcher (see screenshot for details).
Outstanding Issues: * How does the add and remove Gadgets mechanism effect its changes? * What method will we use to start-up a Gadget (shortcut target param?) * What's the UI/user-flow for modifying settings and other user options.
A new Gadget instantiation:
new Gadget({options})
Where options is an object:
Properties
- title uri - Title that appears in the title bar of Gadget
- icon uri - icon to show in the title bar section of the Gadget
- desktopIcon uri - icon that will be used for the auto-created desktop shortcut
- html text/html - html content for the feature
- url uri - url to load content for the feature
- width num - initial width of the Gadget (defaults: 320px - standard smartphone width resolution)
- height num - initial height of the Gadget (defaults: 480px - standard smartphone height resolution)
- maxWidth num - maximum width of the Gadget
- maxHeight num - minimum width of the Gadget
- allowMaximize bool - specifies whether or not a Gadget will have the ability to maximize
- allowResize bool - specifies whether or not a user can resize a Gadget
Events
- onFocus func - event triggered when the Gadget is focused
- onBlur func - event triggered when the Gadget losses focus
- onReady func - event triggered when the Gadget is ready for manipulation or content injection
- onMinimize func - event triggered when the Gadget is minimized to the task bar
- onMaximize func - event triggered when the Gadget is maximized
- onRestore func - event triggered when the Gadget is restored from the task bar
All events are passed the following property hash: * icon - a pointer to the icon used in the Gadget title bar. * icon.toDefault() - reloads icon to original icon * contentDocument - document element of the content area * position - an object that includes the Gadget's position on the screen: {x: 400, y: 500} * location - the URL of the Gadget's window object, http://, chrome://
Example
Show mozilla.com in a Gadget and change the background color of the document when clicked.
new Gadget({, url: "http://www.mozilla.com/", width: 300, onFocus: function(gadget) { gadget.contentWindow.document.body.style.background = '#ffffff'; }, onBlur: function(gadget){ gadget.contentWindow.document.body.style.background = '#ff0000'; } });