diff --git a/data/widget/widget.png b/data/button/icon16.png similarity index 100% rename from data/widget/widget.png rename to data/button/icon16.png diff --git a/data/button/icon32.png b/data/button/icon32.png new file mode 100644 index 0000000..52dce02 Binary files /dev/null and b/data/button/icon32.png differ diff --git a/data/button/icon64.png b/data/button/icon64.png new file mode 100644 index 0000000..57a112e Binary files /dev/null and b/data/button/icon64.png differ diff --git a/lib/main.js b/lib/main.js index 4ee3c31..fbc4d3d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with resumeLater. If not, see . */ -/*jshint esnext:true,strict:false*/ +/*jshint esnext:true,strict:false,latedef:false*/ /*globals exports*/ -const widgets = require('sdk/widget'); +const toggle = require('sdk/ui/button/toggle'); const panel = require('sdk/panel'); const tabs = require('sdk/tabs'); const data = require('sdk/self').data; @@ -34,6 +34,24 @@ const sites = require('./sites'); const VideoStorage = require('./videos').VideoStorage; var videoStorage = new VideoStorage(simpleStorage, simplePrefs); +// button +var button = toggle.ToggleButton({ + id: "button", + label: "Resume Later", + icon: { + "16": "./button/icon16.png", + "32": "./button/icon32.png", + "64": "./button/icon64.png" + }, + onChange: function (state) { + if (state.checked) { + videoList.show({ + position: button + }); + } + } +}); + // list panel var locale = (_("locale")); if (locale === "locale") { @@ -50,7 +68,10 @@ var videoList = panel.Panel({ panelLocale, data.url("panel/l10n.js"), data.url("panel/panel.js") - ] + ], + onHide: function () { + button.state('window', { checked: false }); + } }); function resizeVideoList() { @@ -83,12 +104,4 @@ videoStorage.on('update', function () { videoList.port.emit('update', videoStorage.getAll()); }); -// widget -var widget = widgets.Widget({ - id: "widget.resumeLater@mpuppe.de", - label: "Resume Later", - contentURL: data.url("widget/widget.png"), - panel: videoList -}); - // vim: set ts=4 sw=4 sts=4 tw=72 et :