Skip to content

Commit

Permalink
css cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
liedekef committed Jan 16, 2025
1 parent 455f30e commit 8d8bde5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion css/eme.css
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,9 @@ div#div_import {
}
/* for some fields, only works in chrome for now
* see https://developer.chrome.com/docs/css-ui/css-field-sizing
* fdatepicker fields do this on their own
* */
.eme_formfield_fdatetime, .eme_formfield_fdate, #chooseperson, #eventmail_chooseperson, #chooseevent, .eme_searchfilter, #genericmail_startdate, #eventmail_startdate {
#chooseperson, #eventmail_chooseperson, #chooseevent, .eme_searchfilter {
field-sizing: content;
min-inline-size: 10ch;
}
Expand Down
14 changes: 9 additions & 5 deletions js/fdatepicker/js/fdatepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,18 +794,22 @@
},

_resizeInput: function (input) {
// if the browser supports field-sizing and the field sizing is set to content; we don't need to do anything
if (CSS.supports('field-sizing', 'content') && input.css('field-sizing') === 'content') {
return;
}
if (!this.opts.fieldSizing) {
return;
}

// make sure the empty field has a minimum inline size
if (!(input.val() || input.attr('placeholder')) && input.css('min-inline-size') == "0px") {
input.css({'min-inline-size': '10ch'});
}

// if the browser supports field-sizing, use that
if (CSS.supports('field-sizing', 'content')) {
input.css({'field-sizing': 'content'});
return;
}

// For browsers that don't support field-sizing: fake it
// Create a temporary span to measure the text width
const tempSpan = $('<span>').css({
'font-family': input.css('font-family'),
Expand All @@ -819,7 +823,7 @@
tempSpan.text(input.val() || input.attr('placeholder'));

// Calculate the width and set it to the input
const newWidth = tempSpan.width(); // Adding some padding
const newWidth = tempSpan.width();
input.width(newWidth);

// Remove the temporary span
Expand Down
2 changes: 1 addition & 1 deletion js/fdatepicker/js/fdatepicker.min.js

Large diffs are not rendered by default.

0 comments on commit 8d8bde5

Please sign in to comment.