geary/ui/client-web-view.js
Michael James Gratton 8864e2b7a7 Work around rendering quote controller buttons, enable expanding quotes.
* ui/conversation-web-view.js (ConversationPageState): Add
  ::updatePreferredHeight method to waitch for and update the web view's
  preferred height when it changes.
  (ConversationPageState::createControllableQuotes): Create quote
  controllers using the DOM so we can easily attach click handlers to
  it. Attach handlers to toggle the hide class and updated the preferred
  height.

* ui/client-web-view.js (PageState): Add ::getPreferredHeight method, use
  that to determine the preferred height of the page.

* ui/conversation-web-view.css: Import GTK+4 Adwaita button CSS to work
  around WebKitGTK+ Bug 166648. Tweak quote style a bit.
2017-02-01 00:41:43 +11:00

59 lines
1.7 KiB
JavaScript

/*
* Copyright 2016 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/**
* Application logic for ClientWebView and subclasses.
*/
var PageState = function() {
this.init.apply(this, arguments);
};
PageState.prototype = {
init: function() {
this.allowRemoteImages = false;
this.is_loaded = false;
var state = this;
var timeoutId = window.setInterval(function() {
state.preferredHeightChanged();
if (state.is_loaded) {
window.clearTimeout(timeoutId);
}
}, 50);
},
getPreferredHeight: function() {
return window.document.documentElement.offsetHeight;
},
loaded: function() {
this.is_loaded = true;
},
loadRemoteImages: function() {
this.allowRemoteImages = true;
var images = document.getElementsByTagName("IMG");
for (var i = 0; i < images.length; i++) {
var img = images.item(i);
var src = img.src;
img.src = "";
img.src = src;
}
},
remoteImageLoadBlocked: function() {
window.webkit.messageHandlers.remoteImageLoadBlocked.postMessage(null);
},
preferredHeightChanged: function() {
let height = this.getPreferredHeight();
if (height > 0) {
window.webkit.messageHandlers.preferredHeightChanged.postMessage(
height
);
}
},
selectionChanged: function() {
var has_selection = !window.getSelection().isCollapsed;
window.webkit.messageHandlers.selectionChanged.postMessage(has_selection);
}
};