Skip to content

Commit

Permalink
Replace flatpickr with native datetime inputs
Browse files Browse the repository at this point in the history
The date input library is no longer necessary, as browser datepickers have become mature and handle user language better.
  • Loading branch information
annda committed Dec 5, 2024
1 parent a7779fc commit f3ffce4
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 47 deletions.
13 changes: 0 additions & 13 deletions public/css/flatpickr.min.css

This file was deleted.

7 changes: 0 additions & 7 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,3 @@ initClonability();
tooltips();
initToggles();
tablestyle();

/**
* Init flatpickr
*/
flatpickr('input:read-write[data-calendar-type="date"]', {'dateFormat' : 'd.m.Y', 'allowInput' : true});
flatpickr('input:read-write[data-calendar-type="time"]', {'noCalendar' : true, 'enableTime' : true, 'time_24hr' : true, 'allowInput' : true});
flatpickr('input:read-write[data-calendar-type="datetime"]', {'enableTime' : true, 'time_24hr' : true, 'dateFormat' : 'd.m.Y H:i', 'allowInput' : true});
11 changes: 0 additions & 11 deletions public/js/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ function cloneHandler(e) {
const label = cloned.querySelector('label');
label.setAttribute('for', newId);

const pickr = input.dataset.calendarType;
if (pickr === 'date') {
flatpickr(input, {'dateFormat' : 'd.m.Y', 'allowInput' : true});
}
if (pickr === 'datetime') {
flatpickr(input, {'enableTime' : true, 'time_24hr' : true, 'dateFormat' : 'd.m.Y H:i', 'allowInput' : true});
}
if (pickr === 'time') {
flatpickr(input, {'noCalendar' : true, 'enableTime' : true, 'time_24hr' : true, 'allowInput' : true});
}

elem.parentNode.parentNode.after(cloned);
elem.parentNode.removeChild(elem);
}
Expand Down
2 changes: 0 additions & 2 deletions public/js/flatpickr.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions view/_form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
<link rel="stylesheet" href="/css/bulma.min.css" />
<link rel="stylesheet" href="/css/bulma-tooltip.min.css" />
<link rel="stylesheet" href="/css/app.css" />
<link rel="stylesheet" href="/css/flatpickr.min.css" >
{%- if css is not empty -%}
<link rel="stylesheet" href={{ fileUrl(css) }} >
{% endif %}
<script src="/js/flatpickr.min.js"></script>
<script src="/js/signature_pad.min.js"></script>
</head>
<body>
Expand Down
6 changes: 2 additions & 4 deletions view/date.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
</div>
<div class="control is-cloneable">
<input
type="text"
type="date"
id="{{ id }}-{{ loop.index }}"
name="{{ id }}[]"
value="{{ val }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="date"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand All @@ -46,12 +45,11 @@
</div>
<div class="control">
<input
type="text"
type="date"
id="{{ id }}"
name="{{ id }}"
value="{{ value }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="date"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand Down
6 changes: 2 additions & 4 deletions view/datetime.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
</div>
<div class="control is-cloneable">
<input
type="text"
type="datetime-local"
id="{{ id }}-{{ loop.index }}"
name="{{ id }}[]"
value="{{ val }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="datetime"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand All @@ -46,12 +45,11 @@
</div>
<div class="control">
<input
type="text"
type="datetime-local"
id="{{ id }}"
name="{{ id }}"
value="{{ value }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="datetime"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand Down
6 changes: 2 additions & 4 deletions view/time.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
</div>
<div class="control is-cloneable">
<input
type="text"
type="time"
id="{{ id }}-{{ loop.index }}"
name="{{ id }}[]"
value="{{ val }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="time"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand All @@ -46,12 +45,11 @@
</div>
<div class="control">
<input
type="text"
type="time"
id="{{ id }}"
name="{{ id }}"
value="{{ value }}"
class="input form-input{% if is_readonly%} has-background-grey-lighter{% endif %} {{ errors is not empty ? 'is-danger' }}"
data-calendar-type="time"
{% if is_readonly%}readonly{% endif %}
{% if placeholder is not empty -%}
placeholder="{{ placeholder ~ (is_required and label is empty ? ' *') }}"
Expand Down

0 comments on commit f3ffce4

Please sign in to comment.