From 189342472ecf1d915c1b53012d6e5564c6e41e1f Mon Sep 17 00:00:00 2001
From: tophf
Date: Wed, 29 Nov 2017 19:05:47 +0300
Subject: [PATCH] manage: collapsible #options block
---
edit.html | 4 ++--
edit/edit.css | 2 +-
edit/edit.js | 23 +----------------------
js/dom.js | 32 ++++++++++++++++++++++++++++++++
js/prefs.js | 2 ++
manage.html | 8 ++++----
manage/manage.css | 30 +++++++++++++++++++++++++++---
manage/manage.js | 9 ++++++++-
8 files changed, 77 insertions(+), 33 deletions(-)
diff --git a/edit.html b/edit.html
index 1c458a5c..ee6b2fa3 100644
--- a/edit.html
+++ b/edit.html
@@ -166,7 +166,7 @@
-
+
@@ -242,7 +242,7 @@
-
+
:
-
-
+
+
@@ -258,7 +258,7 @@
i18n-title="editorStylesButton"
target="_blank">
-
+
diff --git a/manage/manage.css b/manage/manage.css
index c9979fca..45c50182 100644
--- a/manage/manage.css
+++ b/manage/manage.css
@@ -188,17 +188,17 @@ label.nobreak input {
margin-left: 1ex;
}
-summary {
+.applies-to-extra-expander {
font-weight: bold;
cursor: pointer;
outline: none;
}
-.applies-to-extra summary {
+.applies-to-extra-expander {
list-style-type: none; /* for FF, allegedly */
}
-.applies-to-extra summary::-webkit-details-marker {
+.applies-to-extra-expander::-webkit-details-marker {
display: none;
}
@@ -239,6 +239,30 @@ summary {
display: none;
}
+/* collapsibles */
+
+#header details:not([open]) h2 {
+ margin-bottom: -.25em;
+}
+
+#header summary {
+ align-items: center;
+ margin-left: -13px;
+ cursor: pointer;
+ outline: none;
+}
+
+#header summary h2 {
+ display: inline-block;
+ border-bottom: 1px dotted transparent;
+ margin-top: .2em;
+ margin-bottom: .4em;
+}
+
+#header summary h2:hover {
+ border-color: #bbb;
+}
+
/* compact layout */
.newUI #installed {
diff --git a/manage/manage.js b/manage/manage.js
index 068106c9..230e14a4 100644
--- a/manage/manage.js
+++ b/manage/manage.js
@@ -3,6 +3,7 @@
/* global checkUpdate, handleUpdateInstalled */
/* global objectDiff */
/* global configDialog */
+/* global initCollapsibles */
'use strict';
let installed;
@@ -74,6 +75,9 @@ function initGlobalEvents() {
// N.B. triggers existing onchange listeners
setupLivePrefs();
+ // the options block
+ initCollapsibles();
+
$$('[id^="manage.newUI"]')
.forEach(el => (el.oninput = (el.onchange = switchUI)));
@@ -519,10 +523,13 @@ function usePrefsDuringPageLoad() {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
// [naively] assuming each element of addedNodes is a childless element
- const prefValue = node.id ? prefs.readOnlyValues[node.id] : undefined;
+ const key = node.dataset && node.dataset.pref || node.id;
+ const prefValue = key ? prefs.readOnlyValues[key] : undefined;
if (prefValue !== undefined) {
if (node.type === 'checkbox') {
node.checked = prefValue;
+ } else if (node.localName === 'details') {
+ node.open = prefValue;
} else {
node.value = prefValue;
}