Feed abstract: Inherit font size
Some checks failed
CI / Build, Upload, Test (push) Has been cancelled
Some checks failed
CI / Build, Upload, Test (push) Has been cancelled
And fix some code style. Closes #4600
This commit is contained in:
parent
182bfb9a38
commit
f8970b92de
2 changed files with 15 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
var EXPORTED_SYMBOLS = ["FeedAbstractChild"];
|
||||
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
class FeedAbstractChild extends JSWindowActorChild {
|
||||
_stylesheet;
|
||||
|
@ -7,7 +8,12 @@ class FeedAbstractChild extends JSWindowActorChild {
|
|||
_stylesheetPromise;
|
||||
|
||||
actorCreated() {
|
||||
this._stylesheetPromise = this.sendQuery('getStylesheet');
|
||||
this._stylesheetPromise = this.sendQuery("getStylesheet");
|
||||
Services.prefs.addObserver("extensions.zotero.fontSize", this._setFontSize);
|
||||
}
|
||||
|
||||
didDestroy() {
|
||||
Services.prefs.removeObserver("extensions.zotero.fontSize", this._setFontSize);
|
||||
}
|
||||
|
||||
async receiveMessage({ name, data: { url, html } }) {
|
||||
|
@ -17,6 +23,7 @@ class FeedAbstractChild extends JSWindowActorChild {
|
|||
base.href = url;
|
||||
this.document.head.replaceChildren(base);
|
||||
this.document.body.innerHTML = html;
|
||||
this._setFontSize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -51,4 +58,9 @@ class FeedAbstractChild extends JSWindowActorChild {
|
|||
|
||||
this.document.wrappedJSObject.adoptedStyleSheets.push(this._stylesheet);
|
||||
}
|
||||
|
||||
_setFontSize = () => {
|
||||
let fontSize = Services.prefs.getStringPref("extensions.zotero.fontSize");
|
||||
this.document.body.style.fontSize = fontSize + "rem";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ class FeedAbstractParent extends JSWindowActorParent {
|
|||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "getStylesheet": {
|
||||
return Zotero.File.getResourceAsync('chrome://zotero/skin/feedAbstract.css');
|
||||
return Zotero.File.getResourceAsync("chrome://zotero/skin/feedAbstract.css");
|
||||
}
|
||||
|
||||
case "resize": {
|
||||
this._resizeBrowser(data.offsetHeight);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue