aboutsummaryrefslogtreecommitdiff
path: root/client/js/controls/expander_control.js
diff options
context:
space:
mode:
authorrr-2016-08-23 23:09:07 +0200
committerrr-2016-08-23 23:19:40 +0200
commit7f4a2c1ceb3f1212874e61a40f50eecbc364ed52 (patch)
tree56bb7507cf65c3f6f6c0a5a369de1a362b15a2bf /client/js/controls/expander_control.js
parentcc787665859ec1d1a97c5ed262c824c4944c4f60 (diff)
client/posts: show tag/note counters in expanders
Diffstat (limited to 'client/js/controls/expander_control.js')
-rw-r--r--client/js/controls/expander_control.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/client/js/controls/expander_control.js b/client/js/controls/expander_control.js
index 93ba2cb..a07367a 100644
--- a/client/js/controls/expander_control.js
+++ b/client/js/controls/expander_control.js
@@ -8,8 +8,8 @@ const views = require('../util/views.js');
const template = views.getTemplate('expander');
class ExpanderControl {
- constructor(title, nodes) {
- this._title = title;
+ constructor(name, title, nodes) {
+ this._name = name;
nodes = Array.from(nodes).filter(n => n);
if (!nodes.length) {
@@ -33,12 +33,16 @@ class ExpanderControl {
expanderNode.classList.toggle(
'collapsed',
- this._allStates[this._title] === undefined ?
+ this._allStates[this._name] === undefined ?
false :
- !this._allStates[this._title]);
+ !this._allStates[this._name]);
this._syncIcon();
}
+ set title(newTitle) {
+ this._expanderNode.querySelector('header span').textContent = newTitle;
+ }
+
get _isOpened() {
return !this._expanderNode.classList.contains('collapsed');
}
@@ -53,7 +57,7 @@ class ExpanderControl {
_save() {
const newStates = Object.assign({}, this._allStates);
- newStates[this._title] = this._isOpened;
+ newStates[this._name] = this._isOpened;
localStorage.setItem('expander', JSON.stringify(newStates));
}

© 2015 - 2026 Jakob L. Kreuze