2013-02-28 86 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; 
相關問題