Using positioning 'Panel' in new Jetpack A

2019-05-19 23:33发布

I'm now using the new version of the Jetpack API of which allows you to create addons for Firefox using a JS framework.

The 'panel' object is easy to use - but I'm struggling to find a way to position it. The documentation simply states (Jetpack Panel API)

panel.show(anchor) DomElement

But I'd like to position the panel in the bottom right corner of the window - How do I do this - and where can I find some more documentation about it.

1条回答
戒情不戒烟
2楼-- · 2019-05-19 23:56

The only way I'm aware of to be able to position a panel to bottom right requires an icon (or text, as in the example below) to be placed in the statusbar. After that the panel can be linked to be positioned above the icon.

Mimicking Jetpack's JEP wiki:

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

jetpack.statusBar.append({
  html: "View SO",
  onReady: function(widget) {
    $(widget).click(function(){
      openBottomRightPanel(widget);
    });
  },
});

When the statusbar text is clicked, the resulting window (Jetpack panel) shoud open in the bottom right corner of the browser window. (N.b. Maybe the icon/text can be blank, if the panel is opened programmatically?)

查看更多
登录 后发表回答