From 3cf0ca85dc21b7e2a2b7f021fdc8cbb90fa451ab Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 13 Apr 2018 14:53:52 +0200 Subject: [js_stupidtable] Add arrow indicating sort direction to current column --- modules-available/js_stupidtable/clientscript.js | 15 +++++++++++++++ modules-available/js_stupidtable/style.css | 3 --- 2 files changed, 15 insertions(+), 3 deletions(-) delete mode 100644 modules-available/js_stupidtable/style.css 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(''); + 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 -- cgit v1.2.3-55-g7522