From 9e97f78b53bae9dc4c700f5a627735da21c8055e Mon Sep 17 00:00:00 2001 From: Nadan Gergeo Date: Wed, 1 Feb 2023 06:41:05 +0100 Subject: [PATCH] Release v6.1.0 --- Gruntfile.js | 2 +- README.md | 75 +++++++- bower.json | 2 +- dist/css/rwd-table.css | 33 +++- dist/css/rwd-table.min.css | 4 +- dist/js/rwd-table.js | 288 ++++++++++++++++++++++++---- dist/js/rwd-table.min.js | 4 +- docs/css/rwd-table.css | 33 +++- docs/css/rwd-table.min.css | 4 +- docs/index.html | 381 ++++++++++++++++++++++++++++++++++--- docs/js/docs.js | 9 + docs/js/docs.min.js | 2 +- docs/js/rwd-table.js | 288 ++++++++++++++++++++++++---- docs/js/rwd-table.min.js | 4 +- package-lock.json | 162 ++++++++-------- package.json | 16 +- 16 files changed, 1096 insertions(+), 211 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4c8f8ad..e8552d8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -95,7 +95,7 @@ module.exports = function(grunt) { watch: { src: { // rebuild if files in src changes - files: ['src/**', 'docs/**'], + files: ['src/**'], tasks: ['build'], options: { livereload: { diff --git a/README.md b/README.md index 6194925..26d229b 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,9 @@ You can initalize the table without writing any JavaScript, just like Bootstrap. ```html ``` @@ -99,9 +101,9 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap Name - type - default - description + Type + Default + Description @@ -114,6 +116,61 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap

Tips: When initalizing via JavaScript, add data-pattern="" to responsive tables you wan't to exclude.

+ + sortable + boolean + false + +

+ Makes the table sortable by columns. Simply click a header to sort it. Reversed toggling if shiftKey is active. +

+

+ The sort function uses the attribute 'data-value' on a cell if it exists, otherwise it uses the 'innerText' prop (the content of the cell). + Useful if you want the value presented in a certain format, and the sort based on the value in another format. +

+

+ Tip: You can also trigger a sort like this: +

+
$(function() {
+  $('#myTableWrapper).responsiveTable(
+    'sortColumn, // name of function to trigger
+    [ // args array
+      pos-x, // x position of column
+      dir // sort direction (-1|1|0)
+    ]
+  );
+});
+

+ Note: Default is set to false, i.e. the feature is opt-in, to avoid potential click-event conflicts. +

+ + + + + compareFunction + function + +
function(a, b, dir) {
+  return a[0].localeCompare(
+    b[0], 
+    undefined, 
+    { numeric: true }
+  ) < 0 ? -dir : dir;
+}
+ + +

+ The default compare function uses String.prototype.localeCompare to sort the table columns. + But you can also pass your own custom compare function for sorting, when initializing via JavaScript. This is in case the built in compare function does not work for you (depends a lot on how the data is formatted). +

+

+ The function should take a (string), b (string) and dir (-1|1) as arguments and return -1, 0 or 1. +

+

+ Note: localeCompare is still highly recommended to base the function on. +

+ + stickyTableHeader boolean @@ -154,11 +211,11 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap i18n object - { - focus : 'Focus', - display : 'Display', - displayAll : 'Display all' - } +
{
+  focus : 'Focus',
+  display : 'Display',
+  displayAll : 'Display all'
+}
Used to translate the buttons (only works if you initialize via JavaScript). diff --git a/bower.json b/bower.json index 3b86a2d..b39181b 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "RWD-Table-Patterns", "description": "This is an awesome solution for responsive tables with complex data.", - "version": "6.0.2", + "version": "6.1.0", "keywords": [ "RWD", "responsive", diff --git a/dist/css/rwd-table.css b/dist/css/rwd-table.css index c0da4d4..c64eac4 100644 --- a/dist/css/rwd-table.css +++ b/dist/css/rwd-table.css @@ -1,5 +1,5 @@ /*! - * Responsive Tables v6.0.2 (http://gergeo.se/RWD-Table-Patterns) + * Responsive Tables v6.1.0 (http://gergeo.se/RWD-Table-Patterns) * This is an awesome solution for responsive tables with complex data. * Authors: Nadan Gergeo (www.blimp.se), Lucas Wiener & "Maggie Wachs (www.filamentgroup.com)" * Licensed under MIT (https://github.com/nadangergeo/RWD-Table-Patterns/blob/master/LICENSE-MIT) @@ -109,6 +109,14 @@ .table-responsive[data-pattern="priority-columns"] > .table { margin-bottom: 0; } +.table-responsive[data-pattern="priority-columns"] > .table > thead > tr > th, +.table-responsive[data-pattern="priority-columns"] > .table > tbody > tr > th, +.table-responsive[data-pattern="priority-columns"] > .table > tfoot > tr > th, +.table-responsive[data-pattern="priority-columns"] > .table > thead > tr > td, +.table-responsive[data-pattern="priority-columns"] > .table > tbody > tr > td, +.table-responsive[data-pattern="priority-columns"] > .table > tfoot > tr > td { + position: relative; +} .table-responsive[data-pattern="priority-columns"] > .table-tighten > thead > tr > th, .table-responsive[data-pattern="priority-columns"] > .table-tighten > tbody > tr > th, .table-responsive[data-pattern="priority-columns"] > .table-tighten > tfoot > tr > th, @@ -378,6 +386,7 @@ table.focus-on tfoot tr.focused td { .sticky-table-header > .table > tbody > tr > td, .sticky-table-header > .table > tfoot > tr > td { border-color: var(--bs-border-color); + position: relative; } .sticky-table-header > .table-tighten > thead > tr > th, .sticky-table-header > .table-tighten > tbody > tr > th, @@ -412,3 +421,25 @@ table.focus-on tfoot tr.focused td { .sticky-table-header > .table-bordered > tfoot > tr:last-child > td { border-bottom: 0; } +.table-responsive[data-sorting-active=true] thead th:not([colSpan]), +.table-responsive[data-sorting-active=true] thead th[colSpan="1"] { + cursor: pointer; + padding-right: 1.5rem; +} +.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted]:after, +.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted]:after { + display: block; + width: auto; + height: auto; + position: absolute; + right: 5px; + bottom: 0.5rem; +} +.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted="asc"]:after, +.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted="asc"]:after { + content: '↑'; +} +.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted="desc"]:after, +.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted="desc"]:after { + content: '↓'; +} diff --git a/dist/css/rwd-table.min.css b/dist/css/rwd-table.min.css index 79526ae..7089bf1 100644 --- a/dist/css/rwd-table.min.css +++ b/dist/css/rwd-table.min.css @@ -1,7 +1,7 @@ /*! - * Responsive Tables v6.0.2 (http://gergeo.se/RWD-Table-Patterns) + * Responsive Tables v6.1.0 (http://gergeo.se/RWD-Table-Patterns) * This is an awesome solution for responsive tables with complex data. * Authors: Nadan Gergeo (www.blimp.se), Lucas Wiener & "Maggie Wachs (www.filamentgroup.com)" * Licensed under MIT (https://github.com/nadangergeo/RWD-Table-Patterns/blob/master/LICENSE-MIT) */ -:root{--responsive-table-dropdown-hover-bg:#f2f2f2}.dropdown-menu>li.checkbox-row{padding:8px 16px}.dropdown-menu li.checkbox-row{display:block;display:flex;align-items:center;clear:both;font-weight:normal;line-height:calc(var(--bs-body-line-height) * 1rem);color:var(--bs-link-color);white-space:nowrap}.dropdown-menu li.checkbox-row label{font-size:.75rem;font-weight:600;margin-left:.5em;color:var(--bs-dark);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dropdown-menu li.checkbox-row:hover,.dropdown-menu li.checkbox-row input:hover,.dropdown-menu li.checkbox-row label:hover{cursor:pointer}.no-touch .dropdown-menu>.checkbox-row:hover,.no-touch .dropdown-menu>.checkbox-row:active{text-decoration:none;background-color:var(--responsive-table-dropdown-hover-bg)}.btn-toolbar{margin-bottom:calc(var(--bs-body-line-height) * 1rem)}.btn-toolbar .btn-outline-primary.btn-primary{color:var(--bs-white)}.lt-ie8 .btn-toolbar{display:none}.table-responsive{border-radius:var(--bs-border-radius);border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)}.table-responsive>.table{margin-bottom:0}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered thead tr:last-child{border-bottom-width:2px}.table-responsive>.table-bordered>thead,.table-responsive>.table-bordered>tbody,.table-responsive>.table-bordered>tfoot{border-color:var(--bs-border-color)}.table-responsive>.table-bordered>thead>th,.table-responsive>.table-bordered>tbody>th,.table-responsive>.table-bordered>tfoot>th,.table-responsive>.table-bordered>thead>td,.table-responsive>.table-bordered>tbody>td,.table-responsive>.table-bordered>tfoot>td{border-color:var(--bs-border-color)}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.table-responsive[data-pattern="priority-columns"]{width:100%;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:-ms-autohiding-scrollbar;border-radius:var(--bs-border-radius);border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);-webkit-overflow-scrolling:touch}.table-responsive[data-pattern="priority-columns"]>.table{margin-bottom:0}.table-responsive[data-pattern="priority-columns"]>.table-tighten>thead>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tbody>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tfoot>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>thead>tr>td,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tbody>tr>td,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tfoot>tr>td{white-space:nowrap}.table-responsive[data-pattern="priority-columns"]>.table-bordered{border:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr{border-color:var(--bs-border-color)}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr td{border-color:var(--bs-border-color)}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>td:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>td:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>td:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>td:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr:last-child>th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr:last-child>th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr:last-child>td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.table-responsive.absolute-solution{position:relative}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="0"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="0"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="0"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="0"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:none}.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="1"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="1"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"]{display:table-cell}@media screen and (min-width:480px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"]{display:table-cell}}@media screen and (min-width:640px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"]{display:table-cell}}@media screen and (min-width:800px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"]{display:table-cell}}@media screen and (min-width:960px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"]{display:table-cell}}@media screen and (min-width:1120px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:table-cell}}.mq.js .table-responsive[data-pattern="priority-columns"] th.cell-hide,.mq.js.lt-ie10 .sticky-table-header th.cell-hide,.mq.js .table-responsive[data-pattern="priority-columns"] td.cell-hide,.mq.js.lt-ie10 .sticky-table-header td.cell-hide{display:none}.mq.js .table-responsive[data-pattern="priority-columns"] th.cell-show,.mq.js.lt-ie10 .sticky-table-header th.cell-show,.mq.js .table-responsive[data-pattern="priority-columns"] td.cell-show,.mq.js.lt-ie10 .sticky-table-header td.cell-show{display:table-cell}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"] th.cell-show,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header th.cell-show,.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"] td.cell-show,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header td.cell-show{display:inline}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all th,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all th,.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all td,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all td{display:inline !important}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all th[data-priority="-1"],.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all th[data-priority="-1"],.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all td[data-priority="-1"],.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all td[data-priority="-1"]{display:none !important}.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all th,.mq.js.lt-ie10 .sticky-table-header table.display-all th,.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all td,.mq.js.lt-ie10 .sticky-table-header table.display-all td{display:table-cell !important}.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all th[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header table.display-all th[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all td[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header table.display-all td[data-priority="-1"]{display:none !important}table.table-small-font{font-size:.85rem;-webkit-text-size-adjust:none;line-height:var(--bs-body-line-height)}table.focus-on tbody tr:hover,table.focus-on tfoot tr:hover{cursor:pointer}table.focus-on tbody tr.unfocused th,table.focus-on tfoot tr.unfocused th,table.focus-on tbody tr.unfocused td,table.focus-on tfoot tr.unfocused td{color:var(--bs-gray);opacity:.75}table.focus-on tbody tr.focused th,table.focus-on tfoot tr.focused th,table.focus-on tbody tr.focused td,table.focus-on tfoot tr.focused td{background-color:var(--bs-primary);color:var(--bs-white);opacity:1 !important}.sticky-table-header{background-color:#fff;border:none;border-radius:0;border-top:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);border-bottom:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);visibility:hidden;z-index:990;overflow:hidden}.fixed-solution .sticky-table-header{position:fixed;min-width:0}.absolute-solution .sticky-table-header{position:absolute;min-width:100%;top:0}.sticky-table-header.border-radius-fix{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.sticky-table-header>.table{margin-bottom:0}.sticky-table-header>.table>thead>tr,.sticky-table-header>.table>tbody>tr,.sticky-table-header>.table>tfoot>tr{border-color:var(--bs-border-color)}.sticky-table-header>.table>thead>tr>th,.sticky-table-header>.table>tbody>tr>th,.sticky-table-header>.table>tfoot>tr>th,.sticky-table-header>.table>thead>tr>td,.sticky-table-header>.table>tbody>tr>td,.sticky-table-header>.table>tfoot>tr>td{border-color:var(--bs-border-color)}.sticky-table-header>.table-tighten>thead>tr>th,.sticky-table-header>.table-tighten>tbody>tr>th,.sticky-table-header>.table-tighten>tfoot>tr>th,.sticky-table-header>.table-tighten>thead>tr>td,.sticky-table-header>.table-tighten>tbody>tr>td,.sticky-table-header>.table-tighten>tfoot>tr>td{white-space:nowrap}.sticky-table-header>.table-bordered{border:0}.sticky-table-header>.table-bordered>thead>tr>th:first-child,.sticky-table-header>.table-bordered>tbody>tr>th:first-child,.sticky-table-header>.table-bordered>tfoot>tr>th:first-child,.sticky-table-header>.table-bordered>thead>tr>td:first-child,.sticky-table-header>.table-bordered>tbody>tr>td:first-child,.sticky-table-header>.table-bordered>tfoot>tr>td:first-child{border-left:0}.sticky-table-header>.table-bordered>thead>tr>th:last-child,.sticky-table-header>.table-bordered>tbody>tr>th:last-child,.sticky-table-header>.table-bordered>tfoot>tr>th:last-child,.sticky-table-header>.table-bordered>thead>tr>td:last-child,.sticky-table-header>.table-bordered>tbody>tr>td:last-child,.sticky-table-header>.table-bordered>tfoot>tr>td:last-child{border-right:0}.sticky-table-header>.table-bordered>tbody>tr:last-child>th,.sticky-table-header>.table-bordered>tfoot>tr:last-child>th,.sticky-table-header>.table-bordered>tbody>tr:last-child>td,.sticky-table-header>.table-bordered>tfoot>tr:last-child>td{border-bottom:0} \ No newline at end of file +:root{--responsive-table-dropdown-hover-bg:#f2f2f2}.dropdown-menu>li.checkbox-row{padding:8px 16px}.dropdown-menu li.checkbox-row{display:block;display:flex;align-items:center;clear:both;font-weight:normal;line-height:calc(var(--bs-body-line-height) * 1rem);color:var(--bs-link-color);white-space:nowrap}.dropdown-menu li.checkbox-row label{font-size:.75rem;font-weight:600;margin-left:.5em;color:var(--bs-dark);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dropdown-menu li.checkbox-row:hover,.dropdown-menu li.checkbox-row input:hover,.dropdown-menu li.checkbox-row label:hover{cursor:pointer}.no-touch .dropdown-menu>.checkbox-row:hover,.no-touch .dropdown-menu>.checkbox-row:active{text-decoration:none;background-color:var(--responsive-table-dropdown-hover-bg)}.btn-toolbar{margin-bottom:calc(var(--bs-body-line-height) * 1rem)}.btn-toolbar .btn-outline-primary.btn-primary{color:var(--bs-white)}.lt-ie8 .btn-toolbar{display:none}.table-responsive{border-radius:var(--bs-border-radius);border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)}.table-responsive>.table{margin-bottom:0}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered thead tr:last-child{border-bottom-width:2px}.table-responsive>.table-bordered>thead,.table-responsive>.table-bordered>tbody,.table-responsive>.table-bordered>tfoot{border-color:var(--bs-border-color)}.table-responsive>.table-bordered>thead>th,.table-responsive>.table-bordered>tbody>th,.table-responsive>.table-bordered>tfoot>th,.table-responsive>.table-bordered>thead>td,.table-responsive>.table-bordered>tbody>td,.table-responsive>.table-bordered>tfoot>td{border-color:var(--bs-border-color)}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.table-responsive[data-pattern="priority-columns"]{width:100%;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:-ms-autohiding-scrollbar;border-radius:var(--bs-border-radius);border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);-webkit-overflow-scrolling:touch}.table-responsive[data-pattern="priority-columns"]>.table{margin-bottom:0}.table-responsive[data-pattern="priority-columns"]>.table>thead>tr>th,.table-responsive[data-pattern="priority-columns"]>.table>tbody>tr>th,.table-responsive[data-pattern="priority-columns"]>.table>tfoot>tr>th,.table-responsive[data-pattern="priority-columns"]>.table>thead>tr>td,.table-responsive[data-pattern="priority-columns"]>.table>tbody>tr>td,.table-responsive[data-pattern="priority-columns"]>.table>tfoot>tr>td{position:relative}.table-responsive[data-pattern="priority-columns"]>.table-tighten>thead>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tbody>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tfoot>tr>th,.table-responsive[data-pattern="priority-columns"]>.table-tighten>thead>tr>td,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tbody>tr>td,.table-responsive[data-pattern="priority-columns"]>.table-tighten>tfoot>tr>td{white-space:nowrap}.table-responsive[data-pattern="priority-columns"]>.table-bordered{border:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr{border-color:var(--bs-border-color)}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr td{border-color:var(--bs-border-color)}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>th:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>td:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>td:first-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>th:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>thead>tr>td:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr>td:last-child,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr:last-child>th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr:last-child>th,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tbody>tr:last-child>td,.table-responsive[data-pattern="priority-columns"]>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.table-responsive.absolute-solution{position:relative}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="0"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="0"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="0"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="0"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:none}.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="1"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="1"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="1"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="1"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="1"]{display:table-cell}@media screen and (min-width:480px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="2"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="2"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="2"]{display:table-cell}}@media screen and (min-width:640px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="3"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="3"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="3"]{display:table-cell}}@media screen and (min-width:800px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="4"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="4"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="4"]{display:table-cell}}@media screen and (min-width:960px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="5"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="5"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="5"]{display:table-cell}}@media screen and (min-width:1120px){.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.lt-ie9.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.lt-ie9.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:inline}.mq.js .table-responsive[data-pattern="priority-columns"] th[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header th[data-priority="6"],.mq.js .table-responsive[data-pattern="priority-columns"] td[data-priority="6"],.mq.js.lt-ie10 .sticky-table-header td[data-priority="6"]{display:table-cell}}.mq.js .table-responsive[data-pattern="priority-columns"] th.cell-hide,.mq.js.lt-ie10 .sticky-table-header th.cell-hide,.mq.js .table-responsive[data-pattern="priority-columns"] td.cell-hide,.mq.js.lt-ie10 .sticky-table-header td.cell-hide{display:none}.mq.js .table-responsive[data-pattern="priority-columns"] th.cell-show,.mq.js.lt-ie10 .sticky-table-header th.cell-show,.mq.js .table-responsive[data-pattern="priority-columns"] td.cell-show,.mq.js.lt-ie10 .sticky-table-header td.cell-show{display:table-cell}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"] th.cell-show,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header th.cell-show,.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"] td.cell-show,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header td.cell-show{display:inline}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all th,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all th,.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all td,.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all td{display:inline !important}.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all th[data-priority="-1"],.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all th[data-priority="-1"],.lt-ie9 .mq.js .table-responsive[data-pattern="priority-columns"].display-all td[data-priority="-1"],.lt-ie9 .mq.js.lt-ie10 .sticky-table-header.display-all td[data-priority="-1"]{display:none !important}.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all th,.mq.js.lt-ie10 .sticky-table-header table.display-all th,.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all td,.mq.js.lt-ie10 .sticky-table-header table.display-all td{display:table-cell !important}.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all th[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header table.display-all th[data-priority="-1"],.mq.js .table-responsive[data-pattern="priority-columns"] table.display-all td[data-priority="-1"],.mq.js.lt-ie10 .sticky-table-header table.display-all td[data-priority="-1"]{display:none !important}table.table-small-font{font-size:.85rem;-webkit-text-size-adjust:none;line-height:var(--bs-body-line-height)}table.focus-on tbody tr:hover,table.focus-on tfoot tr:hover{cursor:pointer}table.focus-on tbody tr.unfocused th,table.focus-on tfoot tr.unfocused th,table.focus-on tbody tr.unfocused td,table.focus-on tfoot tr.unfocused td{color:var(--bs-gray);opacity:.75}table.focus-on tbody tr.focused th,table.focus-on tfoot tr.focused th,table.focus-on tbody tr.focused td,table.focus-on tfoot tr.focused td{background-color:var(--bs-primary);color:var(--bs-white);opacity:1 !important}.sticky-table-header{background-color:#fff;border:none;border-radius:0;border-top:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);border-bottom:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);visibility:hidden;z-index:990;overflow:hidden}.fixed-solution .sticky-table-header{position:fixed;min-width:0}.absolute-solution .sticky-table-header{position:absolute;min-width:100%;top:0}.sticky-table-header.border-radius-fix{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.sticky-table-header>.table{margin-bottom:0}.sticky-table-header>.table>thead>tr,.sticky-table-header>.table>tbody>tr,.sticky-table-header>.table>tfoot>tr{border-color:var(--bs-border-color)}.sticky-table-header>.table>thead>tr>th,.sticky-table-header>.table>tbody>tr>th,.sticky-table-header>.table>tfoot>tr>th,.sticky-table-header>.table>thead>tr>td,.sticky-table-header>.table>tbody>tr>td,.sticky-table-header>.table>tfoot>tr>td{border-color:var(--bs-border-color);position:relative}.sticky-table-header>.table-tighten>thead>tr>th,.sticky-table-header>.table-tighten>tbody>tr>th,.sticky-table-header>.table-tighten>tfoot>tr>th,.sticky-table-header>.table-tighten>thead>tr>td,.sticky-table-header>.table-tighten>tbody>tr>td,.sticky-table-header>.table-tighten>tfoot>tr>td{white-space:nowrap}.sticky-table-header>.table-bordered{border:0}.sticky-table-header>.table-bordered>thead>tr>th:first-child,.sticky-table-header>.table-bordered>tbody>tr>th:first-child,.sticky-table-header>.table-bordered>tfoot>tr>th:first-child,.sticky-table-header>.table-bordered>thead>tr>td:first-child,.sticky-table-header>.table-bordered>tbody>tr>td:first-child,.sticky-table-header>.table-bordered>tfoot>tr>td:first-child{border-left:0}.sticky-table-header>.table-bordered>thead>tr>th:last-child,.sticky-table-header>.table-bordered>tbody>tr>th:last-child,.sticky-table-header>.table-bordered>tfoot>tr>th:last-child,.sticky-table-header>.table-bordered>thead>tr>td:last-child,.sticky-table-header>.table-bordered>tbody>tr>td:last-child,.sticky-table-header>.table-bordered>tfoot>tr>td:last-child{border-right:0}.sticky-table-header>.table-bordered>tbody>tr:last-child>th,.sticky-table-header>.table-bordered>tfoot>tr:last-child>th,.sticky-table-header>.table-bordered>tbody>tr:last-child>td,.sticky-table-header>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.table-responsive[data-sorting-active=true] thead th:not([colSpan]),.table-responsive[data-sorting-active=true] thead th[colSpan="1"]{cursor:pointer;padding-right:1.5rem}.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted]:after,.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted]:after{display:block;width:auto;height:auto;position:absolute;right:5px;bottom:.5rem}.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted="asc"]:after,.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted="asc"]:after{content:'↑'}.table-responsive[data-sorting-active=true] thead th:not([colSpan])[data-sorted="desc"]:after,.table-responsive[data-sorting-active=true] thead th[colSpan="1"][data-sorted="desc"]:after{content:'↓'} \ No newline at end of file diff --git a/dist/js/rwd-table.js b/dist/js/rwd-table.js index 7676722..53ddc88 100644 --- a/dist/js/rwd-table.js +++ b/dist/js/rwd-table.js @@ -1,5 +1,5 @@ /*! - * Responsive Tables v6.0.2 (http://gergeo.se/RWD-Table-Patterns) + * Responsive Tables v6.1.0 (http://gergeo.se/RWD-Table-Patterns) * This is an awesome solution for responsive tables with complex data. * Authors: Nadan Gergeo (www.blimp.se), Lucas Wiener & "Maggie Wachs (www.filamentgroup.com)" * Licensed under MIT (https://github.com/nadangergeo/RWD-Table-Patterns/blob/master/LICENSE-MIT) @@ -37,8 +37,12 @@ //good to have - for easy access this.$thead = this.$table.find('thead'); - this.$hdrCells = this.$thead.find("tr").first().find('th'); - this.$bodyRows = this.$table.find('tbody, tfoot').find('tr'); + this.$hdrRows = this.$thead.find("tr"); + this.$hdrCells = this.$hdrRows.first().find('th'); // use first row as basis + this.$tbody = this.$table.find('tbody'); + this.$bodyRows = this.$tbody.find('tr'); + this.$footRows = this.$table.find('tfoot').find('tr'); + this.$bodyAndFootRows = $.merge(this.$bodyRows, this.$footRows); // combine tbody and tfoot rows //toolbar and buttons this.$btnToolbar = null; //defined farther down @@ -77,7 +81,7 @@ this.setupTableHeader(); //setup standard cells - this.setupBodyRows(); + this.setupBodyAndFootRows(); //create sticky table head if(this.options.stickyTableHeader){ @@ -92,6 +96,25 @@ // Event binding // ------------------------- + // bind click on rows + this.bindClickOnRows(); + + if(this.options.sortable) { + //apply pattern option as data-attribute, in case it was set via js + this.$tableScrollWrapper.attr('data-sortable', true); + //needed for the css. Makes sure that sorting is actually active before applying styles. + this.$tableScrollWrapper.attr('data-sorting-active', true); + // bind click on theads with sorting function + this.makeSortableByColumns(); + + // for alternate toggling of sort direction + this.shiftKeyActive = false; + // listen on keydown/up and update shiftKeyActive + $(document).on('keydown keyup', function(event) { + that.shiftKeyActive = event.shiftKey; + }); + } + // on orientchange, resize and displayAllBtn-click $(window).bind('orientationchange resize ' + this.displayAllTrigger, function(){ @@ -114,6 +137,10 @@ addFocusBtn: true, // should it have a focus button? focusBtnIcon: 'fa fa-crosshairs', mainContainer: window, + sortable: false, + compareFunction: function(a, b, dir) { + return a[0].localeCompare(b[0], undefined, { numeric: true }) < 0 ? -dir : dir; + }, i18n: { focus : 'Focus', display : 'Display', @@ -127,11 +154,23 @@ this.$tableWrapper = this.$tableScrollWrapper.parent(); }; + ResponsiveTable.prototype.bindClickOnRows = function() { + var that = this; + + if(this.options.addFocusBtn) { + this.$bodyAndFootRows.unbind('click'); // remove old event listeners + this.$bodyAndFootRows.click(function() { + that.focusOnRow($(this)); + }); + } + } + // Create toolbar with buttons ResponsiveTable.prototype.createButtonToolbar = function() { var that = this; - this.$btnToolbar = $('[data-responsive-table-toolbar="' + this.id + '"]').addClass('btn-toolbar justify-content-between'); + this.$btnToolbar = $('[data-responsive-table-toolbar="' + this.id + '"]'); + this.$btnToolbar.addClass('btn-toolbar justify-content-between'); if(this.$btnToolbar.length === 0) { this.$btnToolbar = $('
'); } @@ -159,12 +198,7 @@ // bind click on focus btn this.$focusBtn.click(function(){ - $.proxy(that.activateFocus(), that); - }); - - // bind click on rows - this.$bodyRows.click(function(){ - $.proxy(that.focusOnRow($(this)), that); + that.activateFocus(); }); } else { this.$btnToolbar.append($('
')); //add empty div instead, keeping same layout @@ -199,8 +233,8 @@ }; ResponsiveTable.prototype.clearAllFocus = function() { - this.$bodyRows.removeClass('unfocused'); - this.$bodyRows.removeClass('focused'); + this.$bodyAndFootRows.removeClass('unfocused'); + this.$bodyAndFootRows.removeClass('focused'); }; ResponsiveTable.prototype.activateFocus = function() { @@ -223,7 +257,7 @@ this.clearAllFocus(); if(!alreadyFocused) { - this.$bodyRows.addClass('unfocused'); + this.$bodyAndFootRows.addClass('unfocused'); $(row).addClass('focused'); } } @@ -285,16 +319,16 @@ // bind scroll on mainContainer with updateStickyTableHeader $(this.options.mainContainer).on('scroll', function(event){ - $.proxy(that.updateStickyTableHeader(), that); + that.updateStickyTableHeader(); }); // bind resize on window with updateStickyTableHeader - $(window).on('resize', function(e){ - $.proxy(that.updateStickyTableHeader(), that); + $(window).on('resize', function(event){ + that.updateStickyTableHeader(); }); $(that.$tableScrollWrapper).on('scroll', function(event){ - $.proxy(that.updateStickyTableHeader(), that); + that.updateStickyTableHeader(); }); // determine what solution to use for rendereing sticky table head (aboslute/fixed). @@ -422,6 +456,8 @@ ResponsiveTable.prototype.setupTableHeader = function() { var that = this; + var colSpans = 0; + // for each header column that.$hdrCells.each(function(i){ var $th = $(this), @@ -438,6 +474,15 @@ thText = $th.attr('data-col-name'); } + // add x pos (used for sorting) + $th.attr('data-pos-x', i + colSpans); + + // take account for colspans + var colSpan = parseInt($th.prop('colSpan')); + if(colSpan > 1) { + colSpans += (colSpan - 1); + } + // create the hide/show toggle for the current column if ( $th.is('[data-priority]') && $th.data('priority') !== -1 ) { var $toggle = $('
  • '); @@ -532,22 +577,30 @@ }); // end hdrCells loop if(!$.isEmptyObject(this.headerRowIndices)) { - that.setupRow(this.$thead.find("tr:eq(1)"), this.headerRowIndices); + that.setupRow(this.$thead.find("tr:eq(1)"), this.headerRowIndices, 1); } + + // also give first row in thead an index + this.$hdrRows.first().attr('data-pos-y', 0); }; // Setup body rows // assign matching "data-columns" attributes to the associated cells "(cells with colspan>1 has multiple columns). - ResponsiveTable.prototype.setupBodyRows = function() { + ResponsiveTable.prototype.setupBodyAndFootRows = function() { var that = this; - // for each body rows - that.$bodyRows.each(function(){ - that.setupRow($(this), that.headerColIndices); + // for each body + that.$bodyRows.each(function(index){ + that.setupRow($(this), that.headerColIndices, index); + }); + + // for each footer row + that.$footRows.each(function(index){ + that.setupRow($(this), that.headerColIndices, index); }); }; - ResponsiveTable.prototype.setupRow = function($row, indices) { + ResponsiveTable.prototype.setupRow = function($row, indices, index) { var that = this; //check if it's already set up @@ -556,12 +609,13 @@ return; } else { $row.data('setup', true); + $row.attr('data-pos-y', index); } var idStart = 0; // for each cell - $row.find('th, td').each(function(){ + $row.find('th, td').each(function(i){ var $cell = $(this); var columnsAttr = ''; @@ -590,9 +644,19 @@ //remove whitespace in begining of string. columnsAttr = columnsAttr.substring(1); - //set attribute to cell + //set data-columns attribute to cell $cell.attr('data-columns', columnsAttr); + // x-position (for sorting function) + var rowSpansBeforeCell = 0; + + // Take account to rowspans if it is the seconds row in thead + if($row.parent().prop('tagName') === 'THEAD' && $row.attr('data-pos-y') === "1" && that.rowspansBeforeIndex) { + var rowSpansBeforeCell = that.rowspansBeforeIndex[i] || 0; + } + + $cell.attr('data-pos-x', i + rowSpansBeforeCell); + //increment idStart with the current cells colSpan. idStart = idStart + colSpan; }); @@ -608,7 +672,7 @@ var colPadding = 0; var rowPadding = 0; - this.$thead.find("tr").first().find('th').each(function(i){ + this.$hdrCells.each(function(i){ var $th = $(this); var colSpan = $th.prop('colSpan'); var rowSpan = $th.prop("rowSpan"); @@ -628,27 +692,27 @@ colPadding += colSpan - 1; }); - if(this.$thead.find("tr").length > 2) { - throw new Error("This plugin doesnt support more than two rows in thead."); - } - - if(this.$thead.find("tr").length === 2) { - var $row = $(this.$thead.find("tr")[1]); + if(this.$hdrRows.length === 2) { + var $row = $(this.$hdrRows[1]); $row.find("th").each(function(cellIndex) { that.headerRowIndices[cellIndex] = that.headerColIndices[rowspansBeforeIndex[cellIndex] + cellIndex]; + that.rowspansBeforeIndex = rowspansBeforeIndex; }); + } else if(this.$hdrRows.length > 2) { + throw new Error("This plugin doesnt support more than two rows in thead."); } } // Run this after the content in tbody has changed ResponsiveTable.prototype.update = function() { - this.$bodyRows = this.$table.find('tbody, tfoot').find('tr'); - this.setupBodyRows(); + this.$bodyAndFootRows = this.$table.find('tbody, tfoot').find('tr'); // get fresh list + this.setupBodyAndFootRows(); + this.bindClickOnRows(); // Remove old tbody clone from Tableclone this.$tableClone.find('tbody, tfoot').remove(); - // Make new clone of tbody + // Make new clone of tbody and tfoot var $tbodyClone = this.$table.find('tbody, tfoot').clone(); //replace ids @@ -699,12 +763,160 @@ }); }; + // Utils for sorting + + ResponsiveTable.prototype.getSortedColumn = function(col, dir) { + var that = this; + + for (var i = 0; i < col.length; i++) { + col[i] = [col[i], i]; + } + + var compareFunction; + if(that.options.compareFunction instanceof Function) { + compareFunction = function(a, b) { + return that.options.compareFunction(a, b, dir); + }; + } + + col.sort(compareFunction); + + col.indices = []; + + for (var j = 0; j < col.length; j++) { + col.indices.push(col[j][1]); + col[j] = col[j][0]; + } + + return col; + }; + + ResponsiveTable.prototype.getRestoredColumn = function(col) { + for (var i = 0; i < col.length; i++) { + col[i] = [col[i], i, $(col[i]).attr("data-pos-y")]; + } + + col.sort(function(a, b) { + return a[2].localeCompare(b[2], undefined, { numeric: true }) < 0 ? -1 : 1; + }); + + col.indices = []; + + for (var j = 0; j < col.length; j++) { + col.indices.push(col[j][1]); + col[j] = col[j][0]; + } + + return col; + }; + + var sortDirMapping = { + "asc": 1, + "desc": -1, + "org": 0 + }; + + ResponsiveTable.prototype.sortColumn = function(hdr, dir) { + var that = this; + var $tBody = that.$tbody; + + // if hdr is an number (index), treat as pos-x and use it to get hdr. Otherwise expecting hdr element directly (sent via click-event). + var $hdr = Number.isInteger(hdr) ? that.$thead.find('th[data-pos-x='+ hdr +']') : $(hdr); + var id = $hdr.prop('id'); + var $clone = id.indexOf('-clone') === (id.length - 6) ? $('#' + id.slice(0, id.length - 6)) : $('#' + $(hdr).prop('id') + '-clone'); // the clone is the original if 'hdr' is the clone, and vice versa. + + // get fresh list of rows in tbody + var $tBodyRows = $tBody.find('tr'); + + // get all cells under the column + var posX = $hdr.data('pos-x'); + var col = $tBodyRows.find('[data-pos-x='+ posX +']'); + + var sorted = $hdr.attr("data-sorted"); + + // get all hdr cells if not cached + if(!that.$allHdrCells) { + that.$hdrCellsClones = that.$tableClone ? that.$tableClone.find('thead > tr > th') : []; + that.$allHdrCells = $.merge(this.$hdrRows.find('th'), that.$hdrCellsClones); + } + + // remove sorted attr from all cols + that.$allHdrCells.filter("[data-sorted]").each(function() { + $(this).removeAttr("data-sorted"); + }); + + var sortDir; + + if((that.shiftKeyActive && sorted === "desc") || (!sorted && !that.shiftKeyActive) || dir === 1) { + // add attr to clicked col + $hdr.attr("data-sorted", "asc"); + // do same on clone (sticky) + $clone.attr("data-sorted", "asc"); + sortDir = 1; + } else if((that.shiftKeyActive && !sorted) || (sorted === "asc" && !that.shiftKeyActive) || dir === -1) { + // switch to desc order + $hdr.attr("data-sorted", "desc"); + // do same on clone (sticky) + $clone.attr("data-sorted", "desc"); + sortDir = -1; + } else if((that.shiftKeyActive && sorted === "asc") || (sorted === "desc" && !that.shiftKeyActive) || dir === 0) { + // remove + $hdr.removeAttr("data-sorted"); + // do same on clone (sticky) + $clone.removeAttr("data-sorted"); + sortDir = 0; + } + + if(sortDir !== 0){ + col = col.map(function(i, e) { + // prepare for sorting by just keeping the inner text + return $(e).data('value') || e.innerText; + }).get(); + + // sort + col = that.getSortedColumn(col, sortDir); + } else { + // restore original order + col = that.getRestoredColumn($tBodyRows.get()) + } + + // Now that we have the new order indexes, modify dom into that order. + // This is definetely not the fastest method, but it was the easiest to implement for now. + // Todo: optimize by detatching and appending (moving) rows, instead of cloning and deleting. + for (var i = 0; i < col.length; i++) { + $tBodyRows.eq(col.indices[i]).clone().appendTo($tBody); // add copy to end + } + + for (var i = 0; i < col.length; i++) { + $tBodyRows.eq(i).remove(); // remove old copies at top (unsorted original) + } + + that.$bodyAndFootRows = that.$table.find('tbody, tfoot').find('tr'); // get fresh list + that.bindClickOnRows(); // add click events (focus) + } + + ResponsiveTable.prototype.makeSortableByColumns = function() { + var that = this; + that.$hdrCellsClones = that.$tableClone ? that.$tableClone.find('thead > tr > th') : []; + that.$allHdrCells = $.merge(this.$hdrRows.find('th'), that.$hdrCellsClones); + + that.$allHdrCells.each(function(colIndex){ + if($(this).prop('colSpan') > 1) { + return; + } + + $(this).click(function() { + that.sortColumn(this); + }); + }); + }; + // RESPONSIVE TABLE PLUGIN DEFINITION // =========================== var old = $.fn.responsiveTable; - $.fn.responsiveTable = function (option) { + $.fn.responsiveTable = function (option, args) { return this.each(function () { var $this = $(this); var data = $this.data('responsiveTable'); @@ -718,7 +930,7 @@ $this.data('responsiveTable', (data = new ResponsiveTable(this, options))); } if (typeof option === 'string') { - data[option](); + data[option].apply(data, args); } }); }; diff --git a/dist/js/rwd-table.min.js b/dist/js/rwd-table.min.js index 833a827..1e4c70d 100644 --- a/dist/js/rwd-table.min.js +++ b/dist/js/rwd-table.min.js @@ -1,7 +1,7 @@ /*! - * Responsive Tables v6.0.2 (http://gergeo.se/RWD-Table-Patterns) + * Responsive Tables v6.1.0 (http://gergeo.se/RWD-Table-Patterns) * This is an awesome solution for responsive tables with complex data. * Authors: Nadan Gergeo (www.blimp.se), Lucas Wiener & "Maggie Wachs (www.filamentgroup.com)" * Licensed under MIT (https://github.com/nadangergeo/RWD-Table-Patterns/blob/master/LICENSE-MIT) */ -!function(d){"use strict";var a=function(t,i){var e=this;if(this.options=i,this.$tableWrapper=null,this.$tableScrollWrapper=d(t),this.$table=d(t).find("table"),1!==this.$table.length)throw new Error("Exactly one table is expected in a .table-responsive div.");this.$tableScrollWrapper.attr("data-pattern",this.options.pattern),this.id=this.$table.prop("id")||this.$tableScrollWrapper.prop("id")||"id"+Math.random().toString(16).slice(2),this.$tableClone=null,this.$stickyTableHeader=null,this.$thead=this.$table.find("thead"),this.$hdrCells=this.$thead.find("tr").first().find("th"),this.$bodyRows=this.$table.find("tbody, tfoot").find("tr"),this.$btnToolbar=null,this.$dropdownGroup=null,this.$dropdownBtn=null,this.$dropdownContainer=null,this.$displayAllBtn=null,this.$focusGroup=null,this.$focusBtn=null,this.displayAllTrigger="display-all-"+this.id+".responsive-table",this.idPrefix=this.id+"-col-",this.headerColIndices={},this.headerRowIndices={},this.wrapTable(),this.createButtonToolbar(),this.buildHeaderCellIndices(),this.setupTableHeader(),this.setupBodyRows(),this.options.stickyTableHeader&&this.createStickyTableHeader(),this.$dropdownContainer.is(":empty")&&this.$dropdownGroup.hide(),d(window).bind("orientationchange resize "+this.displayAllTrigger,function(){e.$dropdownContainer.find("input").trigger("updateCheck"),d.proxy(e.updateSpanningCells(),e)}).trigger("resize")};a.DEFAULTS={pattern:"priority-columns",stickyTableHeader:!0,fixedNavbar:".navbar.fixed-top",addDisplayAllBtn:!0,addFocusBtn:!0,focusBtnIcon:"fa fa-crosshairs",mainContainer:window,i18n:{focus:"Focus",display:"Display",displayAll:"Display all"}},a.prototype.wrapTable=function(){this.$tableScrollWrapper.wrap('
    '),this.$tableWrapper=this.$tableScrollWrapper.parent()},a.prototype.createButtonToolbar=function(){var t=this;this.$btnToolbar=d('[data-responsive-table-toolbar="'+this.id+'"]').addClass("btn-toolbar justify-content-between"),0===this.$btnToolbar.length&&(this.$btnToolbar=d('
    ')),this.$dropdownGroup=d('