Transform Search Field
Posted: Wed Sep 06, 2023 1:01 am
Hi,
Sharing Code to transform search field => JS code:
The function can be called from Header or individual form's js.
CSS:
Though might be useful to someone.
Sharing Code to transform search field => JS code:
Code: Select all
function nuTranfomSearchBox() {
$('#nuSearchField,#nuSearchButton,#nuFilter').wrapAll('<div id="nuSeachCombo"></div>');
$("#nuSearchField").attr("placeholder", "Search");
$("#nuSearchField").focus();
$('#nuSearchField').on('input', function() {
if ($(this).val() !== '') {
$(this).addClass('has-value'); // Add a class if the field is not empty
} else {
$(this).removeClass('has-value'); // Remove the class if the field is empty
}
});
}
Code: Select all
if (nuFormType() == 'browse') {
nuTranfomSearchBox();
}
Code: Select all
.nuActionHolder {
height: 2px;
height: auto !important;
width: 100%;
display: flex;
/*flex-wrap: wrap;
*/
gap: 5px;
flex-direction: row;
align-items: baseline
}
#nuSeachCombo {
display: flex;
gap: 0;
order: 1;
}
.nuSearch {
height: 26px;
padding: 0 0 0 10px;
border-radius: 10px 0 0 10px;
margin-left: 10px;
transition: border-color .2s ease;
vertical-align: middle!important;
order: 1;
margin-right: 0;
}
#nuSearchField:empty{
width: 40%;
}
#nuSearchButton {
border-radius: 0 10px 10px 0;
margin-left: 0;
height: 26px;
order: 2;
width:28%;
}
#nuFilter{
order:3;
}
#nuSearchField.has-value, #nuSearchField:focus {
width: 70%;
}