Fix conversation message not shrinking when collapsing quotes.
* ui/conversation-web-view.js (ConversationPageState::createControllableQuotes): Since WK does not want to seem to reduce the value of offsetHeight for the HTML element when a quote is collapsed, calculate the difference and manually update the preferred height. * ui/client-web-view.js (PageState::updatePreferredHeight): Allow the new preferred height to be passed in as a param.
This commit is contained in:
parent
8bf68bd345
commit
d74fcd2e2c
2 changed files with 23 additions and 24 deletions
|
|
@ -84,9 +84,12 @@ PageState.prototype = {
|
||||||
/**
|
/**
|
||||||
* Sends "preferredHeightChanged" message if it has changed.
|
* Sends "preferredHeightChanged" message if it has changed.
|
||||||
*/
|
*/
|
||||||
updatePreferredHeight: function() {
|
updatePreferredHeight: function(height) {
|
||||||
|
if (height === undefined) {
|
||||||
|
height = this.getPreferredHeight();
|
||||||
|
}
|
||||||
|
|
||||||
let updated = false;
|
let updated = false;
|
||||||
let height = this.getPreferredHeight();
|
|
||||||
if (height > 0 && height != this.lastPreferredHeight) {
|
if (height > 0 && height != this.lastPreferredHeight) {
|
||||||
updated = true;
|
updated = true;
|
||||||
this.lastPreferredHeight = height;
|
this.lastPreferredHeight = height;
|
||||||
|
|
|
||||||
|
|
@ -51,20 +51,6 @@ ConversationPageState.prototype = {
|
||||||
document.documentElement.dir = "auto";
|
document.documentElement.dir = "auto";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Polls for a change in the page's preferred height.
|
|
||||||
*/
|
|
||||||
pollPreferredHeightUpdate: function() {
|
|
||||||
let state = this;
|
|
||||||
let count = 0;
|
|
||||||
let timeoutId = window.setInterval(function() {
|
|
||||||
if (state.updatePreferredHeight() || ++count >= 10) {
|
|
||||||
// Cancel polling when height actually changes or if
|
|
||||||
// no change was found after a long enough period
|
|
||||||
window.clearTimeout(timeoutId);
|
|
||||||
}
|
|
||||||
}, 10);
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Add top level blockquotes to hide/show container.
|
* Add top level blockquotes to hide/show container.
|
||||||
*/
|
*/
|
||||||
|
|
@ -91,16 +77,30 @@ ConversationPageState.prototype = {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let quoteDiv = document.createElement("DIV");
|
||||||
|
quoteDiv.classList.add("geary-quote");
|
||||||
|
quoteDiv.appendChild(blockquote);
|
||||||
|
|
||||||
let state = this;
|
let state = this;
|
||||||
function newControllerButton(styleClass, text) {
|
function newControllerButton(styleClass, text) {
|
||||||
let button = document.createElement("BUTTON");
|
let button = document.createElement("BUTTON");
|
||||||
button.classList.add("geary-button");
|
button.classList.add("geary-button");
|
||||||
button.type = "button";
|
button.type = "button";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
quoteContainer.classList.toggle(
|
let hide = ConversationPageState.QUOTE_HIDE_CLASS;
|
||||||
ConversationPageState.QUOTE_HIDE_CLASS
|
quoteContainer.classList.toggle(hide);
|
||||||
);
|
|
||||||
state.pollPreferredHeightUpdate();
|
// Update the preferred height. We calculate
|
||||||
|
// 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;
|
||||||
|
if (quoteContainer.classList.contains(hide)) {
|
||||||
|
height = state.lastPreferredHeight - height;
|
||||||
|
} else {
|
||||||
|
height = state.lastPreferredHeight + height;
|
||||||
|
}
|
||||||
|
state.updatePreferredHeight(height);
|
||||||
};
|
};
|
||||||
button.appendChild(document.createTextNode(text));
|
button.appendChild(document.createTextNode(text));
|
||||||
|
|
||||||
|
|
@ -118,10 +118,6 @@ ConversationPageState.prototype = {
|
||||||
"geary-hider", "▲ ▲ ▲"
|
"geary-hider", "▲ ▲ ▲"
|
||||||
));
|
));
|
||||||
|
|
||||||
let quoteDiv = document.createElement("DIV");
|
|
||||||
quoteDiv.classList.add("geary-quote");
|
|
||||||
quoteDiv.appendChild(blockquote);
|
|
||||||
|
|
||||||
quoteContainer.appendChild(quoteDiv);
|
quoteContainer.appendChild(quoteDiv);
|
||||||
parent.insertBefore(quoteContainer, nextSibling);
|
parent.insertBefore(quoteContainer, nextSibling);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue