dit projekt
Loading...
Searching...
No Matches
dynsections.js
Go to the documentation of this file.
1/*
2 @licstart The following is the entire license notice for the JavaScript code in this file.
3
4 The MIT License (MIT)
5
6 Copyright (C) 1997-2020 by Dimitri van Heesch
7
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:
13
14 The above copyright notice and this permission notice shall be included in all copies or
15 substantial portions of the Software.
16
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.
22
23 @licend The above is the entire license notice for the JavaScript code in this file
24 */
25
26function toggleVisibility(linkObj) {
27 return dynsection.toggleVisibility(linkObj);
28}
29
30let dynsection = {
31 // helper function
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');
37 },
38
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');
47 summary.show();
48 $(linkObj).find('.arrowhead').addClass('closed').removeClass('opened');
49 } else {
50 content.slideDown('fast');
51 summary.hide();
52 $(linkObj).find('.arrowhead').removeClass('closed').addClass('opened');
53 }
54 return false;
55 },
56
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));
62 if (l<level+1) {
63 i.find('.folder-icon').addClass('open');
64 a.find('.arrowhead').removeClass('closed').addClass('opened');
65 $(this).show();
66 } else if (l==level+1) {
67 a.find('.arrowhead').removeClass('opened').addClass('closed');
68 i.find('.folder-icon').removeClass('open');
69 $(this).show();
70 } else {
71 $(this).hide();
72 }
73 });
74 this.updateStripes();
75 },
76
77 toggleFolder : function(id) {
78 // the clicked row
79 const currentRow = $('#row_'+id);
80
81 // all rows after the clicked row
82 const rows = currentRow.nextAll("tr");
83
84 const re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
85
86 // only match elements AFTER this one (can't hide elements before)
87 const childRows = rows.filter(function() { return this.id.match(re); });
88
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
106 }
107 this.updateStripes();
108 },
109
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) {
114 rows.hide();
115 $(header).find('.arrowhead').addClass('closed').removeClass('opened');
116 } else {
117 rows.show();
118 $(header).find('.arrowhead').removeClass('closed').addClass('opened');
119 }
120 },
121
122};
123
124let codefold = {
125 opened : true,
126
127 // toggle all folding blocks
128 toggle_all : function() {
129 if (this.opened) {
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');
134 } else {
135 $('#fold_all').addClass('minus').removeClass('plus');
136 $('div[id^=foldopen]').show();
137 $('div[id^=foldclosed]').hide();
138 }
139 this.opened=!this.opened;
140 },
141
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');
147 },
148
149 init : function() {
150 $('span[class=lineno]').css({
151 'padding-right':'4px',
152 'margin-right':'2px',
153 'display':'inline-block',
154 'width':'54px',
155 'background':'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%'
156 });
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');
178 if (start) {
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'),''));
181 }
182 // replace minus with plus symbol
183 $(line).find('span[class=fold]').addClass('plus').removeClass('minus');
184 // append ellipsis
185 $(line).append(' '+start+'<a href="javascript:codefold.toggle(\''+id+'\')">&#8230;</a>'+end);
186 // insert constructed line into closed div
187 $('#foldclosed'+id).html(line);
188 });
189 },
190};
191/* @license-end */
192$(function() {
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 });
197 });
198});