Using positioning 'Panel' in new Jetpack API

丶灬走出姿态 提交于 2020-01-23 13:28:20

问题


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:


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?)



来源:https://stackoverflow.com/questions/3908931/using-positioning-panel-in-new-jetpack-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!