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

Unified Diff: popup.js

Issue 29532767: Issue 5593 - Use messaging in popup for prefs, whitelisting, and stats (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Use messaging for prefs in stats.js Created Sept. 1, 2017, 3:51 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
Index: popup.js
===================================================================
--- a/popup.js
+++ b/popup.js
@@ -16,17 +16,16 @@
*/
"use strict";
const {require} = ext.backgroundPage.getWindow();
const {Filter} = require("filterClasses");
const {FilterStorage} = require("filterStorage");
-const {Prefs} = require("prefs");
const {checkWhitelisted} = require("whitelisting");
const {getDecodedHostname} = require("url");
let page = null;
function onLoad()
{
ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
@@ -79,22 +78,25 @@
{
ext.showOptions();
}, false);
// Set up collapsing of menu items
for (let collapser of document.getElementsByClassName("collapse"))
{
collapser.addEventListener("click", toggleCollapse, false);
- if (!Prefs[collapser.dataset.option])
+ ext.prefs.get(collapser.dataset.option, value =>
{
- document.getElementById(
- collapser.dataset.collapsable
- ).classList.add("collapsed");
- }
+ if (value)
+ {
+ document.getElementById(
+ collapser.dataset.collapsible
+ ).classList.remove("collapsed");
+ }
+ });
}
}
function toggleEnabled()
{
let disabled = document.body.classList.toggle("disabled");
if (disabled)
{
@@ -140,13 +142,14 @@
}
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 collapsible = document.getElementById(collapser.dataset.collapsible);
+ collapsible.classList.toggle("collapsed");
+ ext.prefs.toggle(collapser.dataset.option);
}
document.addEventListener("DOMContentLoaded", onLoad, false);

Powered by Google App Engine
This is Rietveld