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 I/O Created Aug. 31, 2017, 5:07 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') | skin/popup.css » ('j') | 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
@@ -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,29 @@
{
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])
+ chrome.runtime.sendMessage({
+ type: "prefs.get",
+ key: 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 +146,17 @@
}
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");
+ chrome.runtime.sendMessage({
+ type: "prefs.toggle",
+ key: collapser.dataset.option
+ });
}
document.addEventListener("DOMContentLoaded", onLoad, false);
« popup.html ('K') | « popup.html ('k') | skin/popup.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld