Skip to content

Commit f22486e

Browse files
authored
Merge pull request #214 from ELIXIR-Belgium/adaptive-datable
Only show pagination and search in datatables when relevant
2 parents bbaee32 + 96e9dbb commit f22486e

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

_includes/head.html

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,28 @@
6363
<script type="text/javascript" charset="utf8" src="{{ 'assets/js/jquery.dataTables.min.js' | relative_url }}"></script>
6464
<script type="text/javascript" charset="utf8" src="{{ 'assets/js/dataTables.bootstrap5.min.js' | relative_url }}"></script>
6565
<script type="text/javascript">
66-
$.fn.DataTable.ext.pager.numbers_length = 5;
6766
$(document).ready(function () {
68-
$('div.datatable-begin').nextUntil('div.datatable-end', 'table').addClass('display');
69-
$('table.display').DataTable({
70-
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
71-
stateSave: true,
72-
searching: true,
73-
language: {
74-
searchPlaceholder: "Type here..."
75-
}
76-
});
67+
$('table.display').each(function() {
68+
$(this).DataTable({
69+
lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
70+
stateSave: true,
71+
searching: true,
72+
info: true,
73+
pageLength: 10,
74+
language: {
75+
searchPlaceholder: "Type here..."
76+
},
77+
"fnDrawCallback": function ( oSettings ){
78+
var tableId = oSettings.nTable.id;
79+
if(oSettings.fnRecordsTotal() < 10){
80+
$('#'+tableId+'_length').hide();
81+
$('#'+tableId+'_paginate').hide();
82+
$('#'+tableId+'_filter').hide();
83+
$('#'+tableId+'_info').hide();
84+
}
85+
}
86+
});
87+
})
7788
});
7889
</script>
7990
{%- endif %}

pages/documentation/resource_table.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Tools and resources table
33
page_id: tools_and_resources_table
4+
datatable: true
45
---
56

67
One of the themes key features is the support for a central tool and resource table. This means that tools that are mentioned at multiple places on the website, can be described centrally, and these descriptions/metadata fields can be used to automatically populate a tools and resources table at the bottom of the page.
@@ -88,3 +89,18 @@ Tools and resources specifically mentioned in the text of the pages should be pr
8889

8990
{% include callout.html type="important" content="Don't forget to add the `\"` double quotes around the tool_id and make sure to use the exact tool_id as described in the yaml file." %}
9091

92+
## Listing all resources
93+
94+
By default, the table at the bottom of the page will appear when tools are mentioned in the text/tagged with the correct page_id as seen at the bottom of this page under the "Tools and resources on this page" heading. To list manually all tools and resources that are described in your website, use following snippet:
95+
96+
```
97+
{% raw %}
98+
{% include resource-table-all.html %}
99+
{% endraw %}
100+
```
101+
102+
103+
{% include resource-table-all.html %}
104+
105+
106+

pages/example_pages/all_tools_and_resources.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)