summaryrefslogtreecommitdiff
path: root/resources/assets/js/forms.js
diff options
context:
space:
mode:
authorMichiK <6341204+der-michik@users.noreply.github.com>2018-12-04 21:03:32 +0100
committerMichiK <6341204+der-michik@users.noreply.github.com>2018-12-04 21:03:32 +0100
commit4e3232e57a1b8afde5aa71fb3b1bfd70fcf6ff92 (patch)
tree70af265ca515fdbbd8f73e00f394cf6711ac568e /resources/assets/js/forms.js
parent36b7f8d2a2c732725c8993e1df16d454c0e9d47c (diff)
Replace datepicker and remove datepicker inline JS
Diffstat (limited to 'resources/assets/js/forms.js')
-rw-r--r--resources/assets/js/forms.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/resources/assets/js/forms.js b/resources/assets/js/forms.js
index 13e42d26..f1581907 100644
--- a/resources/assets/js/forms.js
+++ b/resources/assets/js/forms.js
@@ -92,3 +92,36 @@ $(function () {
return ($(window).height() - 50) + 'px';
}).css('overflow-y', 'scroll');
});
+
+/*
+ * Add a datepicker to all date input fields.
+ */
+$(function () {
+ $('.input-group.date').each(function () {
+ var elem = $(this);
+ var opts = {
+ minDate: '',
+ maxDate: '',
+ locale: 'en',
+ format: 'YYYY-MM-DD',
+ widgetPositioning: {horizontal: 'auto', vertical: 'bottom'}
+ };
+ $.extend(opts, elem.data());
+ if (opts.minDate.length === 0) {
+ delete opts.minDate;
+ }
+ if (opts.maxDate.length === 0) {
+ delete opts.maxDate;
+ }
+ elem.children('input').attr('type', 'text');
+ elem.children().on('click', function (ev) {
+ ev.stopImmediatePropagation();
+ if (elem.data('DateTimePicker') === undefined) {
+ elem.datetimepicker(opts);
+ elem.data('DateTimePicker').show();
+ } else {
+ elem.data('DateTimePicker').toggle();
+ }
+ });
+ });
+});