2 @licstart The following is the entire license notice for the JavaScript code in this file.
6 Copyright (C) 1997-2020 by Dimitri van Heesch
8 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9 and associated documentation files (the "Software"), to deal in the Software without restriction,
10 including without limitation the rights to use, copy, modify, merge, publish, distribute,
11 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in all copies or
15 substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 @licend The above is the entire license notice for the JavaScript code in this file
26function toggleVisibility(linkObj) {
27 return dynsection.toggleVisibility(linkObj);
32 updateStripes : function() {
33 $('table.directory tr').
34 removeClass('even').filter(':visible:even').addClass('even');
35 $('table.directory tr').
36 removeClass('odd').filter(':visible:odd').addClass('odd');
39 toggleVisibility : function(linkObj) {
40 const base = $(linkObj).attr('id');
41 const summary = $('#'+base+'-summary');
42 const content = $('#'+base+'-content');
43 const trigger = $('#'+base+'-trigger');
44 const src=$(trigger).attr('src');
45 if (content.is(':visible')===true) {
46 content.slideUp('fast');
48 $(linkObj).find('.arrowhead').addClass('closed').removeClass('opened');
50 content.slideDown('fast');
52 $(linkObj).find('.arrowhead').removeClass('closed').addClass('opened');
57 toggleLevel : function(level) {
58 $('table.directory tr').each(function() {
59 const l = this.id.split('_').length-1;
60 const i = $('#img'+this.id.substring(3));
61 const a = $('#arr'+this.id.substring(3));
63 i.find('.folder-icon').addClass('open');
64 a.find('.arrowhead').removeClass('closed').addClass('opened');
66 } else if (l==level+1) {
67 a.find('.arrowhead').removeClass('opened').addClass('closed');
68 i.find('.folder-icon').removeClass('open');
77 toggleFolder : function(id) {
79 const currentRow = $('#row_'+id);
81 // all rows after the clicked row
82 const rows = currentRow.nextAll("tr");
84 const re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
86 // only match elements AFTER this one (can't hide elements before)
87 const childRows = rows.filter(function() { return this.id.match(re); });
89 // first row is visible we are HIDING
90 if (childRows.filter(':first').is(':visible')===true) {
91 // replace down arrow by right arrow for current row
92 const currentRowSpans = currentRow.find("span");
93 currentRowSpans.filter(".iconfolder").find('.folder-icon').removeClass("open");
94 currentRowSpans.filter(".opened").removeClass("opened").addClass("closed");
95 rows.filter("[id^=row_"+id+"]").hide(); // hide all children
96 } else { // we are SHOWING
97 // replace right arrow by down arrow for current row
98 const currentRowSpans = currentRow.find("span");
99 currentRowSpans.filter(".iconfolder").find('.folder-icon').addClass("open");
100 currentRowSpans.filter(".closed").removeClass("closed").addClass("opened");
101 // replace down arrows by right arrows for child rows
102 const childRowsSpans = childRows.find("span");
103 childRowsSpans.filter(".iconfolder").find('.folder-icon').removeClass("open");
104 childRowsSpans.filter(".opened").removeClass("opened").addClass("closed");
105 childRows.show(); //show all children
107 this.updateStripes();
110 toggleInherit : function(id) {
111 let rows = $('tr.inherit.'+id);
112 let header = $('tr.inherit_header.'+id);
113 if (rows.filter(':first').is(':visible')===true) {
115 $(header).find('.arrowhead').addClass('closed').removeClass('opened');
118 $(header).find('.arrowhead').removeClass('closed').addClass('opened');
127 // toggle all folding blocks
128 toggle_all : function() {
130 $('#fold_all').addClass('plus').removeClass('minus');
131 $('div[id^=foldopen]').hide();
132 $('div[id^=foldclosed]').show();
133 $('div[id^=foldclosed] span.fold').removeClass('minus').addClass('plus');
135 $('#fold_all').addClass('minus').removeClass('plus');
136 $('div[id^=foldopen]').show();
137 $('div[id^=foldclosed]').hide();
139 this.opened=!this.opened;
142 // toggle single folding block
143 toggle : function(id) {
144 $('#foldopen'+id).toggle();
145 $('#foldclosed'+id).toggle();
146 $('#foldopen'+id).next().find('span.fold').addClass('plus').removeClass('minus');
150 $('span[class=lineno]').css({
151 'padding-right':'4px',
152 'margin-right':'2px',
153 'display':'inline-block',
155 'background':'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%'
157 // add global toggle to first line
158 $('span[class=lineno]:first').append('<span class="fold minus" id="fold_all" '+
159 'onclick="javascript:codefold.toggle_all();"></span>');
160 // add vertical lines to other rows
161 $('span[class=lineno]').not(':eq(0)').append('<span class="fold"></span>');
162 // add toggle controls to lines with fold divs
163 $('div[class=foldopen]').each(function() {
164 // extract specific id to use
165 const id = $(this).attr('id').replace('foldopen','');
166 // extract start and end foldable fragment attributes
167 const start = $(this).attr('data-start');
168 const end = $(this).attr('data-end');
169 // replace normal fold span with controls for the first line of a foldable fragment
170 $(this).find('span[class=fold]:first').replaceWith('<span class="fold minus" '+
171 'onclick="javascript:codefold.toggle(\''+id+'\');"></span>');
172 // append div for folded (closed) representation
173 $(this).after('<div id="foldclosed'+id+'" class="foldclosed" style="display:none;"></div>');
174 // extract the first line from the "open" section to represent closed content
175 const line = $(this).children().first().clone();
176 // remove any glow that might still be active on the original line
177 $(line).removeClass('glow');
179 // if line already ends with a start marker (e.g. trailing {), remove it
180 $(line).html($(line).html().replace(new RegExp('\\s*'+start+'\\s*$','g'),''));
182 // replace minus with plus symbol
183 $(line).find('span[class=fold]').addClass('plus').removeClass('minus');
185 $(line).append(' '+start+'<a href="javascript:codefold.toggle(\''+id+'\')">…</a>'+end);
186 // insert constructed line into closed div
187 $('#foldclosed'+id).html(line);
193 $('.code,.codeRef').each(function() {
194 $(this).data('powertip',$('#a'+$(this).attr('href').replace(/.*\//,'').replace(/[^a-z_A-Z0-9]/g,'_')).html());
195 $.fn.powerTip.smartPlacementLists.s = [ 's', 'n', 'ne', 'se' ];
196 $(this).powerTip({ placement: 's', smartPlacement: true, mouseOnToPopup: true });