|
22 | 22 |
|
23 | 23 | @licend The above is the entire license notice for the JavaScript code in this file
|
24 | 24 | */
|
25 |
| - |
26 |
| -function toggleVisibility(linkObj) { |
27 |
| - return dynsection.toggleVisibility(linkObj); |
| 25 | +function toggleVisibility(linkObj) |
| 26 | +{ |
| 27 | + var base = $(linkObj).attr('id'); |
| 28 | + var summary = $('#'+base+'-summary'); |
| 29 | + var content = $('#'+base+'-content'); |
| 30 | + var trigger = $('#'+base+'-trigger'); |
| 31 | + var src=$(trigger).attr('src'); |
| 32 | + if (content.is(':visible')===true) { |
| 33 | + content.hide(); |
| 34 | + summary.show(); |
| 35 | + $(linkObj).addClass('closed').removeClass('opened'); |
| 36 | + $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); |
| 37 | + } else { |
| 38 | + content.show(); |
| 39 | + summary.hide(); |
| 40 | + $(linkObj).removeClass('closed').addClass('opened'); |
| 41 | + $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); |
| 42 | + } |
| 43 | + return false; |
28 | 44 | }
|
29 | 45 |
|
30 |
| -let dynsection = { |
31 |
| - |
32 |
| - // helper function |
33 |
| - updateStripes : function() { |
34 |
| - $('table.directory tr'). |
35 |
| - removeClass('even').filter(':visible:even').addClass('even'); |
36 |
| - $('table.directory tr'). |
37 |
| - removeClass('odd').filter(':visible:odd').addClass('odd'); |
38 |
| - }, |
39 |
| - |
40 |
| - toggleVisibility : function(linkObj) { |
41 |
| - const base = $(linkObj).attr('id'); |
42 |
| - const summary = $('#'+base+'-summary'); |
43 |
| - const content = $('#'+base+'-content'); |
44 |
| - const trigger = $('#'+base+'-trigger'); |
45 |
| - const src=$(trigger).attr('src'); |
46 |
| - if (content.is(':visible')===true) { |
47 |
| - content.hide(); |
48 |
| - summary.show(); |
49 |
| - $(linkObj).addClass('closed').removeClass('opened'); |
50 |
| - $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); |
51 |
| - } else { |
52 |
| - content.show(); |
53 |
| - summary.hide(); |
54 |
| - $(linkObj).removeClass('closed').addClass('opened'); |
55 |
| - $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); |
56 |
| - } |
57 |
| - return false; |
58 |
| - }, |
59 |
| - |
60 |
| - toggleLevel : function(level) { |
61 |
| - $('table.directory tr').each(function() { |
62 |
| - const l = this.id.split('_').length-1; |
63 |
| - const i = $('#img'+this.id.substring(3)); |
64 |
| - const a = $('#arr'+this.id.substring(3)); |
65 |
| - if (l<level+1) { |
66 |
| - i.removeClass('iconfopen iconfclosed').addClass('iconfopen'); |
67 |
| - a.html('▼'); |
68 |
| - $(this).show(); |
69 |
| - } else if (l==level+1) { |
70 |
| - i.removeClass('iconfclosed iconfopen').addClass('iconfclosed'); |
71 |
| - a.html('►'); |
72 |
| - $(this).show(); |
73 |
| - } else { |
74 |
| - $(this).hide(); |
75 |
| - } |
76 |
| - }); |
77 |
| - this.updateStripes(); |
78 |
| - }, |
79 |
| - |
80 |
| - toggleFolder : function(id) { |
81 |
| - // the clicked row |
82 |
| - const currentRow = $('#row_'+id); |
83 |
| - |
84 |
| - // all rows after the clicked row |
85 |
| - const rows = currentRow.nextAll("tr"); |
86 |
| - |
87 |
| - const re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub |
88 |
| - |
89 |
| - // only match elements AFTER this one (can't hide elements before) |
90 |
| - const childRows = rows.filter(function() { return this.id.match(re); }); |
91 |
| - |
92 |
| - // first row is visible we are HIDING |
93 |
| - if (childRows.filter(':first').is(':visible')===true) { |
94 |
| - // replace down arrow by right arrow for current row |
95 |
| - const currentRowSpans = currentRow.find("span"); |
96 |
| - currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
97 |
| - currentRowSpans.filter(".arrow").html('►'); |
98 |
| - rows.filter("[id^=row_"+id+"]").hide(); // hide all children |
99 |
| - } else { // we are SHOWING |
100 |
| - // replace right arrow by down arrow for current row |
101 |
| - const currentRowSpans = currentRow.find("span"); |
102 |
| - currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen"); |
103 |
| - currentRowSpans.filter(".arrow").html('▼'); |
104 |
| - // replace down arrows by right arrows for child rows |
105 |
| - const childRowsSpans = childRows.find("span"); |
106 |
| - childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
107 |
| - childRowsSpans.filter(".arrow").html('►'); |
108 |
| - childRows.show(); //show all children |
109 |
| - } |
110 |
| - this.updateStripes(); |
111 |
| - }, |
| 46 | +function updateStripes() |
| 47 | +{ |
| 48 | + $('table.directory tr'). |
| 49 | + removeClass('even').filter(':visible:even').addClass('even'); |
| 50 | +} |
112 | 51 |
|
113 |
| - toggleInherit : function(id) { |
114 |
| - const rows = $('tr.inherit.'+id); |
115 |
| - const img = $('tr.inherit_header.'+id+' img'); |
116 |
| - const src = $(img).attr('src'); |
117 |
| - if (rows.filter(':first').is(':visible')===true) { |
118 |
| - rows.css('display','none'); |
119 |
| - $(img).attr('src',src.substring(0,src.length-8)+'closed.png'); |
| 52 | +function toggleLevel(level) |
| 53 | +{ |
| 54 | + $('table.directory tr').each(function() { |
| 55 | + var l = this.id.split('_').length-1; |
| 56 | + var i = $('#img'+this.id.substring(3)); |
| 57 | + var a = $('#arr'+this.id.substring(3)); |
| 58 | + if (l<level+1) { |
| 59 | + i.removeClass('iconfopen iconfclosed').addClass('iconfopen'); |
| 60 | + a.html('▼'); |
| 61 | + $(this).show(); |
| 62 | + } else if (l==level+1) { |
| 63 | + i.removeClass('iconfclosed iconfopen').addClass('iconfclosed'); |
| 64 | + a.html('►'); |
| 65 | + $(this).show(); |
120 | 66 | } else {
|
121 |
| - rows.css('display','table-row'); // using show() causes jump in firefox |
122 |
| - $(img).attr('src',src.substring(0,src.length-10)+'open.png'); |
| 67 | + $(this).hide(); |
123 | 68 | }
|
124 |
| - }, |
125 |
| -}; |
126 |
| - |
127 |
| -let codefold = { |
128 |
| - opened : true, |
129 |
| - |
130 |
| - // in case HTML_COLORSTYLE is LIGHT or DARK the vars will be replaced, so we write them out explicitly and use double quotes |
131 |
| - plusImg: [ "var(--fold-plus-image)", "var(--fold-plus-image-relpath)" ], |
132 |
| - minusImg: [ "var(--fold-minus-image)", "var(--fold-minus-image-relpath)" ], |
| 69 | + }); |
| 70 | + updateStripes(); |
| 71 | +} |
133 | 72 |
|
134 |
| - // toggle all folding blocks |
135 |
| - toggle_all : function(relPath) { |
136 |
| - if (this.opened) { |
137 |
| - $('#fold_all').css('background-image',this.plusImg[relPath]); |
138 |
| - $('div[id^=foldopen]').hide(); |
139 |
| - $('div[id^=foldclosed]').show(); |
140 |
| - } else { |
141 |
| - $('#fold_all').css('background-image',this.minusImg[relPath]); |
142 |
| - $('div[id^=foldopen]').show(); |
143 |
| - $('div[id^=foldclosed]').hide(); |
144 |
| - } |
145 |
| - this.opened=!this.opened; |
146 |
| - }, |
| 73 | +function toggleFolder(id) |
| 74 | +{ |
| 75 | + // the clicked row |
| 76 | + var currentRow = $('#row_'+id); |
| 77 | + |
| 78 | + // all rows after the clicked row |
| 79 | + var rows = currentRow.nextAll("tr"); |
| 80 | + |
| 81 | + var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub |
| 82 | + |
| 83 | + // only match elements AFTER this one (can't hide elements before) |
| 84 | + var childRows = rows.filter(function() { return this.id.match(re); }); |
| 85 | + |
| 86 | + // first row is visible we are HIDING |
| 87 | + if (childRows.filter(':first').is(':visible')===true) { |
| 88 | + // replace down arrow by right arrow for current row |
| 89 | + var currentRowSpans = currentRow.find("span"); |
| 90 | + currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
| 91 | + currentRowSpans.filter(".arrow").html('►'); |
| 92 | + rows.filter("[id^=row_"+id+"]").hide(); // hide all children |
| 93 | + } else { // we are SHOWING |
| 94 | + // replace right arrow by down arrow for current row |
| 95 | + var currentRowSpans = currentRow.find("span"); |
| 96 | + currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen"); |
| 97 | + currentRowSpans.filter(".arrow").html('▼'); |
| 98 | + // replace down arrows by right arrows for child rows |
| 99 | + var childRowsSpans = childRows.find("span"); |
| 100 | + childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
| 101 | + childRowsSpans.filter(".arrow").html('►'); |
| 102 | + childRows.show(); //show all children |
| 103 | + } |
| 104 | + updateStripes(); |
| 105 | +} |
147 | 106 |
|
148 |
| - // toggle single folding block |
149 |
| - toggle : function(id) { |
150 |
| - $('#foldopen'+id).toggle(); |
151 |
| - $('#foldclosed'+id).toggle(); |
152 |
| - }, |
153 | 107 |
|
154 |
| - init : function(relPath) { |
155 |
| - $('span[class=lineno]').css({ |
156 |
| - 'padding-right':'4px', |
157 |
| - 'margin-right':'2px', |
158 |
| - 'display':'inline-block', |
159 |
| - 'width':'54px', |
160 |
| - 'background':'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%' |
161 |
| - }); |
162 |
| - // add global toggle to first line |
163 |
| - $('span[class=lineno]:first').append('<span class="fold" id="fold_all" '+ |
164 |
| - 'onclick="javascript:codefold.toggle_all('+relPath+');" '+ |
165 |
| - 'style="background-image:'+this.minusImg[relPath]+';"></span>'); |
166 |
| - // add vertical lines to other rows |
167 |
| - $('span[class=lineno]').not(':eq(0)').append('<span class="fold"></span>'); |
168 |
| - // add toggle controls to lines with fold divs |
169 |
| - $('div[class=foldopen]').each(function() { |
170 |
| - // extract specific id to use |
171 |
| - const id = $(this).attr('id').replace('foldopen',''); |
172 |
| - // extract start and end foldable fragment attributes |
173 |
| - const start = $(this).attr('data-start'); |
174 |
| - const end = $(this).attr('data-end'); |
175 |
| - // replace normal fold span with controls for the first line of a foldable fragment |
176 |
| - $(this).find('span[class=fold]:first').replaceWith('<span class="fold" '+ |
177 |
| - 'onclick="javascript:codefold.toggle(\''+id+'\');" '+ |
178 |
| - 'style="background-image:'+codefold.minusImg[relPath]+';"></span>'); |
179 |
| - // append div for folded (closed) representation |
180 |
| - $(this).after('<div id="foldclosed'+id+'" class="foldclosed" style="display:none;"></div>'); |
181 |
| - // extract the first line from the "open" section to represent closed content |
182 |
| - const line = $(this).children().first().clone(); |
183 |
| - // remove any glow that might still be active on the original line |
184 |
| - $(line).removeClass('glow'); |
185 |
| - if (start) { |
186 |
| - // if line already ends with a start marker (e.g. trailing {), remove it |
187 |
| - $(line).html($(line).html().replace(new RegExp('\\s*'+start+'\\s*$','g'),'')); |
188 |
| - } |
189 |
| - // replace minus with plus symbol |
190 |
| - $(line).find('span[class=fold]').css('background-image',codefold.plusImg[relPath]); |
191 |
| - // append ellipsis |
192 |
| - $(line).append(' '+start+'<a href="javascript:codefold.toggle(\''+id+'\')">…</a>'+end); |
193 |
| - // insert constructed line into closed div |
194 |
| - $('#foldclosed'+id).html(line); |
195 |
| - }); |
196 |
| - }, |
197 |
| -}; |
| 108 | +function toggleInherit(id) |
| 109 | +{ |
| 110 | + var rows = $('tr.inherit.'+id); |
| 111 | + var img = $('tr.inherit_header.'+id+' img'); |
| 112 | + var src = $(img).attr('src'); |
| 113 | + if (rows.filter(':first').is(':visible')===true) { |
| 114 | + rows.css('display','none'); |
| 115 | + $(img).attr('src',src.substring(0,src.length-8)+'closed.png'); |
| 116 | + } else { |
| 117 | + rows.css('display','table-row'); // using show() causes jump in firefox |
| 118 | + $(img).attr('src',src.substring(0,src.length-10)+'open.png'); |
| 119 | + } |
| 120 | +} |
198 | 121 | /* @license-end */
|
0 commit comments