Skip to content

Instantly share code, notes, and snippets.

@neonux
Created June 16, 2011 09:32
Show Gist options
  • Save neonux/1028947 to your computer and use it in GitHub Desktop.
Save neonux/1028947 to your computer and use it in GitHub Desktop.
It could be funny if...
let AddonsMgrListener = {
get addonBar() document.getElementById("addon-bar"),
get statusBar() document.getElementById("status-bar"),
getAddonBarItemCount: function() {
// Take into account the contents of the status bar shim for the count.
var itemCount = this.statusBar.childNodes.length;
var defaultOrNoninteractive = this.addonBar.getAttribute("defaultset")
.split(",")
.concat(["separator", "spacer", "spring"]);
this.addonBar.currentSet.split(",").forEach(function (item) {
if (defaultOrNoninteractive.indexOf(item) == -1)
itemCount++;
});
return itemCount;
},
onInstalling: function(aAddon) {
this.lastAddonBarCount = this.getAddonBarItemCount();
},
onInstalled: function(aAddon) {
if (this.getAddonBarItemCount() > this.lastAddonBarCount)
setToolbarVisibility(this.addonBar, true);
},
onUninstalling: function(aAddon) {
this.lastAddonBarCount = this.getAddonBarItemCount();
},
onUninstalled: function(aAddon) {
if (this.getAddonBarItemCount() == 0)
setToolbarVisibility(this.addonBar, false);
},
onEnabling: function(aAddon) this.onInstalling(),
onEnabled: function(aAddon) this.onInstalled(),
onDisabling: function(aAddon) this.onUninstalling(),
onDisabled: function(aAddon) this.onUninstalled(),
};
function toggleAddonBar() {
let addonBar = document.getElementById("addon-bar");
setToolbarVisibility(addonBar, addonBar.collapsed);
}
var Scratchpad = {
prefEnabledName: "devtools.scratchpad.enabled",
openScratchpad: function SP_openScratchpad() {
const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
return Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
SCRATCHPAD_WINDOW_FEATURES, null);
},
};
var StyleEditor = {
prefEnabledName: "devtools.style_editor.enabled",
openChrome: function SE_openChrome() {
const WINDOW_URL = "chrome://browser/content/StyleEditor/StyleEditorChrome.xul";
const WINDOW_FLAGS = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
return Services.ww.openWindow(null, WINDOW_URL, "_blank", WINDOW_FLAGS, null);
}
};
XPCOMUtils.defineLazyGetter(window, "gShowPageResizers", function () {
#ifdef XP_WIN
// Only show resizers on Windows 2000 and XP
let sysInfo = Components.classes["@mozilla.org/system-info;1"]
.getService(Components.interfaces.nsIPropertyBag2);
return parseFloat(sysInfo.getProperty("version")) < 6;
#else
return false;
#endif
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment