summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdo Walter2017-09-13 13:57:20 +0200
committerUdo Walter2017-09-13 13:57:20 +0200
commit20dae626debac91f737473175b372c27b931f283 (patch)
treec7e3c2516cf1f24c5099da1b413558d8890639e2
parent[exams] small design changes (diff)
downloadslx-admin-20dae626debac91f737473175b372c27b931f283.tar.gz
slx-admin-20dae626debac91f737473175b372c27b931f283.tar.xz
slx-admin-20dae626debac91f737473175b372c27b931f283.zip
[js_stupidtable] fixed stupidtable not working with collapsed tables
-rw-r--r--modules-available/exams/templates/page-upcoming-lectures.html4
-rw-r--r--modules-available/js_stupidtable/clientscript.js17
2 files changed, 16 insertions, 5 deletions
diff --git a/modules-available/exams/templates/page-upcoming-lectures.html b/modules-available/exams/templates/page-upcoming-lectures.html
index bea53ad0..8ff8143e 100644
--- a/modules-available/exams/templates/page-upcoming-lectures.html
+++ b/modules-available/exams/templates/page-upcoming-lectures.html
@@ -39,8 +39,6 @@
</td>
</tr>
{{/pending_lectures}}
- </tbody>
- <tfoot>
{{#decollapse}}
<tr class="slx-decollapse">
<td colspan="3">
@@ -50,7 +48,7 @@
</td>
</tr>
{{/decollapse}}
- </tfoot>
+ </tbody>
</table>
</div>
</div>
diff --git a/modules-available/js_stupidtable/clientscript.js b/modules-available/js_stupidtable/clientscript.js
index 4e0dd4c9..8b8fc107 100644
--- a/modules-available/js_stupidtable/clientscript.js
+++ b/modules-available/js_stupidtable/clientscript.js
@@ -97,7 +97,8 @@
var column = [];
var sortFns = $table.data('sortFns');
var sortMethod = sortFns[datatype];
- var trs = $table.children("tbody").children("tr");
+ var collapsedCount = $table.children("tbody").children("tr.collapse").length;
+ var trs = $table.children("tbody").children("tr:not(.slx-decollapse)");
// Extract the data for the column that needs to be sorted and pair it up
// with the TR itself into a tuple. This way sorting the values will
@@ -124,7 +125,19 @@
// Replace the content of tbody with the sorted rows. Strangely
// enough, .append accomplishes this for us.
trs = $.map(column, function(kv) { return kv[1]; });
- $table.children("tbody").append(trs);
+
+ if (collapsedCount > 0) {
+ var showCount = trs.length - collapsedCount;
+ for (var i = 0; i < trs.length; i++) {
+ if (i < showCount) {
+ $(trs[i]).removeClass("collapse");
+ } else {
+ $(trs[i]).addClass("collapse");
+ }
+ }
+ }
+
+ $table.children("tbody").prepend(trs);
// Reset siblings
$table.find("th").data("sort-dir", null).removeClass("sorting-desc sorting-asc");