Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: popup.js

Issue 29532763: Issue 5593 - Wait for prefs before updating popup UI (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Aug. 31, 2017, 3:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« popup.html ('K') | « popup.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: popup.js
===================================================================
--- a/popup.js
+++ b/popup.js
@@ -75,27 +75,30 @@
document.getElementById("clickhide-cancel").addEventListener(
"click", cancelClickHide, false
);
document.getElementById("options").addEventListener("click", () =>
{
ext.showOptions();
}, false);
- // Set up collapsing of menu items
- for (let collapser of document.getElementsByClassName("collapse"))
+ Prefs.untilLoaded.then(() =>
Manish Jethani 2017/08/31 15:56:57 Wait for the prefs to load.
{
- collapser.addEventListener("click", toggleCollapse, false);
- if (!Prefs[collapser.dataset.option])
+ // Set up collapsing of menu items
+ for (let collapser of document.getElementsByClassName("collapse"))
{
- document.getElementById(
- collapser.dataset.collapsable
- ).classList.add("collapsed");
+ collapser.addEventListener("click", toggleCollapse, false);
+ if (Prefs[collapser.dataset.option])
Manish Jethani 2017/08/31 15:56:57 Since it's now collapsed by default, uncollapse it
+ {
+ document.getElementById(
+ collapser.dataset.collapsable
+ ).classList.remove("collapsed");
+ }
Thomas Greiner 2017/08/31 16:39:08 FYI: IIRC we've avoided using `Element.classList.t
}
- }
+ });
}
function toggleEnabled()
{
let disabled = document.body.classList.toggle("disabled");
if (disabled)
{
let host = getDecodedHostname(page.url).replace(/^www\./, "");
@@ -140,13 +143,13 @@
}
document.body.classList.remove("clickhide-active");
page.sendMessage({type: "composer.content.finished"});
}
function toggleCollapse(event)
{
let collapser = event.currentTarget;
- Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
- collapser.parentNode.classList.toggle("collapsed");
+ let collapsable = document.getElementById(collapser.dataset.collapsable);
Thomas Greiner 2017/08/31 16:39:08 Typo: Replace "collapsable" with "collapsible"
+ Prefs[collapser.dataset.option] = !collapsable.classList.toggle("collapsed");
Manish Jethani 2017/08/31 15:56:57 The pref value should follow the UI so they never
Thomas Greiner 2017/08/31 16:39:08 Usually we do it the other way around to ensure th
}
document.addEventListener("DOMContentLoaded", onLoad, false);
« popup.html ('K') | « popup.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld