Skip to content

Commit

Permalink
Replace Widget by ToggleButton
Browse files Browse the repository at this point in the history
  • Loading branch information
puppe committed Jul 28, 2015
1 parent 1b20059 commit 9e729cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
File renamed without changes
Binary file added data/button/icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/button/icon64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 24 additions & 11 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License
along with resumeLater. If not, see <http://www.gnu.org/licenses/>.
*/

/*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;
Expand All @@ -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") {
Expand All @@ -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() {
Expand Down Expand Up @@ -83,12 +104,4 @@ videoStorage.on('update', function () {
videoList.port.emit('update', videoStorage.getAll());
});

// widget
var widget = widgets.Widget({
id: "[email protected]",
label: "Resume Later",
contentURL: data.url("widget/widget.png"),
panel: videoList
});

// vim: set ts=4 sw=4 sts=4 tw=72 et :

0 comments on commit 9e729cf

Please sign in to comment.