alchemy-widget 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,12 +16,10 @@ const Toc = Function.inherits('Alchemy.Widget', 'TableOfContents');
16
16
  *
17
17
  * @author Jelle De Loecker <jelle@elevenways.be>
18
18
  * @since 0.1.2
19
- * @version 0.2.0
19
+ * @version 0.2.1
20
20
  */
21
21
  Toc.setMethod(function populateWidget() {
22
22
 
23
- populateWidget.super.call(this);
24
-
25
23
  let toc = this.createElement('al-toc');
26
24
 
27
25
  if (this.config.parent_selector) {
@@ -28,7 +28,7 @@ Text.constitute(function prepareSchema() {
28
28
  *
29
29
  * @author Jelle De Loecker <jelle@elevenways.be>
30
30
  * @since 0.1.0
31
- * @version 0.1.6
31
+ * @version 0.2.1
32
32
  *
33
33
  * @param {HTMLElement} widget
34
34
  */
@@ -36,8 +36,6 @@ Text.setMethod(function populateWidget() {
36
36
 
37
37
  let tag_name;
38
38
 
39
- populateWidget.super.call(this);
40
-
41
39
  if (this.widget.dataset.textElementTag) {
42
40
  tag_name = this.widget.dataset.textElementTag;
43
41
  }
@@ -57,13 +55,16 @@ Text.setMethod(function populateWidget() {
57
55
  *
58
56
  * @author Jelle De Loecker <jelle@elevenways.be>
59
57
  * @since 0.1.0
60
- * @version 0.1.0
58
+ * @version 0.2.1
61
59
  */
62
60
  Text.setMethod(function _startEditor() {
63
61
 
64
- let child = this.widget.children[0];
62
+ let child,
63
+ i;
64
+
65
+ for (i = 0; i < this.widget.children.length; i++) {
66
+ child = this.widget.children[i];
65
67
 
66
- if (child) {
67
68
  child.setAttribute('contenteditable', true);
68
69
  }
69
70
  });
@@ -73,13 +74,16 @@ Text.setMethod(function _startEditor() {
73
74
  *
74
75
  * @author Jelle De Loecker <jelle@elevenways.be>
75
76
  * @since 0.1.0
76
- * @version 0.1.0
77
+ * @version 0.2.1
77
78
  */
78
79
  Text.setMethod(function _stopEditor() {
79
80
 
80
- let child = this.widget.children[0];
81
+ let child,
82
+ i;
83
+
84
+ for (i = 0; i < this.widget.children.length; i++) {
85
+ child = this.widget.children[i];
81
86
 
82
- if (child) {
83
87
  child.removeAttribute('contenteditable');
84
88
  }
85
89
  });
@@ -89,17 +93,13 @@ Text.setMethod(function _stopEditor() {
89
93
  *
90
94
  * @author Jelle De Loecker <jelle@elevenways.be>
91
95
  * @since 0.1.0
92
- * @version 0.1.0
96
+ * @version 0.2.1
93
97
  *
94
98
  * @return {Object}
95
99
  */
96
100
  Text.setMethod(function syncConfig() {
97
101
 
98
- let child = this.widget.children[0];
99
-
100
- if (child) {
101
- this.config.content = child.textContent;
102
- }
102
+ this.config.content = this.widget?.textContent;
103
103
 
104
104
  return this.config;
105
105
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alchemy-widget",
3
3
  "description": "The widget plugin for the AlchemyMVC",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "peerDependencies": {
13
13
  "alchemymvc" : ">=1.2.0",
14
- "alchemy-form": "~0.2.0"
14
+ "alchemy-form": "~0.2.1"
15
15
  },
16
16
  "repository": "11ways/alchemy-widget",
17
17
  "license": "MIT",
@@ -1,3 +1,5 @@
1
+ <% all_entries = self.entries %>
2
+
1
3
  {% macro printEntries %}
2
4
  <ol>
3
5
  {% each entries as entry %}
@@ -20,4 +22,12 @@
20
22
  </li>
21
23
  {% /macro %}
22
24
 
23
- {% run printEntries entries=self.entries}
25
+ {% run printEntries entries=all_entries %}
26
+
27
+ {% if all_entries %}
28
+ <% self.classList.add('toc-has-content') %>
29
+ {% else %}
30
+ <% self.classList.add('toc-is-empty') %>
31
+ {% /if %}
32
+
33
+ <% all_entries = null %>