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); |