table-sort-js
Advanced tools
Comparing version 1.6.8 to 1.6.9
@@ -6,7 +6,8 @@ Repository link: https://github.com/LeeWannacott/table-sort-js | ||
Objectives of table-sort-js: | ||
* Be easy to use (e.g Download one file and just put "table-sort" on table tags to make sortable). | ||
* No dependencies (No jQuery) | ||
* Be able to sort (dates, numbers, alpha,alphanumeric, etc.)(Properly; meaning natural sort) | ||
* Not interfere too much with the css of tables that should be left to the user. | ||
- Be easy to use (e.g Download one file and just put "table-sort" on table tags to make sortable). | ||
- No dependencies (No jQuery) | ||
- Be able to sort (dates, numbers, alpha,alphanumeric, etc.)(Properly; meaning natural sort) | ||
- Not interfere too much with the css of tables that should be left to the user. | ||
You are welcome to open issues or make pull requests. | ||
@@ -20,3 +21,3 @@ | ||
You can modify testTable.js in table-sort-js/src/testTable.js for the feature or | ||
bug request you are testing. You can go to http://localhost:3000/ if you have used npm start. | ||
bug request you are testing. You can go to http://localhost:3000/ if you have used npm start. | ||
@@ -31,2 +32,2 @@ Alternatively download table-sort.js and use your | ||
Feel free to contact me if you need help, or have any questions: | ||
WannacottL@gmail.com | ||
WannacottL@gmail.com |
{ | ||
"name": "table-sort-js", | ||
"version": "1.6.8", | ||
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.", | ||
"name": "table-sort-js", | ||
"version": "1.6.9", | ||
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.", | ||
"license": "MIT", | ||
@@ -27,2 +27,1 @@ "repository": "LeeWannacott/table-sort-js", | ||
} | ||
@@ -15,5 +15,6 @@ ![table-sort-js](https://img.shields.io/npm/v/table-sort-js) | ||
- [npm package.](https://www.npmjs.com/package/table-sort-js) | ||
## Install instructions. | ||
<b>Option 1.</b> Install from npm: ` npm install table-sort-js` | ||
<b>Option 1.</b> Install from npm: ` npm install table-sort-js` | ||
@@ -23,2 +24,3 @@ ```javascript | ||
``` | ||
Refer to the documentation for examples on using table-sort-js with frontend frameworks such as | ||
@@ -29,9 +31,12 @@ [ReactJS.](https://leewannacott.github.io/table-sort-js/docs/react.html) | ||
Then add the following script before your HTML table: | ||
Then add the following script before your HTML table: | ||
```html | ||
<script src="table-sort.js"></script> | ||
``` | ||
Refer to the documenation for examples how to use table-sort-js with [HTML.](https://leewannacott.github.io/table-sort-js/docs/html5.html) | ||
#### To make tables sortable: | ||
#### To make tables sortable: | ||
- Add `class="table-sort"` to HTML <table> tags. | ||
@@ -42,15 +47,16 @@ - Click on table headers to sort columns. | ||
| <table> classes | Description | | ||
| -------------- | ------------------------------------------------ | | ||
| "table-sort" | Make the table sortable! (Words, numbers, dates) | | ||
| "table-arrows" | Display ascending or descending triangles. | | ||
| "remember-sort"| If clicking on different columns remembers sort of the original column. | | ||
| <table> classes | Description | | ||
| --------------------- | ----------------------------------------------------------------------- | | ||
| "table-sort" | Make the table sortable! (Words, numbers, dates) | | ||
| "table-arrows" | Display ascending or descending triangles. | | ||
| "remember-sort" | If clicking on different columns remembers sort of the original column. | | ||
| <th> classes | Description | | ||
| --------------- | ----------------------------------------------------------- | | ||
| "order-by-desc" | Order by descending on first click. (default is aescending) | | ||
| "file-size" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) | | ||
| "data-sort" | Sort by [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), e.g <td data-sort="42"> | | ||
| <th> classes | Description | | ||
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | | ||
| "order-by-desc" | Order by descending on first click. (default is aescending) | | ||
| "file-size" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) | | ||
| "data-sort" | Sort by [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), e.g <td data-sort="42"> | | ||
#### Development: | ||
If you wish to contribute, install instructions can be found [here.](https://leewannacott.github.io/table-sort-js/docs/development.html) |
@@ -331,3 +331,9 @@ /* | ||
const columnData = []; | ||
const tableRows = tableBody.querySelectorAll("tr"); | ||
// To make it work even if there is a tr with display: none; in the table, only the tr that is currently displayed is subject to sorting. | ||
const visibleTableRows = Array.prototype.filter.call( | ||
tableBody.querySelectorAll("tr"), | ||
(tr) => { | ||
return tr.style.display !== "none"; | ||
} | ||
); | ||
@@ -338,3 +344,3 @@ let isDataAttribute = th.classList.contains("data-sort"); | ||
if (isDataAttribute) { | ||
sortDataAttributes(tableRows, columnData); | ||
sortDataAttributes(visibleTableRows, columnData); | ||
} | ||
@@ -345,3 +351,3 @@ | ||
if (isFileSize) { | ||
sortFileSize(tableRows, columnData); | ||
sortFileSize(visibleTableRows, columnData); | ||
} | ||
@@ -358,4 +364,4 @@ | ||
getTableData(tableRows, columnData, isFileSize, isDataAttribute); | ||
updateTable(tableRows, columnData, isFileSize); | ||
getTableData(visibleTableRows, columnData, isFileSize, isDataAttribute); | ||
updateTable(visibleTableRows, columnData, isFileSize); | ||
}); | ||
@@ -362,0 +368,0 @@ } |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
19716
351
59