Skip to content

Commit de8b184

Browse files
committed
For #2339
1 parent d9f4621 commit de8b184

3 files changed

Lines changed: 306 additions & 154 deletions

File tree

scripts/go-cam-records-template.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@
3333
"paging": false,
3434
"info": false,
3535
"ordering": true,
36-
"searching": true
36+
"searching": true,
37+
// scrollX gives a horizontal scrollbar for wide tables (e.g.
38+
// the protein-complex page); scrollY bounds the body to the
39+
// viewport so that scrollbar stays on screen instead of below
40+
// a long table, and scrollCollapse lets short tables (most
41+
// drilldown pages) shrink to fit instead of padding to 70vh.
42+
"scrollX": true,
43+
"scrollY": "70vh",
44+
"scrollCollapse": true
3745
});
3846
});
3947
</script>

scripts/go-cam-stats-template.html

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,42 @@
2323
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"/>
2424
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" crossorigin="anonymous"/>
2525

26+
<style>
27+
/* Keep wide / tall stats tables (e.g. group- and curator-stats, which
28+
gain one column per group/curator) inside a viewport-bounded scroll
29+
box. Without this the table's own horizontal scrollbar sits at the
30+
bottom of the table — below the fold on a many-row page — so users
31+
scroll sideways with no scrollbar in view. overflow:auto here keeps
32+
BOTH scrollbars on screen. */
33+
.gostats-scroll { max-height: 75vh; overflow: auto; }
34+
/* Opaque stripes so the sticky cells below can inherit a solid
35+
background and not let scrolled-under content bleed through. */
36+
.gostats-scroll table tbody tr { background-color: #fff; }
37+
.gostats-scroll table tbody tr:nth-of-type(odd) { background-color: #f2f2f2; }
38+
/* Freeze the header row and the leading Statistic column on scroll. */
39+
.gostats-scroll table thead th { position: sticky; top: 0; z-index: 2; background-color: #fff; }
40+
.gostats-scroll table tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; background-color: inherit; }
41+
/* Only the Statistic header (first cell of the first header row) is the
42+
frozen corner; the per-entity Total/Unique subheader cells scroll. */
43+
.gostats-scroll table thead tr:first-child th:first-child { left: 0; z-index: 3; }
44+
/* Two-level (grouped) header: the second row sticks just below the
45+
first. 2.1rem ≈ one table-sm header row; if header text wraps this
46+
can drift, but the bounded scroll box still keeps both bars on screen. */
47+
.gostats-grouped table thead tr:nth-child(2) th { top: 2.1rem; }
48+
/* Entity (group/curator) column banding: alternate entities (ent-b)
49+
get a warm-gray tint. Row striping is preserved by combining both
50+
axes into four solid colors; cells stay opaque so the sticky header
51+
and first column keep covering scrolled-under content. The neutral
52+
ent-a columns match the default white/#f2f2f2 row stripes. */
53+
.gostats-grouped tbody tr td.ent-a { background-color: #ffffff; }
54+
.gostats-grouped tbody tr:nth-of-type(odd) td.ent-a { background-color: #f2f2f2; }
55+
.gostats-grouped tbody tr td.ent-b { background-color: #efece8; }
56+
.gostats-grouped tbody tr:nth-of-type(odd) td.ent-b { background-color: #e4ded6; }
57+
.gostats-grouped table thead th.ent-b { background-color: #efece8; }
58+
/* Visible cell borders (Bootstrap's table-bordered border is very faint). */
59+
.gostats-scroll table th, .gostats-scroll table td { border: 1px solid #b8c2cc; }
60+
</style>
61+
2662
<title>{{ title }}</title>
2763

2864
<script>
@@ -36,28 +72,45 @@
3672
<div class="container-fluid">
3773
<h2>{{ title }}</h2>
3874
Generated on {{ date }}<br/>
75+
{{#note}}<p class="text-muted mt-2 mb-0"><em>{{ note }}</em></p>{{/note}}
3976
<nav class="mt-2 mb-3">
4077
{{ #links }}
4178
<a href="{{ href }}" class="btn btn-outline-primary btn-sm">{{ label }}</a>
4279
{{ /links }}
4380
</nav>
44-
<div class="table-responsive">
81+
<div class="table-responsive gostats-scroll{{#grouped}} gostats-grouped{{/grouped}}">
4582
<table id="sourcestable" class="table table-sm table-striped rud-compact-table table-bordered table-hover">
4683
<thead>
84+
{{#grouped}}
85+
<tr>
86+
<th scope="col" rowspan="2">Statistic</th>
87+
{{ #header }}
88+
{{#href}}<th scope="col" colspan="{{ colspan }}" class="text-center {{ cls }}"><a href="{{ href }}">{{ id }}</a></th>{{/href}}
89+
{{^href}}<th scope="col" colspan="{{ colspan }}" class="text-center {{ cls }}">{{ id }}</th>{{/href}}
90+
{{ /header }}
91+
</tr>
92+
<tr>
93+
{{ #subheader }}
94+
<th scope="col" class="{{ cls }}">{{ label }}</th>
95+
{{ /subheader }}
96+
</tr>
97+
{{/grouped}}
98+
{{^grouped}}
4799
<tr>
48100
<th scope="col">Statistic</th>
49101
{{ #header }}
50102
{{#href}}<th scope="col"><a href="{{ href }}">{{ id }}</a></th>{{/href}}
51103
{{^href}}<th scope="col">{{ id }}</th>{{/href}}
52104
{{ /header }}
53105
</tr>
106+
{{/grouped}}
54107
</thead>
55108
<tbody>
56109
{{ #rows }}
57110
<tr>
58111
<th scope="row" style="white-space: nowrap;">{{ field_display }}</th>
59112
{{ #values }}
60-
<td>{{#href}}<a href="{{ href }}">{{ value }}</a>{{/href}}{{^href}}{{ value }}{{/href}}</td>
113+
<td class="{{ cls }}">{{#href}}<a href="{{ href }}">{{ value }}</a>{{/href}}{{^href}}{{ value }}{{/href}}</td>
61114
{{ /values }}
62115
</tr>
63116
{{ /rows }}

0 commit comments

Comments
 (0)