summaryrefslogtreecommitdiffstats
path: root/modules-available/js_stupidtable
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-13 14:53:52 +0200
committerSimon Rettberg2018-04-13 14:53:52 +0200
commit3cf0ca85dc21b7e2a2b7f021fdc8cbb90fa451ab (patch)
tree79c2e10704a767c30e0d933cdc17732f4bd9e729 /modules-available/js_stupidtable
parent[js_stupidtable] Make will_manually_build_table default to true (diff)
downloadslx-admin-3cf0ca85dc21b7e2a2b7f021fdc8cbb90fa451ab.tar.gz
slx-admin-3cf0ca85dc21b7e2a2b7f021fdc8cbb90fa451ab.tar.xz
slx-admin-3cf0ca85dc21b7e2a2b7f021fdc8cbb90fa451ab.zip
[js_stupidtable] Add arrow indicating sort direction to current column
Diffstat (limited to 'modules-available/js_stupidtable')
-rw-r--r--modules-available/js_stupidtable/clientscript.js15
-rw-r--r--modules-available/js_stupidtable/style.css3
2 files changed, 15 insertions, 3 deletions
diff --git a/modules-available/js_stupidtable/clientscript.js b/modules-available/js_stupidtable/clientscript.js
index 563e8d00..25027690 100644
--- a/modules-available/js_stupidtable/clientscript.js
+++ b/modules-available/js_stupidtable/clientscript.js
@@ -37,6 +37,20 @@
$(this).stupidsort();
});
+ // OpenSLX -- sort arrow; pointer cursor
+ var $sortThs = $table.find('th[data-sort]');
+ $sortThs.addClass('slx-pointer').append('<span class="glyphicon glyphicon-chevron-up sortarrow invisible"></span>');
+ var $arrows = $sortThs.find('.sortarrow');
+ var dir = $.fn.stupidtable.dir;
+ $table.on("aftertablesort", function (e, data) {
+ $arrows.addClass('invisible');
+ var addArrow = data.direction !== dir.ASC ? "down" : "up";
+ var remArrow = data.direction === dir.ASC ? "down" : "up";
+ console.log(data);
+ data.$th.find('.sortarrow').removeClass('invisible glyphicon-chevron-' + remArrow).addClass('glyphicon-chevron-' + addArrow);
+ });
+ // End OpenSLX
+
// Sort th immediately if data-sort-onload="yes" is specified. Limit to
// the first one found - only one default sort column makes sense anyway.
var $th_onload_sort = $table.find("th[data-sort-onload=yes]").eq(0);
@@ -304,6 +318,7 @@
})(jQuery);
+// OpenSLX -- apply to all elements with class stupidtable
document.addEventListener("DOMContentLoaded", function() {
var table = $(".stupidtable");
if (table.length) {
diff --git a/modules-available/js_stupidtable/style.css b/modules-available/js_stupidtable/style.css
deleted file mode 100644
index 614a3d38..00000000
--- a/modules-available/js_stupidtable/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-th[data-sort] {
- cursor: pointer;
-} \ No newline at end of file