Change reload so that the text size style can be used in more places.

This commit is contained in:
Maurice Parker 2021-09-17 15:59:43 -05:00
parent 48b2a5ca0f
commit b43d8b6b28
2 changed files with 9 additions and 12 deletions

View File

@ -155,16 +155,12 @@ final class DetailWebViewController: NSViewController {
@objc func userDefaultsDidChange(_ note: Notification) {
if articleTextSize != AppDefaults.shared.articleTextSize {
articleTextSize = AppDefaults.shared.articleTextSize
webView.evaluateJavaScript("updateTextSize(\"\(articleTextSize.cssClass)\");")
reloadHTMLMaintainingScrollPosition()
}
}
@objc func currentArticleThemeDidChangeNotification(_ note: Notification) {
fetchScrollInfo() { scrollInfo in
self.windowScrollY = scrollInfo?.offsetY
self.reloadHTML()
}
reloadHTMLMaintainingScrollPosition()
}
// MARK: Media Functions
@ -293,6 +289,13 @@ private extension DetailWebViewController {
webView?.evaluateJavaScript("reloadArticleImage(\"\(imageSrc)\")")
}
}
func reloadHTMLMaintainingScrollPosition() {
fetchScrollInfo() { scrollInfo in
self.windowScrollY = scrollInfo?.offsetY
self.reloadHTML()
}
}
func reloadHTML() {
delegate?.mouseDidExit(self)

View File

@ -132,12 +132,6 @@ function stopMediaPlayback() {
});
}
function updateTextSize(cssClass) {
var bodyElement = document.getElementById("bodyContainer");
bodyElement.classList.remove("smallText", "mediumText", "largeText", "xLargeText", "xxLargeText");
bodyElement.classList.add(cssClass);
}
function error() {
document.body.innerHTML = "error";
}