diff --git a/mobile/chrome/content/AlertsHelper.js b/mobile/chrome/content/AlertsHelper.js index 4be363025b4..cdc0700a06c 100644 --- a/mobile/chrome/content/AlertsHelper.js +++ b/mobile/chrome/content/AlertsHelper.js @@ -9,10 +9,10 @@ var AlertsHelper = { // Move the popup on the other side if we are in RTL let [leftSidebar, rightSidebar] = [Elements.tabs.getBoundingClientRect(), Elements.controls.getBoundingClientRect()]; - if (leftSidebar.left > rightSidebar.left) { - container.removeAttribute("right"); + if (leftSidebar.left > rightSidebar.left) container.setAttribute("left", "0"); - } + else + container.setAttribute("right", "0"); let self = this; container.addEventListener("transitionend", function() { @@ -27,13 +27,35 @@ var AlertsHelper = { this._listener = aListener || null; this._cookie = aCookie || ""; + // Reset the container settings from the last time so layout can happen naturally + let container = this.container; + container.removeAttribute("width"); + let alertText = document.getElementById("alerts-text"); + alertText.style.whiteSpace = ""; + document.getElementById("alerts-image").setAttribute("src", aImageURL); document.getElementById("alerts-title").value = aTitle; - document.getElementById("alerts-text").textContent = aText; + alertText.textContent = aText; - let container = this.container; container.hidden = false; - container.height = container.getBoundingClientRect().height; + let bcr = container.getBoundingClientRect(); + if (bcr.width > window.innerWidth - 50) { + // If the window isn't wide enough, we need to re-layout + container.setAttribute("width", window.innerWidth - 50); // force a max width + alertText.style.whiteSpace = "pre-wrap"; // wrap text as needed + bcr = container.getBoundingClientRect(); // recalculate the bcr + } + container.setAttribute("width", bcr.width); // redundant but cheap + container.setAttribute("height", bcr.height); + +#ifdef ANDROID + let offset = (window.innerWidth - container.width) / 2; + if (container.hasAttribute("left")) + container.setAttribute("left", offset); + else + container.setAttribute("right", offset); +#endif + container.classList.add("showing"); let timeout = Services.prefs.getIntPref("alerts.totalOpenTime"); diff --git a/mobile/chrome/content/browser.xul b/mobile/chrome/content/browser.xul index b0f6cef1f80..9505599b8b1 100644 --- a/mobile/chrome/content/browser.xul +++ b/mobile/chrome/content/browser.xul @@ -661,8 +661,7 @@ -