summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhackademix2018-07-12 16:01:26 +0200
committerhackademix2018-07-12 16:01:26 +0200
commit8f6574661d06fa2e047e950645d3e0c90ec5be0d (patch)
tree2bf81a6ad8b896be7b928c81edc2172bb165492e /src
parent54dd9fa754262cb14204e68e1b34b214657bc1db (diff)
downloadnoscript-8f6574661d06fa2e047e950645d3e0c90ec5be0d.tar.gz
noscript-8f6574661d06fa2e047e950645d3e0c90ec5be0d.tar.xz
noscript-8f6574661d06fa2e047e950645d3e0c90ec5be0d.zip
Fixed first popup row not showing the initial site active preset.
Diffstat (limited to 'src')
-rw-r--r--src/ui/ui.js60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/ui/ui.js b/src/ui/ui.js
index e367f74..6538ade 100644
--- a/src/ui/ui.js
+++ b/src/ui/ui.js
@@ -214,6 +214,9 @@ var UI = (() => {
}
+ if (!UI.mobile) {
+ UI.Sites.correctSize(presets);
+ }
}
@@ -246,42 +249,40 @@ var UI = (() => {
return row;
}
- correctSize() {
- if (!(UI.mobile || document.getElementById("presets-sizer"))) {
- // adapt button to label if needed
- let presets = document.querySelector(".presets");
- let sizer = document.createElement("div");
- sizer.id = "presets-sizer";
- sizer.appendChild(presets.cloneNode(true));
- document.body.appendChild(sizer);
- setTimeout(async () => {
- let presetWidth = sizer.querySelector("input.preset").offsetWidth;
- let labelWidth = 0;
- for (let l of sizer.querySelectorAll("label.preset")) {
- let lw = l.offsetWidth;
- debug("lw", l.textContent, lw);
- if (lw > labelWidth) labelWidth = lw;
- }
+ static correctSize(presets) {
+ // adapt button to label if needed
+ let sizer = document.createElement("div");
+ sizer.id = "presets-sizer";
+ sizer.appendChild(presets.cloneNode(true));
+ document.body.appendChild(sizer);
+ setTimeout(async () => {
+ let presetWidth = sizer.querySelector("input.preset").offsetWidth;
+ let labelWidth = 0;
+ for (let l of sizer.querySelectorAll("label.preset")) {
+ let lw = l.offsetWidth;
+ debug("lw", l.textContent, lw);
+ if (lw > labelWidth) labelWidth = lw;
+ }
- debug(`Preset: %s Label: %s`, presetWidth, labelWidth);
- labelWidth += 16;
- if (presetWidth < labelWidth) {
- for (let ss of document.styleSheets) {
- if (ss.href.endsWith("/ui.css")) {
- for (let r of ss.cssRules) {
- if (/input\.preset:checked.*min-width:/.test(r.cssText)) {
- r.style.minWidth = (labelWidth) + "px";
- break;
- }
+ debug(`Preset: %s Label: %s`, presetWidth, labelWidth);
+ labelWidth += 16;
+ if (presetWidth < labelWidth) {
+ for (let ss of document.styleSheets) {
+ if (ss.href.endsWith("/ui.css")) {
+ for (let r of ss.cssRules) {
+ if (/input\.preset:checked.*min-width:/.test(r.cssText)) {
+ r.style.minWidth = (labelWidth) + "px";
+ break;
}
}
}
}
+ }
- sizer.style.display = "none";
+ sizer.remove();
- }, 100);
- }
+ }, 100);
+ UI.Sites.correctSize = () => {}; // just once, please!
}
allSiteRows() {
@@ -446,7 +447,6 @@ var UI = (() => {
root.addEventListener("change", this, true);
root.wiredBy = this;
}
- this.correctSize();
return root;
}