如何在Mozilla中像Chrome扩展一样更改面板大小 [英] How to change Panel Size in mozilla like chrome extension

查看:160
本文介绍了如何在Mozilla中像Chrome扩展一样更改面板大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

面板大小在基于SDK的插件中是固定的

我想像chrome字典扩展名一样自动更改面板大小< href =https://chrome.google.com/webstore/detail/dictionarycom-extension/epkhgmlgiomobdlofllfmoejgjdojknn?utm_source=chrome-ntp-icon =nofollow>这里



如果您要在面板中搜索,则会显示内容需求等大小数据。
在Mozilla面板中,我们只能修复一种类型的大小,如 width:400px height:400px 等。但我希望面板的大小应该基于数据大小意味着像铬扩展。

解决方案

您可以在Add-在一些额外的代码SDK上。

在main.js中:

  var panel = require(panel)。Panel({
contentURL:https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK,
onShow (){
data.url('windowsize.js')
]
} );

worker.port.on('winsize',function(data){
panel.resize((data.width-120),(data.height-120));
});
worker.port.emit('fetchwinsize');
}
});

在内容脚本中:

<$ p $ (){$ b $ self.port.eon(winsize,{height:window.innerHeight,width:window.innerWidth}) ;
});

下面是一个可行的例子:

https://builder.addons.mozilla.org/package/150225/latest/


Panel Size is fixed in SDK-based Add-on

I want to change the size of panel automatically like chrome dictionary extension here

If you will search in panel it will show big and small data like content requirement. In Mozilla panel we can fix only 1 type of size like width:400px and height:400px etc. but i want that panel size should based on data size means like chrome extensions.

解决方案

You can implement this in the Add-on SDK with a little extra code.

In main.js:

var panel = require("panel").Panel({
  contentURL: "https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK",
  onShow: function() {
        let worker = tabs.activeTab.attach({
            contentScriptFile: [
                data.url('windowsize.js')
            ]
        });

        worker.port.on('winsize', function(data) {
            panel.resize((data.width-120), (data.height-120));
        });
        worker.port.emit('fetchwinsize');
  }
});

In the content script:

self.port.on('fetchwinsize', function() {
    self.port.emit("winsize", {height: window.innerHeight, width: window.innerWidth});
});

Here's a working example of this:

https://builder.addons.mozilla.org/package/150225/latest/

这篇关于如何在Mozilla中像Chrome扩展一样更改面板大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆