@@ -122,17 +122,18 @@ function toggleInherit(id)
122
122
}
123
123
124
124
var opened = true ;
125
- var plusImg = "var(--fold-plus-image)" ;
126
- var minusImg = "var(--fold-minus-image)" ;
125
+ // in case HTML_COLORSTYLE is LIGHT or DARK the vars will be replaced, so we write them out explicitly and use double quotes
126
+ var plusImg = [ "var(--fold-plus-image)" , "var(--fold-plus-image-relpath)" ] ;
127
+ var minusImg = [ "var(--fold-minus-image)" , "var(--fold-minus-image-relpath)" ] ;
127
128
128
129
// toggle all folding blocks
129
- function codefold_toggle_all ( ) {
130
+ function codefold_toggle_all ( relPath ) {
130
131
if ( opened ) {
131
- $ ( '#fold_all' ) . css ( 'background-image' , plusImg ) ;
132
+ $ ( '#fold_all' ) . css ( 'background-image' , plusImg [ relPath ] ) ;
132
133
$ ( 'div[id^=foldopen]' ) . hide ( ) ;
133
134
$ ( 'div[id^=foldclosed]' ) . show ( ) ;
134
135
} else {
135
- $ ( '#fold_all' ) . css ( 'background-image' , minusImg ) ;
136
+ $ ( '#fold_all' ) . css ( 'background-image' , minusImg [ relPath ] ) ;
136
137
$ ( 'div[id^=foldopen]' ) . show ( ) ;
137
138
$ ( 'div[id^=foldclosed]' ) . hide ( ) ;
138
139
}
@@ -144,7 +145,7 @@ function codefold_toggle(id) {
144
145
$ ( '#foldopen' + id ) . toggle ( ) ;
145
146
$ ( '#foldclosed' + id ) . toggle ( ) ;
146
147
}
147
- function init_codefold ( ) {
148
+ function init_codefold ( relPath ) {
148
149
$ ( 'span[class=lineno]' ) . css (
149
150
{ 'padding-right' :'4px' ,
150
151
'margin-right' :'2px' ,
@@ -153,7 +154,9 @@ function init_codefold() {
153
154
'background' :'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%'
154
155
} ) ;
155
156
// add global toggle to first line
156
- $ ( 'span[class=lineno]:first' ) . append ( '<span class="fold" id="fold_all" onclick="javascript:codefold_toggle_all();" style="background-image:' + minusImg + ';"></span>' ) ;
157
+ $ ( 'span[class=lineno]:first' ) . append ( '<span class="fold" id="fold_all" ' +
158
+ 'onclick="javascript:codefold_toggle_all(' + relPath + ');" ' +
159
+ 'style="background-image:' + minusImg [ relPath ] + ';"></span>' ) ;
157
160
// add vertical lines to other rows
158
161
$ ( 'span[class=lineno]' ) . not ( ':eq(0)' ) . append ( '<span class="fold"></span>' ) ;
159
162
// add toggle controls to lines with fold divs
@@ -164,7 +167,9 @@ function init_codefold() {
164
167
var start = $ ( this ) . attr ( 'data-start' ) ;
165
168
var end = $ ( this ) . attr ( 'data-end' ) ;
166
169
// replace normal fold span with controls for the first line of a foldable fragment
167
- $ ( this ) . find ( 'span[class=fold]:first' ) . replaceWith ( '<span class="fold" onclick="javascript:codefold_toggle(\'' + id + '\');" style="background-image:' + minusImg + ';"></span>' ) ;
170
+ $ ( this ) . find ( 'span[class=fold]:first' ) . replaceWith ( '<span class="fold" ' +
171
+ 'onclick="javascript:codefold_toggle(\'' + id + '\');" ' +
172
+ 'style="background-image:' + minusImg [ relPath ] + ';"></span>' ) ;
168
173
// append div for folded (closed) representation
169
174
$ ( this ) . after ( '<div id="foldclosed' + id + '" class="foldclosed" style="display:none;"></div>' ) ;
170
175
// extract the first line from the "open" section to represent closed content
@@ -176,7 +181,7 @@ function init_codefold() {
176
181
$ ( line ) . html ( $ ( line ) . html ( ) . replace ( new RegExp ( '\\s*' + start + '\\s*$' , 'g' ) , '' ) ) ;
177
182
}
178
183
// replace minus with plus symbol
179
- $ ( line ) . find ( 'span[class=fold]' ) . css ( 'background-image' , plusImg ) ;
184
+ $ ( line ) . find ( 'span[class=fold]' ) . css ( 'background-image' , plusImg [ relPath ] ) ;
180
185
// append ellipsis
181
186
$ ( line ) . append ( ' ' + start + '<a href="javascript:codefold_toggle(\'' + id + '\')">…</a>' + end ) ;
182
187
// insert constructed line into closed div
0 commit comments