summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorAndy Huang <ath@google.com>2012-10-13 13:30:19 -0700
committerAndy Huang <ath@google.com>2012-10-13 22:24:40 -0700
commitadbf3e8cadb66666f307352b72537fbac57b916f (patch)
tree383c766111ca2bc87675a971fd6043ef4af9dd04 /assets
parent90528f425e09a72b1505c3a1066051ab5a3a67b4 (diff)
downloadandroid_packages_apps_UnifiedEmail-adbf3e8cadb66666f307352b72537fbac57b916f.tar.gz
android_packages_apps_UnifiedEmail-adbf3e8cadb66666f307352b72537fbac57b916f.tar.bz2
android_packages_apps_UnifiedEmail-adbf3e8cadb66666f307352b72537fbac57b916f.zip
toggle normalization & zoom on/off
and wire it all up to a pref that re-renders upon change. separately, make a few improvements to whitespace management when zoomed in with normalized mode: * place attachment overlays at the top of their regions * place overlays above the first expanded message at the top of the conversation, instead of the usual position just above the message. * impose a max zoom factor to limit excessive spacer whitespace Bug: 7312540 Change-Id: Iae3afff0ee81e4ba9367568e884a041780b24ebf
Diffstat (limited to 'assets')
-rw-r--r--assets/script.js35
1 files changed, 25 insertions, 10 deletions
diff --git a/assets/script.js b/assets/script.js
index 27da9be3e..2aaf314e5 100644
--- a/assets/script.js
+++ b/assets/script.js
@@ -111,9 +111,15 @@ function normalizeAllMessageWidths() {
function normalizeElementWidths(elements) {
var i;
var el;
- var documentWidth = document.body.offsetWidth;
+ var documentWidth;
var newZoom, oldZoom;
+ if (!NORMALIZE_MESSAGE_WIDTHS) {
+ return;
+ }
+
+ documentWidth = document.body.offsetWidth;
+
for (i = 0; i < elements.length; i++) {
el = elements[i];
oldZoom = el.style.zoom;
@@ -256,23 +262,32 @@ function setupContentReady() {
// BEGIN Java->JavaScript handlers
function measurePositions() {
- var overlayBottoms;
- var h;
+ var overlayTops, overlayBottoms;
var i;
var len;
- var expandedSpacerDivs = document.querySelectorAll(".expanded > .spacer");
+ var expandedBody, headerSpacer;
+ var prevBodyBottom = 0;
+ var expandedBodyDivs = document.querySelectorAll(".expanded > .mail-message-content");
+
+ // N.B. offsetTop and offsetHeight of an element with the "zoom:" style applied cannot be
+ // trusted.
- overlayBottoms = new Array(expandedSpacerDivs.length + 1);
- for (i = 0, len = expandedSpacerDivs.length; i < len; i++) {
- h = expandedSpacerDivs[i].offsetHeight;
+ overlayTops = new Array(expandedBodyDivs.length + 1);
+ overlayBottoms = new Array(expandedBodyDivs.length + 1);
+ for (i = 0, len = expandedBodyDivs.length; i < len; i++) {
+ expandedBody = expandedBodyDivs[i];
+ headerSpacer = expandedBody.previousElementSibling;
// addJavascriptInterface handler only supports string arrays
- overlayBottoms[i] = "" + (getTotalOffset(expandedSpacerDivs[i]).top + h);
+ overlayTops[i] = "" + prevBodyBottom;
+ overlayBottoms[i] = "" + (getTotalOffset(headerSpacer).top + headerSpacer.offsetHeight);
+ prevBodyBottom = getTotalOffset(expandedBody.nextElementSibling).top;
}
- // add an extra one to mark the bottom of the last message
+ // add an extra one to mark the top/bottom of the last message footer spacer
+ overlayTops[i] = "" + prevBodyBottom;
overlayBottoms[i] = "" + document.body.offsetHeight;
- window.mail.onWebContentGeometryChange(overlayBottoms);
+ window.mail.onWebContentGeometryChange(overlayTops, overlayBottoms);
}
function unblockImages(messageDomId) {