@@ -56,6 +56,9 @@ document.addEventListener("DOMContentLoaded", function() {
56
56
57
57
// Add input for filtering
58
58
function addInput ( el , label , idx ) {
59
+ const container = document . createElement ( 'div' ) ;
60
+ container . setAttribute ( 'style' , 'display: flex; align-items: center;' ) ;
61
+
59
62
const input = document . createElement ( 'input' ) ;
60
63
input . addEventListener ( "change" , function ( e ) {
61
64
widget . filters [ idx ] = e . target . value ;
@@ -68,15 +71,18 @@ document.addEventListener("DOMContentLoaded", function() {
68
71
input . setAttribute ( 'type' , 'text' ) ;
69
72
input . setAttribute ( 'name' , 'filter_' + label ) ;
70
73
input . setAttribute ( 'list' , 'opts_for_' + label ) ;
71
- el . appendChild ( input ) ;
74
+
75
+ container . appendChild ( input ) ;
76
+ addSortButton ( container , idx ) ;
77
+
78
+ el . appendChild ( container ) ;
72
79
}
73
80
const tbody = el . querySelector ( 'tbody' ) ;
74
81
const headings = Array . from ( el . querySelectorAll ( 'thead th' ) ) . map ( ( el , idx ) => {
75
82
const isSuggested = el . getAttribute ( "data-suggest" ) !== null ;
76
83
const label = el . innerText . toLowerCase ( ) ;
77
84
el . appendChild ( document . createElement ( 'br' ) ) ;
78
85
addInput ( el , label , idx ) ;
79
- addSortButton ( el , idx ) ;
80
86
81
87
if ( isSuggested ) {
82
88
setupDatalist ( el , label , idx ) ;
@@ -104,18 +110,14 @@ document.addEventListener("DOMContentLoaded", function() {
104
110
}); */
105
111
106
112
function addSortButton ( el , idx ) {
107
- const button = document . createElement ( 'button' ) ;
108
113
const img = document . createElement ( 'img' ) ;
109
- button . innerText = 'Sort' ;
110
- button . addEventListener ( "click" , function ( ) {
111
- sortTable ( idx ) ;
112
- } ) ;
113
- img . addEventListener ( "click" , function ( ) {
114
- sortTable ( idx ) ;
115
- } ) ;
116
- button . setAttribute ( 'style' , 'justify-content: center' ) ;
114
+ img . src = "https://uxwing.com/wp-content/themes/uxwing/download/arrow-direction/up-down-arrows-icon.png"
115
+ img . addEventListener ( "click" , function ( ) {
116
+ sortTable ( idx ) ;
117
+ } ) ;
118
+ img . setAttribute ( 'style' , 'width: 16px; margin-left: 5px' )
117
119
118
- el . appendChild ( button ) ;
120
+ el . appendChild ( img )
119
121
}
120
122
121
123
let direction = false ;
0 commit comments