Skip to content

Instantly share code, notes, and snippets.

@teramako
Created January 18, 2011 15:46
Show Gist options
  • Save teramako/784616 to your computer and use it in GitHub Desktop.
Save teramako/784616 to your computer and use it in GitHub Desktop.
tansparent Panorama background for https://bugzilla.mozilla.org/show_bug.cgi?id=593388
// userChorme.js
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=593388
window.addEventListener("tabviewframeinitialized", function (event) {
this.removeEventListener(event.type, arguments.callee, false);
var win = TabView._window;
var tabViewRootElement = win.document.documentElement;
function updateBackground (isLwthemeActive) {
var imageStyle = "";
if (isLwthemeActive) {
let bgColor = window.getComputedStyle(document.documentElement, "").backgroundColor;
imageStyle = "-moz-linear-gradient(center top, transparent, transparent 150px," + bgColor + " 190px, " + bgColor + ")";
}
win.document.getElementById("bg").style.backgroundImage = imageStyle;
}
if (window.document.documentElement.hasAttribute("lwtheme")) {
tabViewRootElement.setAttribute("lwtheme", "true");
updateBackground(true);
}
var lwthemeObserver = {
rootElement: tabViewRootElement,
observe: function (aSubject, aTopic, aData) {
if (aTopic != "lightweight-theme-styling-update")
return;
if (aData === "null") {
this.rootElement.removeAttribute("lwtheme");
updateBackground(false);
} else {
this.rootElement.setAttribute("lwtheme", "true");
updateBackground(true);
}
},
};
win.Services.obs.addObserver(lwthemeObserver, "lightweight-theme-styling-update", false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment