Skip to content

Commit

Permalink
Merge pull request #214 from ELIXIR-Belgium/adaptive-datable
Browse files Browse the repository at this point in the history
Only  show pagination and search in datatables when relevant
  • Loading branch information
bedroesb authored Nov 15, 2023
2 parents bbaee32 + 96e9dbb commit f22486e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
31 changes: 21 additions & 10 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,28 @@
<script type="text/javascript" charset="utf8" src="{{ 'assets/js/jquery.dataTables.min.js' | relative_url }}"></script>
<script type="text/javascript" charset="utf8" src="{{ 'assets/js/dataTables.bootstrap5.min.js' | relative_url }}"></script>
<script type="text/javascript">
$.fn.DataTable.ext.pager.numbers_length = 5;
$(document).ready(function () {
$('div.datatable-begin').nextUntil('div.datatable-end', 'table').addClass('display');
$('table.display').DataTable({
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
stateSave: true,
searching: true,
language: {
searchPlaceholder: "Type here..."
}
});
$('table.display').each(function() {
$(this).DataTable({
lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
stateSave: true,
searching: true,
info: true,
pageLength: 10,
language: {
searchPlaceholder: "Type here..."
},
"fnDrawCallback": function ( oSettings ){
var tableId = oSettings.nTable.id;
if(oSettings.fnRecordsTotal() < 10){
$('#'+tableId+'_length').hide();
$('#'+tableId+'_paginate').hide();
$('#'+tableId+'_filter').hide();
$('#'+tableId+'_info').hide();
}
}
});
})
});
</script>
{%- endif %}
Expand Down
16 changes: 16 additions & 0 deletions pages/documentation/resource_table.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Tools and resources table
page_id: tools_and_resources_table
datatable: true
---

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.
Expand Down Expand Up @@ -88,3 +89,18 @@ Tools and resources specifically mentioned in the text of the pages should be pr

{% 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." %}

## Listing all resources

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:

```
{% raw %}
{% include resource-table-all.html %}
{% endraw %}
```


{% include resource-table-all.html %}



18 changes: 0 additions & 18 deletions pages/example_pages/all_tools_and_resources.md

This file was deleted.

0 comments on commit f22486e

Please sign in to comment.