Toggle paginations if one or less items are displayed.

This commit is contained in:
Patrick Jentsch 2019-08-14 16:59:39 +02:00
parent ea399d2cdc
commit 47c3edeb7f
2 changed files with 21 additions and 16 deletions

View File

@ -12,6 +12,17 @@
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/>
<script src="{{ url_for('static', filename='js/list.js') }}"></script>
<script>
// Utils
var updatePagination = function(list) {
pagination = list.listContainer.querySelector(".pagination");
if (pagination.childElementCount <= 1) {
pagination.classList.add("hide");
} else {
pagination.classList.remove("hide");
}
}
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>

View File

@ -39,16 +39,11 @@
</div>
</div>
<script>
corpusListOptions = {
valueNames: ['title'],
corpusList = new List("corpus-list", {valueNames: ["title"],
page: 4,
pagination: true
};
corpusList = new List("corpus-list", corpusListOptions);
/*
* TODO: Hide Pagination if there is only on page
* corpusListPagination = document.querySelector("#corpus-list .pagination");
*/
pagination: true});
corpusList.on("filterComplete", updatePagination);
corpusList.on("searchComplete", updatePagination);
</script>
<div class="col s12">
@ -113,12 +108,11 @@
</div>
</div>
<script>
jobListOptions = {
valueNames: ['title'],
var jobList = new List("job-list", {valueNames: ["title"],
page: 4,
pagination: true
};
jobList = new List("job-list", jobListOptions);
pagination: true});
jobList.on("filterComplete", updatePagination);
jobList.on("searchComplete", updatePagination);
</script>
<div id="new-corpus-modal" class="modal">