@@ -139,8 +139,11 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
139
139
table . hasClass = {
140
140
noClassInfer : sortableTable . classList . contains ( "no-class-infer" ) ,
141
141
cellsSort : sortableTable . classList . contains ( "cells-sort" ) ,
142
- tableArrows : sortableTable . classList . contains ( "table-arrows" ) ,
143
142
rememberSort : sortableTable . classList . contains ( "remember-sort" ) ,
143
+ // tableArrows: sortableTable.classList.contains("table-arrows"),
144
+ tableArrows : Array . from ( sortableTable . classList ) . filter ( ( item ) =>
145
+ item . includes ( "table-arrows" )
146
+ ) ,
144
147
} ;
145
148
for (
146
149
let headerIndex = 0 ;
@@ -400,37 +403,26 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
400
403
return ;
401
404
}
402
405
403
- function changeTableArrow ( arrowDirection ) {
406
+ function changeArrowAndSort ( arrowDirection , sortDirection ) {
404
407
if ( table . hasClass . tableArrows ) {
405
408
clearArrows ( arrow ) ;
406
409
th . insertAdjacentText ( "beforeend" , arrowDirection ) ;
407
410
}
408
- }
409
-
410
- function sortColumn ( sortDirection ) {
411
411
column . toBeSorted . sort ( sortDirection , {
412
412
numeric : ! isAlphaSort ,
413
413
ignorePunctuation : ! isPunctSort ,
414
414
} ) ;
415
415
}
416
416
417
417
if ( timesClickedColumn === 1 ) {
418
- if ( desc ) {
419
- changeTableArrow ( arrow . down ) ;
420
- sortColumn ( sortDescending ) ;
421
- } else {
422
- changeTableArrow ( arrow . up ) ;
423
- sortColumn ( sortAscending ) ;
424
- }
418
+ desc
419
+ ? changeArrowAndSort ( arrow . down , sortDescending )
420
+ : changeArrowAndSort ( arrow . up , sortAscending ) ;
425
421
} else if ( timesClickedColumn === 2 ) {
426
422
timesClickedColumn = 0 ;
427
- if ( desc ) {
428
- changeTableArrow ( arrow . up ) ;
429
- sortColumn ( sortAscending ) ;
430
- } else {
431
- changeTableArrow ( arrow . down ) ;
432
- sortColumn ( sortDescending ) ;
433
- }
423
+ desc
424
+ ? changeArrowAndSort ( arrow . up , sortAscending )
425
+ : changeArrowAndSort ( arrow . down , sortDescending ) ;
434
426
}
435
427
return timesClickedColumn ;
436
428
}
@@ -524,20 +516,20 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
524
516
columnIndexesClicked
525
517
) {
526
518
const desc = th . classList . contains ( "order-by-desc" ) ;
527
- const custom_arrows = th . classList . contains ( "custom-arrows" ) ;
528
- // for (let word in th.classList) {
529
- // console.log(word);
530
- // }
531
- let arrow = { neutral : " ↕" , up : " ↑" , down : " ↓" } ;
532
519
let fillValue = "!X!Y!Z!" ;
533
- if ( custom_arrows ) {
534
- console . log ( custom_arrows ) ;
535
- console . log ( custom_arrows . split ( "-" ) ) ;
536
- [ arrow . up , arrow . neutral , arrow . down ] = custom_arrows . split ( ) ;
537
- th . classList . add ( "table-arrows" ) ;
538
- }
539
-
540
- if ( table . hasClass . tableArrows ) {
520
+ let arrow = { up : " ↑" , neutral : " ↕" , down : " ↓" } ;
521
+ if ( table . hasClass . tableArrows [ 0 ] ) {
522
+ if ( table . hasClass . tableArrows [ 0 ] . split ( "-" ) . length > 2 ) {
523
+ var customArrow = table . hasClass . tableArrows [ 0 ] . split ( "-" ) [ 2 ] ;
524
+ if ( customArrow . length === 3 ) {
525
+ console . log ( table . hasClass . tableArrows [ 0 ] . split ( "-" ) ) ;
526
+ [ arrow . up , arrow . neutral , arrow . down ] = [
527
+ " " + customArrow [ 0 ] ,
528
+ " " + customArrow [ 1 ] ,
529
+ " " + customArrow [ 2 ] ,
530
+ ] ;
531
+ }
532
+ }
541
533
th . insertAdjacentText ( "beforeend" , arrow . neutral ) ;
542
534
}
543
535
0 commit comments