Skip to content

Commit 51ed941

Browse files
add filterbar to long tables
1 parent dcc900f commit 51ed941

File tree

4 files changed

+309
-231
lines changed

4 files changed

+309
-231
lines changed

_static/css/custom.css

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
/* modified from https://github.com/readthedocs/sphinx_rtd_theme/issues/295#issuecomment-560895037 */
22

33
.wy-nav-content {
4-
max-width: 900px !important;
4+
max-width: 900px !important;
55
}
66

77
/* and fix wrap bug per https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html */
88
.wy-table-responsive table td {
9-
/* !important prevents the common CSS stylesheets from overriding
10-
this as on RTD they are loaded after this stylesheet */
11-
white-space: normal !important;
9+
/* !important prevents the common CSS stylesheets from overriding
10+
this as on RTD they are loaded after this stylesheet */
11+
white-space: normal !important;
1212
}
1313

1414
.wy-table-responsive {
15-
overflow: visible !important;
15+
overflow: visible !important;
16+
}
17+
18+
19+
.wrapper {
20+
position: relative;
21+
display: inline-block;
22+
width: 100%;
23+
height: 40px;
24+
}
25+
26+
.description {
27+
width: 95%;
28+
text-overflow: clip;
29+
display: -webkit-box;
30+
overflow: hidden;
31+
-webkit-line-clamp: 1;
32+
-webkit-box-orient: vertical;
33+
height: 40px;
34+
}
35+
36+
.btn {
37+
background-color: transparent; border-width: 0; outline-width: 0;
38+
font-size: 20px; color: #2f58df;
39+
position: absolute;
40+
right: 5%;
41+
cursor: pointer;
1642
}

_static/js/filter_table.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function filtertable(filterbar_id, table_name) {
2+
var input, filter, table, tr, td, i, txtValue, show;
3+
4+
input = document.getElementById(filterbar_id);
5+
filter = input.value.toUpperCase();
6+
table = document.getElementById(table_name);
7+
tr = table.getElementsByTagName("tr");
8+
9+
// For each row: loop through all columns and hides the row that
10+
// does not match the case-insensitive search query
11+
for (i = 0; i < tr.length; i++) {
12+
td = tr[i].getElementsByTagName("td")[0];
13+
show = "none";
14+
if (td) {
15+
for (j = 0; j < tr[i].getElementsByTagName("td").length; j++) {
16+
column = tr[i].getElementsByTagName("td")[j];
17+
txtValue = column.textContent || column.innerText;
18+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
19+
show = "";
20+
}
21+
}
22+
tr[i].style.display = show;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)