2013-02-28 83 views
0

Helo,我尝试开发(我的第一个)Firefox附加组件。它应该在几个定义的网址上显示一些面板并附带一些内容。这工作,如果我点击小工具 - 符号罚款。现在我想要的是,如果用户加载页面,则显示面板。我如何将一个面板锚定到一个小部件(Firefox插件SDK)

panel.show();以面板为中心显示。我想将面板映射/定位到小部件,以便面板显示在右下角。

解决方案https://gist.github.com/azu/4413137Mozilla "Jetpack" Add-On: Anchor Panel to Widget没有为我工作。 (SDK 1.13.2通过插件生成器)

我的代码:

thePanel = panel.Panel({ 
    width: 320, 
    height: 170, 
    contentScriptFile: [self.data.url('jquery.js'), self.data.url('panel.js')], 
    contentScriptWhen: "ready", 
    contentScript: "SOMESCRIPT", 
    contentURL: self.data.url('thecontent.html'), 
    onMessage: function (item) { 
     console.log('message : "' + item + '"'); 
     tabs.open(item); 
    } 
}); 


var widget = widgets.Widget({ 
    id: "my-id", 
    label: ".de", 
    panel: thePanel, 
    contentURL: self.data.url("favicon.ico"), 
    onClick: function() { 
     /*blabla*/ 
    } 
}); 

tabs.on('ready', function(tab) { 
    check_content(); // loads thecontent.html for panel content 
    thePanel.show(); // Shows panel at center 
}); 

有人能帮助我吗?

回答

1
thePanel = panel.Panel({ 
    width: 320, 
    height: 170, 
    contentScriptFile: [self.data.url('jquery.js'), self.data.url('panel.js')], 
    contentScriptWhen: "ready", 
    contentScript: "SOMESCRIPT", 
    contentURL: self.data.url('thecontent.html'), 
    onMessage: function (item) { 
     console.log('message : "' + item + '"'); 
     tabs.open(item); 
    } 
}); 


var widget = widgets.Widget({ 
    id: "my-id", 
    label: ".de", 
    //panel: thePanel, 
    contentURL: self.data.url("favicon.ico"), 
    onClick: function(view) { 
     /*This will work*/ 
     view.panel = thePanel; 
     /*This will work*/ 
    } 
}); 

Instead of using panel.show(), use view.panel = thePanel; 
相关问题