@@ -7,51 +7,42 @@ var tables = document.querySelectorAll("table.configuration-reference");
77var typingTimer ;
88
99if ( tables ) {
10- var idx = 0 ;
1110 for ( var table of tables ) {
1211 var caption = table . previousElementSibling ;
1312 if ( table . classList . contains ( 'searchable' ) ) { // activate search engine only when needed
14- var input = document . createElement ( "input" ) ;
15- input . setAttribute ( "type" , "search" ) ;
16- input . setAttribute ( "placeholder" , "FILTER CONFIGURATION" ) ;
17- input . id = "config-search-" + ( idx ++ ) ;
18- caption . children . item ( 0 ) . appendChild ( input ) ;
13+ var input = caption . firstElementChild . lastElementChild ;
1914 input . addEventListener ( "keyup" , initiateSearch ) ;
2015 input . addEventListener ( "input" , initiateSearch ) ;
21- var descriptions = table . querySelectorAll ( ".description" ) ;
22- if ( descriptions ) {
23- var heights = new Array ( descriptions . length ) ;
24- var h = 0 ;
25- for ( description of descriptions ) {
26- heights [ h ++ ] = description . offsetHeight ;
27- }
28- var shadowTable = table . cloneNode ( true ) ;
29- var shadowDescriptions = shadowTable . querySelectorAll ( ".description" ) ;
30- h = 0 ;
31- for ( shadowDescription of shadowDescriptions ) {
32- makeCollapsible ( shadowDescription , heights [ h ++ ] ) ;
33- }
34- table . parentNode . replaceChild ( shadowTable , table ) ;
35- table = shadowTable ;
36- }
16+ input . attributes . removeNamedItem ( 'disabled' ) ;
3717 inputs [ input . id ] = { "table" : table } ;
3818 }
3919
40- var rowIdx = 0 ;
41- for ( var row of table . querySelectorAll ( "table.configuration-reference > tbody > tr" ) ) {
42- var heads = row . querySelectorAll ( "table.configuration-reference > tbody > tr > th" ) ;
43- if ( ! heads || heads . length == 0 ) {
44- // mark even rows
45- if ( ++ rowIdx % 2 ) {
46- row . classList . add ( "odd" ) ;
47- } else {
48- row . classList . remove ( "odd" ) ;
49- }
50- } else {
51- // reset count at each section
52- rowIdx = 0 ;
20+ const collapsibleRows = table . querySelectorAll ( 'tr.row-collapsible' ) ;
21+ if ( collapsibleRows ) {
22+ for ( let row of collapsibleRows ) {
23+ const td = row . firstElementChild ;
24+ const decoration = td . firstElementChild . lastElementChild . firstElementChild ;
25+ const iconDecoration = decoration . children . item ( 0 ) ;
26+ const collapsibleSpan = decoration . children . item ( 1 ) ;
27+ const descDiv = td . firstElementChild . children . item ( 1 ) ;
28+ const collapsibleHandler = makeCollapsibleHandler ( descDiv , td , row , collapsibleSpan , iconDecoration ) ;
29+ row . addEventListener ( 'click' , collapsibleHandler ) ;
5330 }
5431 }
32+
33+ // render hidden rows asynchronously
34+ setTimeout ( ( ) => renderHiddenRows ( ) ) ;
35+ }
36+ }
37+
38+ function renderHiddenRows ( ) {
39+ // some rows are initially hidden so that user can hit the ground running
40+ // we render them at this very moment, but when user can already use search function
41+ const hiddenRows = document . querySelectorAll ( 'table.configuration-reference-all-rows.tableblock > tbody > tr.row-hidden' ) ;
42+ if ( hiddenRows ) {
43+ for ( row of hiddenRows ) {
44+ row . classList . remove ( 'row-hidden' ) ;
45+ }
5546 }
5647}
5748
@@ -164,8 +155,8 @@ function reinstallClickHandlers(table){
164155 var td = getAncestor ( descDiv , "td" ) ;
165156 var row = td . parentNode ;
166157 var decoration = content . lastElementChild ;
167- var iconDecoration = decoration . children . item ( 0 ) ;
168- var collapsibleSpan = decoration . children . item ( 1 ) ;
158+ var iconDecoration = decoration . firstElementChild . children . item ( 0 ) ;
159+ var collapsibleSpan = decoration . firstElementChild . children . item ( 1 ) ;
169160 var collapsibleHandler = makeCollapsibleHandler ( descDiv , td , row ,
170161 collapsibleSpan ,
171162 iconDecoration ) ;
@@ -178,6 +169,12 @@ function reinstallClickHandlers(table){
178169function swapShadowTable ( input ) {
179170 var currentTable = inputs [ input . id ] . table ;
180171 var shadowTable = inputs [ input . id ] . shadowTable ;
172+
173+ // makes sure hidden rows are always displayed when search term is defined
174+ if ( shadowTable . classList . contains ( 'configuration-reference-all-rows' ) ) {
175+ shadowTable . classList . remove ( 'configuration-reference-all-rows' ) ;
176+ }
177+
181178 currentTable . parentNode . replaceChild ( shadowTable , currentTable ) ;
182179 inputs [ input . id ] . table = shadowTable ;
183180 inputs [ input . id ] . shadowTable = currentTable ;
@@ -254,41 +251,9 @@ function getAncestor(element, name){
254251 return null ;
255252}
256253
257- /*
258- * COLLAPSIBLE DESCRIPTION
259- */
260- function makeCollapsible ( descDiv , descHeightLong ) {
261- if ( descHeightLong > 25 ) {
262- var td = getAncestor ( descDiv , "td" ) ;
263- var row = td . parentNode ;
264- var iconDecoration = document . createElement ( "i" ) ;
265- descDiv . classList . add ( 'description-collapsed' ) ;
266- iconDecoration . classList . add ( 'fa' , 'fa-chevron-down' ) ;
267-
268- var descDecoration = document . createElement ( "div" ) ;
269- descDecoration . classList . add ( 'description-decoration' ) ;
270- descDecoration . appendChild ( iconDecoration ) ;
271-
272- var collapsibleSpan = document . createElement ( "span" ) ;
273- collapsibleSpan . appendChild ( document . createTextNode ( "Show more" ) ) ;
274- descDecoration . appendChild ( collapsibleSpan ) ;
275-
276- var collapsibleHandler = makeCollapsibleHandler ( descDiv , td , row ,
277- collapsibleSpan ,
278- iconDecoration ) ;
279-
280- var parent = descDiv . parentNode ;
281-
282- parent . appendChild ( descDecoration ) ;
283- row . classList . add ( "row-collapsible" , "row-collapsed" ) ;
284- row . addEventListener ( "click" , collapsibleHandler ) ;
285- }
286-
287- } ;
288-
289254function makeCollapsibleHandler ( descDiv , td , row ,
290- collapsibleSpan ,
291- iconDecoration ) {
255+ collapsibleSpan ,
256+ iconDecoration ) {
292257
293258 return function ( event ) {
294259 var target = event . target ;
0 commit comments