File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 93
93
color : # 777 ;
94
94
}
95
95
96
+ .toc .invisable-node {
97
+ list-style-type : none;
98
+ }
99
+
96
100
.ui-toc {
97
101
position : fixed;
98
102
bottom : 20px ;
Original file line number Diff line number Diff line change 52
52
titleNames = this . _elTitlesNames
53
53
ulClass = this . ulClass
54
54
}
55
- var titleElementsLen = titleElements . length
56
55
// No need to do anything for an empty ToC
57
- if ( ! titleElementsLen ) return
56
+ if ( ! titleElements . length ) return
58
57
59
- this . tocContent = ''
60
58
var content = '<ul'
61
59
if ( ulClass ) {
62
60
content += ' class="' + ulClass + '"'
63
61
}
64
- content += '>'
62
+ content += '>\n '
65
63
var iterTag = titleNames [ level ]
66
64
var recurse = false
65
+ var openTag = false
67
66
68
67
for ( var element ; element = titleElements . shift ( ) ; ) {
69
68
var elementTag = element . tagName . toLowerCase ( )
80
79
} else {
81
80
id = '#' + id
82
81
}
82
+ if ( openTag ) {
83
+ content += '</li>\n'
84
+ openTag = false
85
+ }
83
86
content += '<li><a href="' + id + '" title="' + elementTitle + '">' + elementText + '</a>'
84
87
// Reset recursion. We need it for the next subsections
85
88
recurse = false
86
-
89
+ openTag = true
87
90
// Check if the current element has a lower level than ours, if so, we have to go down the rabbithole!
88
91
} else if ( ! recurse && titleNames . indexOf ( elementTag . toLowerCase ( ) ) > level ) {
89
92
recurse = true
93
+ if ( ! openTag ) {
94
+ content += '<li class="invisable-node">'
95
+ openTag = true
96
+ }
90
97
// This element is for the lower lever, we have to re-add it before we send the list down there.
91
98
titleElements . unshift ( element )
92
99
// Let's call ourself and get to the next level
99
106
}
100
107
}
101
108
102
- content += '</ul>'
109
+ if ( openTag ) {
110
+ content += '</li>\n'
111
+ }
112
+ content += '</ul>\n'
103
113
104
114
// Set ToC content of the level 0 everything else pass things to the upper level!
105
115
if ( level === 0 ) {
You can’t perform that action at this time.
0 commit comments