[geary/wip/728002-webkit2] Fix more issues hiding/showing collapsed quotes.



commit 2087036db0a2dd411e63c2c285696d119cda7ac3
Author: Michael James Gratton <mike vee net>
Date:   Tue Jan 31 01:16:05 2017 +1100

    Fix more issues hiding/showing collapsed quotes.
    
    * ui/conversation-web-view.js
      (ConversationPageState::createControllableQuotes): Only add control
      buttons if the quote is controllable. Calculat the height difference up
      front, not in the control button's click handler, so the value is
      correct.

 ui/conversation-web-view.js |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/ui/conversation-web-view.js b/ui/conversation-web-view.js
index 43ac142..b24beb3 100644
--- a/ui/conversation-web-view.js
+++ b/ui/conversation-web-view.js
@@ -64,13 +64,16 @@ ConversationPageState.prototype = {
             // Only insert into a quote container if the element is a
             // top level blockquote
             if (!ConversationPageState.isDescendantOf(blockquote, "BLOCKQUOTE")) {
+                let quoteHeight = blockquote.offsetHeight;
+
+                // Only make the quote it controllable if it is tall enough
+                let isControllable = (quoteHeight > 120);
+
                 let quoteContainer = document.createElement("DIV");
                 quoteContainer.classList.add(
                     ConversationPageState.QUOTE_CONTAINER_CLASS
                 );
-
-                // Only make it controllable if the quote is tall enough
-                if (blockquote.offsetHeight > 120) {
+                if (isControllable) {
                     quoteContainer.classList.add("geary-controllable");
                     quoteContainer.classList.add(
                         ConversationPageState.QUOTE_HIDE_CLASS
@@ -79,7 +82,12 @@ ConversationPageState.prototype = {
 
                 let quoteDiv = document.createElement("DIV");
                 quoteDiv.classList.add("geary-quote");
+
                 quoteDiv.appendChild(blockquote);
+                quoteContainer.appendChild(quoteDiv);
+                parent.insertBefore(quoteContainer, nextSibling);
+
+                let containerHeight = quoteDiv.offsetHeight;
 
                 let state = this;
                 function newControllerButton(styleClass, text) {
@@ -94,7 +102,7 @@ ConversationPageState.prototype = {
                         // what the difference should be rather than
                         // getting it directly, since WK won't ever
                         // shrink the height of the HTML element.
-                        let height = quoteContainer.offsetHeight - quoteDiv.offsetHeight;
+                        let height = quoteHeight - containerHeight;
                         if (quoteContainer.classList.contains(hide)) {
                             height = state.lastPreferredHeight - height;
                         } else {
@@ -111,15 +119,14 @@ ConversationPageState.prototype = {
                     return container;
                 }
 
-                quoteContainer.appendChild(newControllerButton(
-                    "geary-shower", "▼        ▼        ▼"
-                ));
-                quoteContainer.appendChild(newControllerButton(
-                    "geary-hider", "▲        ▲        ▲"
-                ));
-
-                quoteContainer.appendChild(quoteDiv);
-                parent.insertBefore(quoteContainer, nextSibling);
+                if (isControllable) {
+                    quoteContainer.appendChild(newControllerButton(
+                        "geary-shower", "▼        ▼        ▼"
+                    ));
+                    quoteContainer.appendChild(newControllerButton(
+                        "geary-hider", "▲        ▲        ▲"
+                    ));
+                }
             }
         }
     },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]