Skip to content

Commit

Permalink
Add x-button to table filter input (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanmahieu committed Oct 25, 2023
1 parent 2aa68e7 commit d0853e6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
19 changes: 18 additions & 1 deletion popup/tableview/popup-common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018. Stephan Mahieu
* Copyright (c) 2023. Stephan Mahieu
*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
Expand Down Expand Up @@ -178,6 +178,23 @@ function adjustSearchBox() {
if (inpSearch) {
const placeholderText = inpSearch.getAttribute("placeholder");
inpSearch.setAttribute("size", placeholderText.length + 2);

addSearchBoxEraseButton();
}
}

function addSearchBoxEraseButton() {
// add erase icon searchbox
if (!$("#fhcTable_filter_erase").length) {
const inpSearchLbl = $($("#fhcTable_filter label")[0]);
if (inpSearchLbl.length) {
inpSearchLbl.append('<div id="fhcTable_filter_erase">X</div>');
$("#fhcTable_filter_erase").on('click', function(event) {
// Event listener for erasing the searchbox
$($("#fhcTable_filter input")[0]).val('').trigger('cut');
return false;
});
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions popup/tableview/theme/table-theme-blue.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#fhcTable_filter input[type=search] {
background: url("search-white.png") no-repeat 3px 3px var(--field-bg-color);
}
#fhcTable_filter_erase {
color: #b6b6b6;
}
::-webkit-input-placeholder {
color: #b6b6b6;
}
Expand Down
3 changes: 3 additions & 0 deletions popup/tableview/theme/table-theme-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#fhcTable_filter input[type=search] {
background: url("search-white.png") no-repeat 3px 3px var(--field-bg-color);
}
#fhcTable_filter_erase {
color: #b6b6b6;
}
::-webkit-input-placeholder {
color: #b6b6b6;
}
Expand Down
3 changes: 3 additions & 0 deletions popup/tableview/theme/table-theme-orange.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#fhcTable_filter input[type=search] {
background: url("search-white.png") no-repeat 3px 3px var(--field-bg-color);
}
#fhcTable_filter_erase {
color: #b6b6b6;
}
::-webkit-input-placeholder {
color: #b6b6b6;
}
Expand Down
10 changes: 10 additions & 0 deletions popup/tableview/theme/table-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ table.dataTable.compact thead td {
transition: min-width 0.4s ease-in-out;
background: url("search-dark.png") no-repeat 3px 3px;
padding-left: 22px;
padding-right: 14px;
padding-top: 1px !important;
padding-bottom: 2px !important;
}
#fhcTable_filter_erase {
display: inline-block;
position: relative;
left: -14px;
font-size: 14px;
color: #434343;
font-weight: bold;
}

#fhcTable_length select {
padding-top: 1px;
padding-bottom: 2px;
Expand Down

0 comments on commit d0853e6

Please sign in to comment.