Module to add home panels to Firefox for Android with Jetpack. In the npm registry: https://www.npmjs.com/package/jetpack-homepanel
This project is licensed unter the MPL 2.0. For the full license text, check out mozilla.org/MPL/2.0/.
To run the tests, you have to install the jpm-mobile module and then just execute jpm-mobile test
with the matching arguments.
Using this module is as simple as running npm install jetpack-homepanel --save
and npm will do the rest for you.
Consider the walkthrough for a guide on how to use this module and return here for more examples and documentation.
Represents a list or grid of items in a panel on the homescreen. Fennec currently only supports one per panel.
Items for the section follow https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/HomeProvider.jsm/HomeStorage#Item_attributes. The maximal number of supported items is 100.
Either has the value of Types.GRID
or Types.LIST
. Types.GRID
shows
"thumbnails" like the default panel and Types.LIST
shows the items in a list,
like the other default panels.
An string with a URL poitning to a background image for the panel.
Object with a text and imageUrl property, specifying the contents of the panel when there are no items to display.
List of items added to the section upon construction.
Mainly used for speed dials, with the value of ItemTypes.ICON
.
Boolean indicating, if a user can pull down to refresh the content of the panel. Defaults to true.
Event listener attached to the refresh event.
Amount in seconds for a refresh interval. See the refreshInterval
property description.
(readonly) ID of the section in the HomeStorage.
The (readonly) type of the section.
Array of items within the section.
Amount in seconds for a refresh interval. Whenever the interval is due, the
refresh event is dispatched with its first argument set to ture. This should
be bigger than 3600. To remove the interval, set the property to null
. Firefox
decides, when it is apropriate to refresh data. It takes into account things
like connectivity and status of the Firefox app.
This is a more efficient way of adding items to the section than setting the data attribute with a concatenated array. Returns a promise that resolves with the new data.
Does the same as setting the data attribute but returns a promise that resolves whenever the data is acutally replaced.
Removes all items from the section.
Returns a promise, when Firefox thinks it's apropriate to sync data with the internet. This takes into account things like device connectivity and app status.
Cleans the object's private attributes and clears its items.
The refresh event can get fired if manuallyRefreshable
was true in the
constructor. It is triggered after the user pulled down to refresh. The loading
animation will only stop, if the data property is set or addData is called.
The other case, is if the refreshInterval
is set. The event then passes true
as the first argument to the listener.
Adds a panel to fennec's homescreen.
The title displayed for the panel on the fennec homepage.
An array of at least one Sections. Firefox currently only supports one Section per HomePanel.
Event listener for the install event.
Event listener for the uninstall event.
Boolean indicating, whether or not the panel is currently accessible on Fennec's homescreen. Read only.
The title of the panel.
Sections in the panel.
Adds the panel to fennec's homescreen. Returns a promise that resolves when the panel is installed.
Removes the panel from fennec's homescreen. Returns a promise that resolves when the panel is uninstalled.
Clears the panel's attributes and sections, which removes the panel from Firefox.
Fired whenever the panel is added to fennec's homescreen.
Fired whenever the panel is removed from fennec's homescreen.
const { HomePanel, Section, Types } = require("jetpack-homepanel");
let section = Section({
type: Types.GRID,
data: [
{
url: "http://example.com/",
title: "An example item",
description: "An example description",
image_url: "http://lorempixel.com/190/190"
},
{
url: "http://example.com/",
title: "Another example item",
image_url: "http://lorempixel.com/95/95"
},
{
url: "http://just.an/url",
title: "Imageless item"
},
{
url: "http://example.com",
image_url: "http://lorempixel/191/191"
}
]
});
HomePanel({
title: "Example Grid Panel",
sections: [
section
]
});
The code above results in such a panel:
const { HomePanel, Section, Types } = require("jetpack-homepanel");
HomePanel({
title: "Example List Panel",
sections: [
Section({
type: Types.LIST,
data: [
{
url: "http://example.com/",
title: "An example item",
description: "An example description",
image_url: "http://lorempixel.com/190/190"
},
{
url: "http://example.com/",
title: "Another example item",
image_url: "http://lorempixel.com/95/95"
},
{
url: "http://just.an/url",
title: "Imageless item"
},
{
url: "http://url.with/picture",
image_url: "http://lorempixel/190/190"
},
{
url: "http://example.com",
title: "Another imageless item",
description: "With a very, very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong description"
}
]
})
]
});
The code above results in a panel shown in this screenshot:
The item configuration for this example was taken from the MDN HomeProvider.jsm Example.
const { HomePanel, Section, Types } = require("jetpack-homepanel");
HomePanel({
title: "Example Panel with a Folder",
sections: [
Section({
type: Types.LIST,
data: [
{ url: "http://example.com/first",
title: "First Example" },
{ url: "http://example.com/second",
title: "Second Example" },
{ url: "filter://folder",
title: "Folder" },
{ url: "http://example.com/third",
title: "Filtered Example",
filter: "folder" }
]
})
]
});
The code above results in a panel like the following screenshots show: