Skip to content

Instantly share code, notes, and snippets.

@azu
Created December 30, 2012 14:59
Show Gist options
  • Save azu/4413137 to your computer and use it in GitHub Desktop.
Save azu/4413137 to your computer and use it in GitHub Desktop.
Addon-SDK : anchor a panel to a widget
var socialWidget = require("widget").Widget({
id : "open-clock-btn",
label : "Clock",
contentURL : "http://www.mozilla.org/favicon.ico",
panel : socialPanel,
onClick : seeingHatenaBookmark
});
function getItemNodeForWidget(widget){
var item;
for (var win in require("window-utils").windowIterator()){
var doc = win.document;
var bar = doc.getElementById("addon-bar");
var selector = 'toolbaritem[id$="' + widget.id + '"]';
item = bar.querySelector(selector);
}
return item;
}
var item = getItemNodeForWidget(socialWidget);
socialPanel.show(item);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment