Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to apply panel.resize in panel itself

Seems there no auto size option for Panels in Firefox Add-on SDK extensions, but panel.resize exist. Is it possible to call it on current panel?

like image 577
Vasya Avatar asked May 18 '12 17:05

Vasya


1 Answers

No, the code running inside a panel doesn't have the necessary privileges to call any SDK modules. This is solved by using a content script that will send a message back to the extension. The extension can then resize the panel. Something along these lines (untested):

var panel = require("panel").Panel({
  contentURL: ...,
  contentScript: "self.port.emit('resize', " +
                   "{width: document.documentElement.clientWidth, " +
                   "height: document.documentElement.clientHeight});"
});
panel.port.on("resize", function({width, height})
{
  panel.resize(width, height);
});
panel.show();
like image 91
Wladimir Palant Avatar answered Sep 25 '22 06:09

Wladimir Palant