1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.devacfr.maven.skins.reflow.model;
20
21 import javax.annotation.Nonnull;
22
23 import org.devacfr.maven.skins.reflow.ISkinConfig;
24
25
26
27
28
29 public class TocSidebar extends Toc<TocSidebar> {
30
31
32 private boolean fixed = true;
33
34
35 private boolean expanded = true;
36
37
38 private boolean autoExpandable = true;
39
40
41 private int level = 0;
42
43
44
45
46
47
48
49 public TocSidebar(final @Nonnull ISkinConfig config) {
50 super("sidebar", "sidebar");
51 final String position = config.getAttributeValue("toc", "position", String.class, "fixed").toLowerCase();
52 this.withEnabled(true)
53 .withExpanded(config.getAttributeValue("toc", "expanded", Boolean.class, true))
54 .withAutoExpandable(config.getAttributeValue("toc", "autoExpandable", Boolean.class, true))
55 .withFixed("fixed".equals(position))
56 .withLevel(config.getAttributeValue("toc", "level", Integer.class, 0));
57 if (this.isEnabled()) {
58 this.addCssOptions("m-toc-sidebar-enabled");
59 }
60 if (isExpanded()) {
61 this.addCssOptions("m-toc-sidebar-expanded");
62 }
63 if (isAutoExpandable()) {
64 this.addCssOptions("m-toc-sidebar-autoexpandable");
65 }
66 if (isFixed()) {
67 this.addCssOptions("toc-sidebar-fixed");
68 } else {
69 this.addCssOptions("toc-sidebar-relative");
70 }
71 }
72
73
74
75
76
77
78 public boolean isFixed() {
79 return fixed;
80 }
81
82
83
84
85
86
87
88
89 protected TocSidebar withFixed(final boolean fixed) {
90 this.fixed = fixed;
91 return self();
92 }
93
94
95
96
97
98
99 public boolean isExpanded() {
100 return expanded;
101 }
102
103
104
105
106
107
108
109
110 protected TocSidebar withExpanded(final boolean expanded) {
111 this.expanded = expanded;
112 return self();
113 }
114
115
116
117
118
119
120 public boolean isAutoExpandable() {
121 return autoExpandable;
122 }
123
124
125
126
127
128
129
130
131 protected TocSidebar withAutoExpandable(final boolean autoExpandable) {
132 this.autoExpandable = autoExpandable;
133 return self();
134 }
135
136
137
138
139 public int getLevel() {
140 return level;
141 }
142
143
144
145
146
147
148
149
150 protected TocSidebar withLevel(final int level) {
151 if (level < 1) {
152 this.level = Integer.MAX_VALUE;
153 } else {
154 this.level = level;
155 }
156 return self();
157 }
158 }