yafowil.widget.datetime 2.0.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yafowil/widget/datetime/__init__.py +192 -0
- yafowil/widget/datetime/example.py +189 -0
- yafowil/widget/datetime/locales/de/LC_MESSAGES/yafowil.widget.datetime.mo +0 -0
- yafowil/widget/datetime/locales/de/LC_MESSAGES/yafowil.widget.datetime.po +56 -0
- yafowil/widget/datetime/locales/en/LC_MESSAGES/yafowil.widget.datetime.mo +0 -0
- yafowil/widget/datetime/locales/en/LC_MESSAGES/yafowil.widget.datetime.po +56 -0
- yafowil/widget/datetime/locales/yafowil.widget.datetime.pot +52 -0
- yafowil/widget/datetime/resources/bootstrap5/datepicker.min.css +1 -0
- yafowil/widget/datetime/resources/bootstrap5/timepicker.min.css +1 -0
- yafowil/widget/datetime/resources/bootstrap5/widget.js +597 -0
- yafowil/widget/datetime/resources/bootstrap5/widget.min.js +1 -0
- yafowil/widget/datetime/resources/default/datepicker.min.css +1 -0
- yafowil/widget/datetime/resources/default/timepicker.min.css +1 -0
- yafowil/widget/datetime/resources/default/widget.js +503 -0
- yafowil/widget/datetime/resources/default/widget.min.js +1 -0
- yafowil/widget/datetime/resources/locales/ar-tn.js +15 -0
- yafowil/widget/datetime/resources/locales/ar.js +15 -0
- yafowil/widget/datetime/resources/locales/az.js +14 -0
- yafowil/widget/datetime/resources/locales/bg.js +14 -0
- yafowil/widget/datetime/resources/locales/bm.js +18 -0
- yafowil/widget/datetime/resources/locales/bn.js +19 -0
- yafowil/widget/datetime/resources/locales/br.js +18 -0
- yafowil/widget/datetime/resources/locales/bs.js +15 -0
- yafowil/widget/datetime/resources/locales/ca.js +18 -0
- yafowil/widget/datetime/resources/locales/cs.js +19 -0
- yafowil/widget/datetime/resources/locales/cy.js +14 -0
- yafowil/widget/datetime/resources/locales/da.js +19 -0
- yafowil/widget/datetime/resources/locales/de.js +18 -0
- yafowil/widget/datetime/resources/locales/el.js +16 -0
- yafowil/widget/datetime/resources/locales/en-AU.js +18 -0
- yafowil/widget/datetime/resources/locales/en-CA.js +18 -0
- yafowil/widget/datetime/resources/locales/en-GB.js +18 -0
- yafowil/widget/datetime/resources/locales/en-IE.js +17 -0
- yafowil/widget/datetime/resources/locales/en-NZ.js +17 -0
- yafowil/widget/datetime/resources/locales/en-ZA.js +17 -0
- yafowil/widget/datetime/resources/locales/eo.js +17 -0
- yafowil/widget/datetime/resources/locales/es.js +18 -0
- yafowil/widget/datetime/resources/locales/et.js +18 -0
- yafowil/widget/datetime/resources/locales/eu.js +18 -0
- yafowil/widget/datetime/resources/locales/fa.js +17 -0
- yafowil/widget/datetime/resources/locales/fi.js +17 -0
- yafowil/widget/datetime/resources/locales/fo.js +15 -0
- yafowil/widget/datetime/resources/locales/fr-CH.js +21 -0
- yafowil/widget/datetime/resources/locales/fr.js +18 -0
- yafowil/widget/datetime/resources/locales/gl.js +16 -0
- yafowil/widget/datetime/resources/locales/he.js +15 -0
- yafowil/widget/datetime/resources/locales/hi.js +18 -0
- yafowil/widget/datetime/resources/locales/hr.js +13 -0
- yafowil/widget/datetime/resources/locales/hu.js +18 -0
- yafowil/widget/datetime/resources/locales/hy.js +18 -0
- yafowil/widget/datetime/resources/locales/id.js +15 -0
- yafowil/widget/datetime/resources/locales/is.js +14 -0
- yafowil/widget/datetime/resources/locales/it-CH.js +20 -0
- yafowil/widget/datetime/resources/locales/it.js +18 -0
- yafowil/widget/datetime/resources/locales/ja.js +17 -0
- yafowil/widget/datetime/resources/locales/ka.js +17 -0
- yafowil/widget/datetime/resources/locales/kk.js +15 -0
- yafowil/widget/datetime/resources/locales/km.js +15 -0
- yafowil/widget/datetime/resources/locales/ko.js +18 -0
- yafowil/widget/datetime/resources/locales/lt.js +19 -0
- yafowil/widget/datetime/resources/locales/lv.js +18 -0
- yafowil/widget/datetime/resources/locales/me.js +17 -0
- yafowil/widget/datetime/resources/locales/mk.js +15 -0
- yafowil/widget/datetime/resources/locales/mn.js +17 -0
- yafowil/widget/datetime/resources/locales/mr.js +18 -0
- yafowil/widget/datetime/resources/locales/ms.js +15 -0
- yafowil/widget/datetime/resources/locales/nl-BE.js +18 -0
- yafowil/widget/datetime/resources/locales/nl.js +18 -0
- yafowil/widget/datetime/resources/locales/no.js +18 -0
- yafowil/widget/datetime/resources/locales/oc.js +17 -0
- yafowil/widget/datetime/resources/locales/pl.js +17 -0
- yafowil/widget/datetime/resources/locales/pt-BR.js +17 -0
- yafowil/widget/datetime/resources/locales/pt.js +18 -0
- yafowil/widget/datetime/resources/locales/ro.js +17 -0
- yafowil/widget/datetime/resources/locales/ru.js +18 -0
- yafowil/widget/datetime/resources/locales/si.js +18 -0
- yafowil/widget/datetime/resources/locales/sk.js +18 -0
- yafowil/widget/datetime/resources/locales/sl.js +15 -0
- yafowil/widget/datetime/resources/locales/sq.js +18 -0
- yafowil/widget/datetime/resources/locales/sr-latn.js +16 -0
- yafowil/widget/datetime/resources/locales/sr.js +16 -0
- yafowil/widget/datetime/resources/locales/sv.js +17 -0
- yafowil/widget/datetime/resources/locales/sw.js +15 -0
- yafowil/widget/datetime/resources/locales/ta.js +18 -0
- yafowil/widget/datetime/resources/locales/tg.js +19 -0
- yafowil/widget/datetime/resources/locales/th.js +14 -0
- yafowil/widget/datetime/resources/locales/tk.js +18 -0
- yafowil/widget/datetime/resources/locales/tr.js +17 -0
- yafowil/widget/datetime/resources/locales/uk.js +17 -0
- yafowil/widget/datetime/resources/locales/uz-cyrl.js +18 -0
- yafowil/widget/datetime/resources/locales/uz-latn.js +18 -0
- yafowil/widget/datetime/resources/locales/vi.js +16 -0
- yafowil/widget/datetime/resources/locales/zh-CN.js +19 -0
- yafowil/widget/datetime/resources/locales/zh-TW.js +18 -0
- yafowil/widget/datetime/resources/vanillajs-datepicker/datepicker.js +2870 -0
- yafowil/widget/datetime/resources/vanillajs-datepicker/datepicker.min.js +1 -0
- yafowil/widget/datetime/tests/test_widget.py +769 -0
- yafowil/widget/datetime/widget.py +531 -0
- yafowil_widget_datetime-2.0.0.dist-info/METADATA +60 -0
- yafowil_widget_datetime-2.0.0.dist-info/RECORD +103 -0
- yafowil_widget_datetime-2.0.0.dist-info/WHEEL +5 -0
- yafowil_widget_datetime-2.0.0.dist-info/entry_points.txt +3 -0
- yafowil_widget_datetime-2.0.0.dist-info/licenses/LICENSE.rst +27 -0
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
var yafowil_datetime = (function (exports, $, Popper) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
class DatepickerWidget extends Datepicker {
|
|
5
|
+
static initialize(context) {
|
|
6
|
+
$('input.datepicker', context).each(function() {
|
|
7
|
+
let elem = $(this);
|
|
8
|
+
if (window.yafowil_array !== undefined &&
|
|
9
|
+
window.yafowil_array.inside_template(elem)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
new DatepickerWidget(elem, elem.data('date-locale'));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
constructor(elem, locale, opts={}) {
|
|
16
|
+
let opts_ = {
|
|
17
|
+
language: locale,
|
|
18
|
+
orientation: 'bottom',
|
|
19
|
+
buttonClass: 'btn',
|
|
20
|
+
todayHighlight: true,
|
|
21
|
+
autohide: true
|
|
22
|
+
};
|
|
23
|
+
let lower_edge = elem.offset().top + elem.outerHeight() + 250;
|
|
24
|
+
if (lower_edge > $(document).height()) {
|
|
25
|
+
opts_.orientation = "top";
|
|
26
|
+
}
|
|
27
|
+
let locale_options = DatepickerWidget.locale_options;
|
|
28
|
+
Object.assign(opts_, locale_options[locale] || locale_options.en);
|
|
29
|
+
Object.assign(opts_, opts);
|
|
30
|
+
super(elem[0], opts_);
|
|
31
|
+
elem.data('yafowil-datepicker', this);
|
|
32
|
+
this.elem = elem;
|
|
33
|
+
this.adapt();
|
|
34
|
+
this.trigger = $(`<button />`)
|
|
35
|
+
.addClass('datepicker-trigger btn btn-outline-secondary')
|
|
36
|
+
.text('...')
|
|
37
|
+
.insertAfter(elem);
|
|
38
|
+
this.toggle_picker = this.toggle_picker.bind(this);
|
|
39
|
+
this.trigger.on('mousedown touchstart', this.toggle_picker);
|
|
40
|
+
this.trigger.on('click', (e) => {e.preventDefault();});
|
|
41
|
+
this.on_change_date = this.on_change_date.bind(this);
|
|
42
|
+
this.elem.on('changeDate', this.on_change_date);
|
|
43
|
+
if (window.ts !== undefined) {
|
|
44
|
+
ts.ajax.attach(this, elem);
|
|
45
|
+
}
|
|
46
|
+
let created_event = $.Event('datepicker_created', {widget: this});
|
|
47
|
+
this.elem.trigger(created_event);
|
|
48
|
+
}
|
|
49
|
+
on_change_date() {
|
|
50
|
+
this.elem.trigger('change');
|
|
51
|
+
}
|
|
52
|
+
adapt() {
|
|
53
|
+
const p_el = $(this.picker.element);
|
|
54
|
+
$('.datepicker-picker', p_el).addClass('card');
|
|
55
|
+
const header = $('.datepicker-header', p_el).addClass('card-header bg-primary');
|
|
56
|
+
$('.btn', header).addClass('btn-primary');
|
|
57
|
+
$('.datepicker-main', p_el).addClass('card-body');
|
|
58
|
+
}
|
|
59
|
+
unload() {
|
|
60
|
+
if (window.ts !== undefined) {
|
|
61
|
+
ts.deprecate(
|
|
62
|
+
'yafowil.widget.datepicker.unload',
|
|
63
|
+
'yafowil.widget.datepicker.destroy',
|
|
64
|
+
'yafowil 2.1'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
this.destroy();
|
|
68
|
+
}
|
|
69
|
+
toggle_picker(evt) {
|
|
70
|
+
evt.preventDefault();
|
|
71
|
+
evt.stopPropagation();
|
|
72
|
+
if (this.picker.active || this.active) {
|
|
73
|
+
this.hide();
|
|
74
|
+
this.elem.blur();
|
|
75
|
+
} else {
|
|
76
|
+
this.show();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
destroy() {
|
|
80
|
+
this.trigger.off('mousedown touchstart', this.toggle_picker);
|
|
81
|
+
this.trigger.off();
|
|
82
|
+
this.elem.off('changeDate', this.on_change_date);
|
|
83
|
+
super.destroy();
|
|
84
|
+
this.elem.off().removeData().remove();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
DatepickerWidget.locale_options = {
|
|
88
|
+
en: {
|
|
89
|
+
weekStart: 1,
|
|
90
|
+
format: 'mm.dd.yyyy'
|
|
91
|
+
},
|
|
92
|
+
de: {
|
|
93
|
+
weekStart: 1,
|
|
94
|
+
format: 'dd.mm.yyyy'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function datepicker_on_array_add(inst, context) {
|
|
98
|
+
DatepickerWidget.initialize(context);
|
|
99
|
+
}
|
|
100
|
+
function register_datepicker_array_subscribers() {
|
|
101
|
+
if (window.yafowil_array === undefined) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
window.yafowil_array.on_array_event('on_add', datepicker_on_array_add);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class TimepickerButton {
|
|
108
|
+
constructor(elem, parent) {
|
|
109
|
+
this.elem = elem;
|
|
110
|
+
this.parent = parent;
|
|
111
|
+
}
|
|
112
|
+
get selected() {
|
|
113
|
+
return this.elem.hasClass('selected');
|
|
114
|
+
}
|
|
115
|
+
set selected(value) {
|
|
116
|
+
if (value) {
|
|
117
|
+
this.parent.remove_previously_selected();
|
|
118
|
+
this.elem.addClass('selected');
|
|
119
|
+
} else {
|
|
120
|
+
this.elem.removeClass('selected');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get previously_selected() {
|
|
124
|
+
return this.elem.hasClass('prev-selected');
|
|
125
|
+
}
|
|
126
|
+
set previously_selected(value) {
|
|
127
|
+
if (value) {
|
|
128
|
+
this.elem.addClass('prev-selected');
|
|
129
|
+
} else {
|
|
130
|
+
this.elem.removeClass('prev-selected');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
class TimepickerButtonContainer {
|
|
135
|
+
constructor(picker, elem) {
|
|
136
|
+
this.picker = picker;
|
|
137
|
+
this.elem = elem;
|
|
138
|
+
this.children = [];
|
|
139
|
+
}
|
|
140
|
+
unload_all() {
|
|
141
|
+
for (let child of this.children) {
|
|
142
|
+
child.elem.off('click', child.on_click);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
unselect_all() {
|
|
146
|
+
for (let child of this.children) {
|
|
147
|
+
child.selected = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
mark_previously_selected() {
|
|
151
|
+
for (let child of this.children) {
|
|
152
|
+
if (child.selected) {
|
|
153
|
+
child.previously_selected = true;
|
|
154
|
+
child.selected = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
remove_previously_selected() {
|
|
159
|
+
for (let child of this.children) {
|
|
160
|
+
child.previously_selected = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
class TimepickerHour extends TimepickerButton {
|
|
165
|
+
constructor(hours, container, value, period) {
|
|
166
|
+
let elem = $('<div />')
|
|
167
|
+
.addClass('cell')
|
|
168
|
+
.text(new String(value).padStart(2, '0'))
|
|
169
|
+
.appendTo(container);
|
|
170
|
+
super(elem, hours);
|
|
171
|
+
this.hours = hours;
|
|
172
|
+
this.picker = hours.picker;
|
|
173
|
+
this.period = period;
|
|
174
|
+
this.on_click = this.on_click.bind(this);
|
|
175
|
+
this.elem.on('click', this.on_click);
|
|
176
|
+
}
|
|
177
|
+
on_click(e) {
|
|
178
|
+
let hour = this.elem.text();
|
|
179
|
+
this.hours.unselect_all();
|
|
180
|
+
this.selected = true;
|
|
181
|
+
this.picker.period = this.period;
|
|
182
|
+
this.picker.hour = hour;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
class TimepickerMinute extends TimepickerButton {
|
|
186
|
+
constructor(minutes, container, value) {
|
|
187
|
+
let elem = $('<div />')
|
|
188
|
+
.addClass('cell')
|
|
189
|
+
.text(new String(value).padStart(2, '0'))
|
|
190
|
+
.appendTo(container);
|
|
191
|
+
super(elem, minutes);
|
|
192
|
+
this.minutes = minutes;
|
|
193
|
+
this.picker = minutes.picker;
|
|
194
|
+
this.on_click = this.on_click.bind(this);
|
|
195
|
+
this.elem.on('click', this.on_click);
|
|
196
|
+
}
|
|
197
|
+
on_click(e) {
|
|
198
|
+
this.minutes.unselect_all();
|
|
199
|
+
this.selected = true;
|
|
200
|
+
this.picker.minute = this.elem.text();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
class TimepickerHours extends TimepickerButtonContainer {
|
|
204
|
+
constructor(picker, container) {
|
|
205
|
+
super(picker, $('<div />').addClass('card-body hours-content'));
|
|
206
|
+
if (picker.clock === 24) {
|
|
207
|
+
this.create_clock_24();
|
|
208
|
+
} else if (picker.clock === 12) {
|
|
209
|
+
this.create_clock_12();
|
|
210
|
+
}
|
|
211
|
+
this.to_minute = this.to_minute.bind(this);
|
|
212
|
+
let header = $('<div />')
|
|
213
|
+
.addClass('header card-header bg-primary text-white')
|
|
214
|
+
.text(picker.translate('hour'));
|
|
215
|
+
this.minutes_btn = $('<button />')
|
|
216
|
+
.append($('<i class="bi bi-caret-right"/>'))
|
|
217
|
+
.append($('<span>Minute</span>'))
|
|
218
|
+
.addClass('to_minutes d-block d-sm-none btn p-0 float-end')
|
|
219
|
+
.on('click', this.to_minute)
|
|
220
|
+
.appendTo(header);
|
|
221
|
+
this.container_elem = $('<div />')
|
|
222
|
+
.addClass('card timepicker-hours')
|
|
223
|
+
.append(header)
|
|
224
|
+
.append(this.elem)
|
|
225
|
+
.appendTo(container);
|
|
226
|
+
}
|
|
227
|
+
create_clock_24() {
|
|
228
|
+
for (let i = 0; i < 24; i++) {
|
|
229
|
+
this.children.push(new TimepickerHour(this, this.elem, i));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
create_clock_12() {
|
|
233
|
+
$('<span />').addClass('am').text('A.M.').appendTo(this.elem);
|
|
234
|
+
let hours_am = $('<div />').addClass('am').appendTo(this.elem);
|
|
235
|
+
$('<span />').addClass('pm').text('P.M.').appendTo(this.elem);
|
|
236
|
+
let hours_pm = $('<div />').addClass('pm').appendTo(this.elem);
|
|
237
|
+
for (let i = 0; i < 12; i++) {
|
|
238
|
+
this.children.push(new TimepickerHour(this, hours_am, i, 'AM'));
|
|
239
|
+
}
|
|
240
|
+
for (let i = 0; i < 12; i++) {
|
|
241
|
+
this.children.push(new TimepickerHour(this, hours_pm, i, 'PM'));
|
|
242
|
+
}
|
|
243
|
+
this.elem.css('grid-template-rows', '1fr 1fr');
|
|
244
|
+
this.elem.css('grid-template-columns', 'auto 1fr');
|
|
245
|
+
}
|
|
246
|
+
to_minute(e) {
|
|
247
|
+
e.preventDefault();
|
|
248
|
+
this.container_elem.hide();
|
|
249
|
+
this.picker.minutes.container_elem.show();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
class TimepickerMinutes extends TimepickerButtonContainer {
|
|
253
|
+
constructor(picker, container, step) {
|
|
254
|
+
super(picker, $('<div />').addClass('card-body minutes-content'));
|
|
255
|
+
this.step = step;
|
|
256
|
+
let count = 60 / step;
|
|
257
|
+
let columns = 0;
|
|
258
|
+
if (count <= 32) {
|
|
259
|
+
columns = Math.ceil(count / 4);
|
|
260
|
+
let cols = '1fr '.repeat(Math.ceil(count / 4));
|
|
261
|
+
this.elem.css(
|
|
262
|
+
'grid-template-columns',
|
|
263
|
+
cols
|
|
264
|
+
);
|
|
265
|
+
} else {
|
|
266
|
+
columns = 10;
|
|
267
|
+
this.elem.css(
|
|
268
|
+
'grid-template-columns',
|
|
269
|
+
'1fr '.repeat(10)
|
|
270
|
+
);
|
|
271
|
+
if (picker.clock === 24) {
|
|
272
|
+
$('div.hours-content', picker.dd_elem).css({
|
|
273
|
+
'grid-template-columns': '1fr 1fr 1fr 1fr'
|
|
274
|
+
});
|
|
275
|
+
} else {
|
|
276
|
+
$('div.am, div.pm', picker.dd_elem).css({
|
|
277
|
+
'grid-template-columns': '1fr 1fr 1fr 1fr'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
this.columns_count = columns;
|
|
282
|
+
for (let i = 0; i < count; i++) {
|
|
283
|
+
this.children.push(new TimepickerMinute(this, this.elem, i * step));
|
|
284
|
+
}
|
|
285
|
+
this.to_hour = this.to_hour.bind(this);
|
|
286
|
+
let header = $('<div />')
|
|
287
|
+
.addClass('header card-header bg-primary text-white')
|
|
288
|
+
.text(picker.translate('minute'));
|
|
289
|
+
this.hours_btn = $('<button />')
|
|
290
|
+
.append($('<i class="bi bi-caret-left"/>'))
|
|
291
|
+
.append($('<span>Hour</span>'))
|
|
292
|
+
.addClass('to_hours d-block d-sm-none btn p-0 float-end')
|
|
293
|
+
.on('click', this.to_hour)
|
|
294
|
+
.appendTo(header);
|
|
295
|
+
this.container_elem = $('<div />')
|
|
296
|
+
.addClass('card timepicker-minutes')
|
|
297
|
+
.append(header)
|
|
298
|
+
.append(this.elem)
|
|
299
|
+
.appendTo(container);
|
|
300
|
+
}
|
|
301
|
+
to_hour(e) {
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
this.container_elem.hide();
|
|
304
|
+
this.picker.hours.container_elem.show();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
class TimepickerWidget {
|
|
308
|
+
static initialize(context) {
|
|
309
|
+
$('input.timepicker', context).each(function() {
|
|
310
|
+
let elem = $(this);
|
|
311
|
+
if (window.yafowil_array !== undefined &&
|
|
312
|
+
window.yafowil_array.inside_template(elem)) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
elem.attr('spellcheck', false);
|
|
316
|
+
new TimepickerWidget(elem, {
|
|
317
|
+
language: elem.data('time-locale'),
|
|
318
|
+
clock: elem.data('time-clock'),
|
|
319
|
+
step: elem.data('time-minutes_step')
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
constructor(elem, opts) {
|
|
324
|
+
elem.data('yafowil-timepicker', this);
|
|
325
|
+
this.elem = elem;
|
|
326
|
+
this.language = opts.language || 'en';
|
|
327
|
+
this.clock = opts.clock || 24;
|
|
328
|
+
this.period = null;
|
|
329
|
+
this.hour = '';
|
|
330
|
+
this.minute = '';
|
|
331
|
+
if (opts.step <= 0 || opts.step > 60 || typeof opts.step !== 'number') {
|
|
332
|
+
this.step = 5;
|
|
333
|
+
} else {
|
|
334
|
+
this.step = opts.step;
|
|
335
|
+
}
|
|
336
|
+
this.trigger_elem = $('<button />')
|
|
337
|
+
.addClass('timepicker-trigger btn btn-outline-secondary')
|
|
338
|
+
.text('...')
|
|
339
|
+
.insertAfter(elem);
|
|
340
|
+
let dd_elem = this.dd_elem = $('<div />')
|
|
341
|
+
.addClass('timepicker-dropdown')
|
|
342
|
+
.insertAfter(elem.closest('.input-group'));
|
|
343
|
+
let dd_container = $('<div />')
|
|
344
|
+
.addClass('timepicker-container card-group shadow')
|
|
345
|
+
.appendTo(dd_elem);
|
|
346
|
+
this.hours = new TimepickerHours(this, dd_container);
|
|
347
|
+
this.minutes = new TimepickerMinutes(this, dd_container, this.step);
|
|
348
|
+
this.calc_flex_basis(this.minutes.columns_count);
|
|
349
|
+
this.validate();
|
|
350
|
+
this.show_dropdown = this.show_dropdown.bind(this);
|
|
351
|
+
this.elem.on('focus', this.show_dropdown);
|
|
352
|
+
this.toggle_dropdown = this.toggle_dropdown.bind(this);
|
|
353
|
+
this.trigger_elem.on('click', this.toggle_dropdown);
|
|
354
|
+
this.hide_dropdown = this.hide_dropdown.bind(this);
|
|
355
|
+
$(document).on('click', this.hide_dropdown);
|
|
356
|
+
this.on_keypress = this.on_keypress.bind(this);
|
|
357
|
+
this.elem.on('keypress', this.on_keypress);
|
|
358
|
+
this.validate = this.validate.bind(this);
|
|
359
|
+
this.elem.on('keyup', this.validate);
|
|
360
|
+
this.popper = Popper.createPopper(this.elem[0], this.dd_elem[0], {
|
|
361
|
+
placement: "bottom-start",
|
|
362
|
+
modifiers: [
|
|
363
|
+
{
|
|
364
|
+
name: 'preventOverflow',
|
|
365
|
+
options: {
|
|
366
|
+
boundary: 'viewport',
|
|
367
|
+
padding: 10,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "flip",
|
|
372
|
+
options: {
|
|
373
|
+
allowedAutoPlacements: ["top-start", "bottom-start"],
|
|
374
|
+
rootBoundary: "viewport"
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
});
|
|
379
|
+
let created_event = $.Event('timepicker_created', {widget: this});
|
|
380
|
+
this.elem.trigger(created_event);
|
|
381
|
+
if (window.ts !== undefined) {
|
|
382
|
+
window.ts.ajax.attach(this, elem);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
calc_flex_basis(minutesColumns) {
|
|
386
|
+
let hoursColumns = 6;
|
|
387
|
+
if (60 / this.step > 32) {
|
|
388
|
+
if (this.clock === 24) {
|
|
389
|
+
hoursColumns = 4;
|
|
390
|
+
} else {
|
|
391
|
+
hoursColumns = 5;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (minutesColumns < 2) {
|
|
395
|
+
minutesColumns = 2;
|
|
396
|
+
}
|
|
397
|
+
const total_columns = hoursColumns + minutesColumns;
|
|
398
|
+
const hoursFlexBasis = (hoursColumns / total_columns) * 100;
|
|
399
|
+
const minutesFlexBasis = (minutesColumns / total_columns) * 100;
|
|
400
|
+
this.hours.container_elem.css('flex-basis', hoursFlexBasis.toFixed(2) + '%');
|
|
401
|
+
this.minutes.container_elem.css('flex-basis', minutesFlexBasis.toFixed(2) + '%');
|
|
402
|
+
const containerWidth = `calc(${total_columns * 40}px + 4rem)`;
|
|
403
|
+
this.dd_elem.css('width', containerWidth);
|
|
404
|
+
}
|
|
405
|
+
unload() {
|
|
406
|
+
if (window.ts !== undefined) {
|
|
407
|
+
ts.deprecate(
|
|
408
|
+
'yafowil.widget.timepicker.unload',
|
|
409
|
+
'yafowil.widget.timepicker.destroy',
|
|
410
|
+
'yafowil 2.1'
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
this.destroy();
|
|
414
|
+
}
|
|
415
|
+
get hour() {
|
|
416
|
+
return this._hour;
|
|
417
|
+
}
|
|
418
|
+
set hour(hour) {
|
|
419
|
+
this._hour = hour;
|
|
420
|
+
this.set_time();
|
|
421
|
+
}
|
|
422
|
+
get minute() {
|
|
423
|
+
return this._minute;
|
|
424
|
+
}
|
|
425
|
+
set minute(minute) {
|
|
426
|
+
this._minute = minute;
|
|
427
|
+
this.set_time();
|
|
428
|
+
}
|
|
429
|
+
set_time() {
|
|
430
|
+
if (this.hour === '' || this.minute === '') {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (this.clock === 24) {
|
|
434
|
+
this.elem.val(`${this.hour}:${this.minute}`);
|
|
435
|
+
} else if (this.clock === 12) {
|
|
436
|
+
this.elem.val(`${this.hour}:${this.minute}${this.period}`);
|
|
437
|
+
}
|
|
438
|
+
this.elem.trigger('change');
|
|
439
|
+
this.hour = '';
|
|
440
|
+
this.minute = '';
|
|
441
|
+
this.hours.mark_previously_selected();
|
|
442
|
+
this.minutes.mark_previously_selected();
|
|
443
|
+
if ($(window).width() <= 575) {
|
|
444
|
+
this.reset_visibility();
|
|
445
|
+
}
|
|
446
|
+
this.dd_elem.hide();
|
|
447
|
+
}
|
|
448
|
+
reset_visibility() {
|
|
449
|
+
this.hours.container_elem.show();
|
|
450
|
+
this.minutes.container_elem.hide();
|
|
451
|
+
}
|
|
452
|
+
hide_dropdown(e) {
|
|
453
|
+
if (e.target !== this.elem[0] && e.target !== this.trigger_elem[0]) {
|
|
454
|
+
if ($(e.target).closest(this.dd_elem).length === 0) {
|
|
455
|
+
this.dd_elem.hide();
|
|
456
|
+
if (this.hour === '' || this.minute === '') {
|
|
457
|
+
this._hour = '';
|
|
458
|
+
this._minute = '';
|
|
459
|
+
}
|
|
460
|
+
this.hours.unselect_all();
|
|
461
|
+
this.minutes.unselect_all();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
show_dropdown(e) {
|
|
466
|
+
this.dd_elem.show();
|
|
467
|
+
this.popper.forceUpdate();
|
|
468
|
+
}
|
|
469
|
+
toggle_dropdown(e) {
|
|
470
|
+
e.preventDefault();
|
|
471
|
+
this.dd_elem.toggle();
|
|
472
|
+
this.popper.forceUpdate();
|
|
473
|
+
}
|
|
474
|
+
on_keypress(e) {
|
|
475
|
+
e.preventDefault();
|
|
476
|
+
let val = this.elem.val();
|
|
477
|
+
let cursor_pos = e.target.selectionStart;
|
|
478
|
+
if (e.key === 'Enter') {
|
|
479
|
+
this.dd_elem.hide();
|
|
480
|
+
this.elem.blur();
|
|
481
|
+
}
|
|
482
|
+
if (cursor_pos <= 4) {
|
|
483
|
+
if (e.key.match(new RegExp('[0-9]'))) {
|
|
484
|
+
this.elem.val(val + e.key);
|
|
485
|
+
if (cursor_pos === 2) {
|
|
486
|
+
this.elem.val(`${val}:${e.key}`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
} else if (cursor_pos === 5 && this.clock === 12) {
|
|
490
|
+
let correct = ['a', 'A', 'p', 'P'];
|
|
491
|
+
if (correct.includes(e.key)) {
|
|
492
|
+
this.elem.val(val + e.key);
|
|
493
|
+
}
|
|
494
|
+
} else if (cursor_pos === 6 && this.clock === 12) {
|
|
495
|
+
if (e.key === 'm' || e.key === 'M') {
|
|
496
|
+
this.elem.val(val + e.key);
|
|
497
|
+
}
|
|
498
|
+
} }
|
|
499
|
+
validate() {
|
|
500
|
+
if (!this.elem.val()) return;
|
|
501
|
+
let time = this.elem.val(),
|
|
502
|
+
match_24 = new RegExp(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/),
|
|
503
|
+
match_12 = new RegExp(/^(?:0?\d|1[012]):[0-5]\d[apAP][mM]$/),
|
|
504
|
+
hour = time.substr(0, 2),
|
|
505
|
+
hour_index = parseInt(hour),
|
|
506
|
+
minute = time.substr(3, 2),
|
|
507
|
+
minute_index = parseInt(minute) / this.step;
|
|
508
|
+
if (this.clock === 24) {
|
|
509
|
+
if (!time.match(match_24) || time.length < 5) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
} else if (this.clock === 12) {
|
|
513
|
+
if (!time.match(match_12) || time.length < 7) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
let period = time.substr(5).toUpperCase();
|
|
517
|
+
this.period = (period === 'PM') ? 'PM' : 'AM';
|
|
518
|
+
if (period === 'PM') hour_index += 12;
|
|
519
|
+
}
|
|
520
|
+
let hour_elem = this.hours.children[hour_index];
|
|
521
|
+
hour_elem.on_click();
|
|
522
|
+
let minute_elem = this.minutes.children[minute_index];
|
|
523
|
+
if (minute_elem) {
|
|
524
|
+
minute_elem.on_click();
|
|
525
|
+
} else {
|
|
526
|
+
this.minutes.unselect_all();
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
translate(msgid) {
|
|
530
|
+
let locales = this.constructor.locales,
|
|
531
|
+
locale = locales[this.language] || locales.en;
|
|
532
|
+
return locale[msgid];
|
|
533
|
+
}
|
|
534
|
+
destroy() {
|
|
535
|
+
$(document).off('click', this.hide_dropdown);
|
|
536
|
+
this.popper.destroy();
|
|
537
|
+
this.hours.unload_all();
|
|
538
|
+
this.minutes.unload_all();
|
|
539
|
+
this.dd_elem.remove();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
TimepickerWidget.locales = {
|
|
543
|
+
en: {
|
|
544
|
+
hour: 'Hour',
|
|
545
|
+
minute: 'Minute'
|
|
546
|
+
},
|
|
547
|
+
de: {
|
|
548
|
+
hour: 'Stunde',
|
|
549
|
+
minute: 'Minute'
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
function timepicker_on_array_add(inst, context) {
|
|
553
|
+
TimepickerWidget.initialize(context);
|
|
554
|
+
}
|
|
555
|
+
function register_timepicker_array_subscribers() {
|
|
556
|
+
if (window.yafowil_array === undefined) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
window.yafowil_array.on_array_event('on_add', timepicker_on_array_add);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
$(function() {
|
|
563
|
+
if (window.ts !== undefined) {
|
|
564
|
+
ts.ajax.register(DatepickerWidget.initialize, true);
|
|
565
|
+
ts.ajax.register(TimepickerWidget.initialize, true);
|
|
566
|
+
} else if (window.bdajax !== undefined) {
|
|
567
|
+
bdajax.register(DatepickerWidget.initialize, true);
|
|
568
|
+
bdajax.register(TimepickerWidget.initialize, true);
|
|
569
|
+
} else {
|
|
570
|
+
DatepickerWidget.initialize();
|
|
571
|
+
TimepickerWidget.initialize();
|
|
572
|
+
}
|
|
573
|
+
register_datepicker_array_subscribers();
|
|
574
|
+
register_timepicker_array_subscribers();
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
exports.DatepickerWidget = DatepickerWidget;
|
|
578
|
+
exports.TimepickerButton = TimepickerButton;
|
|
579
|
+
exports.TimepickerButtonContainer = TimepickerButtonContainer;
|
|
580
|
+
exports.TimepickerHour = TimepickerHour;
|
|
581
|
+
exports.TimepickerHours = TimepickerHours;
|
|
582
|
+
exports.TimepickerMinute = TimepickerMinute;
|
|
583
|
+
exports.TimepickerMinutes = TimepickerMinutes;
|
|
584
|
+
exports.TimepickerWidget = TimepickerWidget;
|
|
585
|
+
exports.register_datepicker_array_subscribers = register_datepicker_array_subscribers;
|
|
586
|
+
exports.register_timepicker_array_subscribers = register_timepicker_array_subscribers;
|
|
587
|
+
|
|
588
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
window.yafowil = window.yafowil || {};
|
|
592
|
+
window.yafowil.datetime = exports;
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
return exports;
|
|
596
|
+
|
|
597
|
+
})({}, jQuery, Popper);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var yafowil_datetime=function(e,t,i){"use strict";class s extends Datepicker{static initialize(e){t("input.datepicker",e).each((function(){let e=t(this);void 0!==window.yafowil_array&&window.yafowil_array.inside_template(e)||new s(e,e.data("date-locale"))}))}constructor(e,i,r={}){let o={language:i,orientation:"bottom",buttonClass:"btn",todayHighlight:!0,autohide:!0};e.offset().top+e.outerHeight()+250>t(document).height()&&(o.orientation="top");let a=s.locale_options;Object.assign(o,a[i]||a.en),Object.assign(o,r),super(e[0],o),e.data("yafowil-datepicker",this),this.elem=e,this.adapt(),this.trigger=t("<button />").addClass("datepicker-trigger btn btn-outline-secondary").text("...").insertAfter(e),this.toggle_picker=this.toggle_picker.bind(this),this.trigger.on("mousedown touchstart",this.toggle_picker),this.trigger.on("click",(e=>{e.preventDefault()})),this.on_change_date=this.on_change_date.bind(this),this.elem.on("changeDate",this.on_change_date),void 0!==window.ts&&ts.ajax.attach(this,e);let l=t.Event("datepicker_created",{widget:this});this.elem.trigger(l)}on_change_date(){this.elem.trigger("change")}adapt(){const e=t(this.picker.element);t(".datepicker-picker",e).addClass("card");const i=t(".datepicker-header",e).addClass("card-header bg-primary");t(".btn",i).addClass("btn-primary"),t(".datepicker-main",e).addClass("card-body")}unload(){void 0!==window.ts&&ts.deprecate("yafowil.widget.datepicker.unload","yafowil.widget.datepicker.destroy","yafowil 2.1"),this.destroy()}toggle_picker(e){e.preventDefault(),e.stopPropagation(),this.picker.active||this.active?(this.hide(),this.elem.blur()):this.show()}destroy(){this.trigger.off("mousedown touchstart",this.toggle_picker),this.trigger.off(),this.elem.off("changeDate",this.on_change_date),super.destroy(),this.elem.off().removeData().remove()}}function r(e,t){s.initialize(t)}function o(){void 0!==window.yafowil_array&&window.yafowil_array.on_array_event("on_add",r)}s.locale_options={en:{weekStart:1,format:"mm.dd.yyyy"},de:{weekStart:1,format:"dd.mm.yyyy"}};class a{constructor(e,t){this.elem=e,this.parent=t}get selected(){return this.elem.hasClass("selected")}set selected(e){e?(this.parent.remove_previously_selected(),this.elem.addClass("selected")):this.elem.removeClass("selected")}get previously_selected(){return this.elem.hasClass("prev-selected")}set previously_selected(e){e?this.elem.addClass("prev-selected"):this.elem.removeClass("prev-selected")}}class l{constructor(e,t){this.picker=e,this.elem=t,this.children=[]}unload_all(){for(let e of this.children)e.elem.off("click",e.on_click)}unselect_all(){for(let e of this.children)e.selected=!1}mark_previously_selected(){for(let e of this.children)e.selected&&(e.previously_selected=!0,e.selected=!1)}remove_previously_selected(){for(let e of this.children)e.previously_selected=!1}}class n extends a{constructor(e,i,s,r){super(t("<div />").addClass("cell").text(new String(s).padStart(2,"0")).appendTo(i),e),this.hours=e,this.picker=e.picker,this.period=r,this.on_click=this.on_click.bind(this),this.elem.on("click",this.on_click)}on_click(e){let t=this.elem.text();this.hours.unselect_all(),this.selected=!0,this.picker.period=this.period,this.picker.hour=t}}class d extends a{constructor(e,i,s){super(t("<div />").addClass("cell").text(new String(s).padStart(2,"0")).appendTo(i),e),this.minutes=e,this.picker=e.picker,this.on_click=this.on_click.bind(this),this.elem.on("click",this.on_click)}on_click(e){this.minutes.unselect_all(),this.selected=!0,this.picker.minute=this.elem.text()}}class h extends l{constructor(e,i){super(e,t("<div />").addClass("card-body hours-content")),24===e.clock?this.create_clock_24():12===e.clock&&this.create_clock_12(),this.to_minute=this.to_minute.bind(this);let s=t("<div />").addClass("header card-header bg-primary text-white").text(e.translate("hour"));this.minutes_btn=t("<button />").append(t('<i class="bi bi-caret-right"/>')).append(t("<span>Minute</span>")).addClass("to_minutes d-block d-sm-none btn p-0 float-end").on("click",this.to_minute).appendTo(s),this.container_elem=t("<div />").addClass("card timepicker-hours").append(s).append(this.elem).appendTo(i)}create_clock_24(){for(let e=0;e<24;e++)this.children.push(new n(this,this.elem,e))}create_clock_12(){t("<span />").addClass("am").text("A.M.").appendTo(this.elem);let e=t("<div />").addClass("am").appendTo(this.elem);t("<span />").addClass("pm").text("P.M.").appendTo(this.elem);let i=t("<div />").addClass("pm").appendTo(this.elem);for(let t=0;t<12;t++)this.children.push(new n(this,e,t,"AM"));for(let e=0;e<12;e++)this.children.push(new n(this,i,e,"PM"));this.elem.css("grid-template-rows","1fr 1fr"),this.elem.css("grid-template-columns","auto 1fr")}to_minute(e){e.preventDefault(),this.container_elem.hide(),this.picker.minutes.container_elem.show()}}class c extends l{constructor(e,i,s){super(e,t("<div />").addClass("card-body minutes-content")),this.step=s;let r=60/s,o=0;if(r<=32){o=Math.ceil(r/4);let e="1fr ".repeat(Math.ceil(r/4));this.elem.css("grid-template-columns",e)}else o=10,this.elem.css("grid-template-columns","1fr ".repeat(10)),24===e.clock?t("div.hours-content",e.dd_elem).css({"grid-template-columns":"1fr 1fr 1fr 1fr"}):t("div.am, div.pm",e.dd_elem).css({"grid-template-columns":"1fr 1fr 1fr 1fr"});this.columns_count=o;for(let e=0;e<r;e++)this.children.push(new d(this,this.elem,e*s));this.to_hour=this.to_hour.bind(this);let a=t("<div />").addClass("header card-header bg-primary text-white").text(e.translate("minute"));this.hours_btn=t("<button />").append(t('<i class="bi bi-caret-left"/>')).append(t("<span>Hour</span>")).addClass("to_hours d-block d-sm-none btn p-0 float-end").on("click",this.to_hour).appendTo(a),this.container_elem=t("<div />").addClass("card timepicker-minutes").append(a).append(this.elem).appendTo(i)}to_hour(e){e.preventDefault(),this.container_elem.hide(),this.picker.hours.container_elem.show()}}class p{static initialize(e){t("input.timepicker",e).each((function(){let e=t(this);void 0!==window.yafowil_array&&window.yafowil_array.inside_template(e)||(e.attr("spellcheck",!1),new p(e,{language:e.data("time-locale"),clock:e.data("time-clock"),step:e.data("time-minutes_step")}))}))}constructor(e,s){e.data("yafowil-timepicker",this),this.elem=e,this.language=s.language||"en",this.clock=s.clock||24,this.period=null,this.hour="",this.minute="",s.step<=0||s.step>60||"number"!=typeof s.step?this.step=5:this.step=s.step,this.trigger_elem=t("<button />").addClass("timepicker-trigger btn btn-outline-secondary").text("...").insertAfter(e);let r=this.dd_elem=t("<div />").addClass("timepicker-dropdown").insertAfter(e.closest(".input-group")),o=t("<div />").addClass("timepicker-container card-group shadow").appendTo(r);this.hours=new h(this,o),this.minutes=new c(this,o,this.step),this.calc_flex_basis(this.minutes.columns_count),this.validate(),this.show_dropdown=this.show_dropdown.bind(this),this.elem.on("focus",this.show_dropdown),this.toggle_dropdown=this.toggle_dropdown.bind(this),this.trigger_elem.on("click",this.toggle_dropdown),this.hide_dropdown=this.hide_dropdown.bind(this),t(document).on("click",this.hide_dropdown),this.on_keypress=this.on_keypress.bind(this),this.elem.on("keypress",this.on_keypress),this.validate=this.validate.bind(this),this.elem.on("keyup",this.validate),this.popper=i.createPopper(this.elem[0],this.dd_elem[0],{placement:"bottom-start",modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:10}},{name:"flip",options:{allowedAutoPlacements:["top-start","bottom-start"],rootBoundary:"viewport"}}]});let a=t.Event("timepicker_created",{widget:this});this.elem.trigger(a),void 0!==window.ts&&window.ts.ajax.attach(this,e)}calc_flex_basis(e){let t=6;60/this.step>32&&(t=24===this.clock?4:5),e<2&&(e=2);const i=t+e,s=t/i*100,r=e/i*100;this.hours.container_elem.css("flex-basis",s.toFixed(2)+"%"),this.minutes.container_elem.css("flex-basis",r.toFixed(2)+"%");const o=`calc(${40*i}px + 4rem)`;this.dd_elem.css("width",o)}unload(){void 0!==window.ts&&ts.deprecate("yafowil.widget.timepicker.unload","yafowil.widget.timepicker.destroy","yafowil 2.1"),this.destroy()}get hour(){return this._hour}set hour(e){this._hour=e,this.set_time()}get minute(){return this._minute}set minute(e){this._minute=e,this.set_time()}set_time(){""!==this.hour&&""!==this.minute&&(24===this.clock?this.elem.val(`${this.hour}:${this.minute}`):12===this.clock&&this.elem.val(`${this.hour}:${this.minute}${this.period}`),this.elem.trigger("change"),this.hour="",this.minute="",this.hours.mark_previously_selected(),this.minutes.mark_previously_selected(),t(window).width()<=575&&this.reset_visibility(),this.dd_elem.hide())}reset_visibility(){this.hours.container_elem.show(),this.minutes.container_elem.hide()}hide_dropdown(e){e.target!==this.elem[0]&&e.target!==this.trigger_elem[0]&&0===t(e.target).closest(this.dd_elem).length&&(this.dd_elem.hide(),""!==this.hour&&""!==this.minute||(this._hour="",this._minute=""),this.hours.unselect_all(),this.minutes.unselect_all())}show_dropdown(e){this.dd_elem.show(),this.popper.forceUpdate()}toggle_dropdown(e){e.preventDefault(),this.dd_elem.toggle(),this.popper.forceUpdate()}on_keypress(e){e.preventDefault();let t=this.elem.val(),i=e.target.selectionStart;if("Enter"===e.key&&(this.dd_elem.hide(),this.elem.blur()),i<=4)e.key.match(new RegExp("[0-9]"))&&(this.elem.val(t+e.key),2===i&&this.elem.val(`${t}:${e.key}`));else if(5===i&&12===this.clock){["a","A","p","P"].includes(e.key)&&this.elem.val(t+e.key)}else 6===i&&12===this.clock&&("m"!==e.key&&"M"!==e.key||this.elem.val(t+e.key))}validate(){if(!this.elem.val())return;let e=this.elem.val(),t=new RegExp(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/),i=new RegExp(/^(?:0?\d|1[012]):[0-5]\d[apAP][mM]$/),s=e.substr(0,2),r=parseInt(s),o=e.substr(3,2),a=parseInt(o)/this.step;if(24===this.clock){if(!e.match(t)||e.length<5)return}else if(12===this.clock){if(!e.match(i)||e.length<7)return;let t=e.substr(5).toUpperCase();this.period="PM"===t?"PM":"AM","PM"===t&&(r+=12)}this.hours.children[r].on_click();let l=this.minutes.children[a];l?l.on_click():this.minutes.unselect_all()}translate(e){let t=this.constructor.locales;return(t[this.language]||t.en)[e]}destroy(){t(document).off("click",this.hide_dropdown),this.popper.destroy(),this.hours.unload_all(),this.minutes.unload_all(),this.dd_elem.remove()}}function m(e,t){p.initialize(t)}function u(){void 0!==window.yafowil_array&&window.yafowil_array.on_array_event("on_add",m)}return p.locales={en:{hour:"Hour",minute:"Minute"},de:{hour:"Stunde",minute:"Minute"}},t((function(){void 0!==window.ts?(ts.ajax.register(s.initialize,!0),ts.ajax.register(p.initialize,!0)):void 0!==window.bdajax?(bdajax.register(s.initialize,!0),bdajax.register(p.initialize,!0)):(s.initialize(),p.initialize()),o(),u()})),e.DatepickerWidget=s,e.TimepickerButton=a,e.TimepickerButtonContainer=l,e.TimepickerHour=n,e.TimepickerHours=h,e.TimepickerMinute=d,e.TimepickerMinutes=c,e.TimepickerWidget=p,e.register_datepicker_array_subscribers=o,e.register_timepicker_array_subscribers=u,Object.defineProperty(e,"__esModule",{value:!0}),window.yafowil=window.yafowil||{},window.yafowil.datetime=e,e}({},jQuery,Popper);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
input.dateinput{display:inline-block;margin-right:45px}button.datepicker-trigger{height:34px;margin:0;padding:0;position:absolute;transform:translateX(calc(-100% - 5px));width:34px}div.datepicker{display:none}.datepicker.active{display:block}.datepicker-dropdown{left:0;padding-top:4px;position:absolute;top:0;z-index:2000}.datepicker-dropdown.datepicker-orient-top{padding-bottom:4px;padding-top:0}.datepicker-picker{background-color:#fff;border-radius:.25rem;border-radius:6px;display:inline-block;padding:5px}.dateinput{width:10em}.datepicker-dropdown .datepicker-picker{box-shadow:0 .5rem 1rem rgba(0,0,0,.175)}.datepicker-picker span{-webkit-touch-callout:none;border:0;border-radius:.25rem;cursor:default;display:block;flex:1;margin-bottom:5px;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.datepicker-main{padding:2px}.datepicker-footer{background-color:#f8f9fa;box-shadow:inset 0 1px 1px rgba(0,0,0,.1)}.datepicker-controls,.datepicker-grid,.datepicker-view,.datepicker-view .days-of-week{display:flex;width:300px}.datepicker-grid{flex-wrap:wrap}.datepicker-view .days .datepicker-cell,.datepicker-view .dow{flex-basis:14.28571%}.datepicker-view.datepicker-grid .datepicker-cell{flex-basis:25%}.datepicker-cell,.datepicker-view .week{height:2.25rem;line-height:2.25rem}.datepicker-title{background-color:#f8f9fa;box-shadow:inset 0 -1px 1px rgba(0,0,0,.1);font-weight:700;padding:.375rem .75rem;text-align:center}.datepicker-header .datepicker-controls{padding:2px 2px 0}.datepicker-controls .btn{background-color:#fff;border:0;padding:5px}.datepicker-controls .btn:focus,.datepicker-controls .btn:hover{background-color:#e2e6ea;border-color:#dae0e5;color:#212529}.datepicker-controls .btn:focus{box-shadow:0 0 0 .2rem hsla(220,4%,85%,.5)}.datepicker-controls .btn:disabled{background-color:#f8f9fa;border-color:#f8f9fa;color:#212529}.datepicker-controls .btn:not(:disabled):active{background-color:#dae0e5;border-color:#d3d9df;color:#212529}.datepicker-controls .btn:not(:disabled):active:focus{box-shadow:0 0 0 .2rem hsla(220,4%,85%,.5)}.datepicker-header .datepicker-controls .btn{border-color:transparent;font-weight:700}.datepicker-footer .datepicker-controls .btn{border-radius:.2rem;font-size:.875rem;margin:calc(.375rem - 1px) .375rem;width:100%}.datepicker-controls .view-switch{flex:auto}.datepicker-controls .next-btn,.datepicker-controls .prev-btn{padding-left:.375rem;padding-right:.375rem;width:2.25rem}.datepicker-controls .next-btn.disabled,.datepicker-controls .prev-btn.disabled{visibility:hidden}.datepicker-view .dow{font-size:.9375rem;font-weight:700;height:1.5rem;line-height:1.5rem}.datepicker-view .week{color:#dee2e6;font-size:.875rem;width:2.25rem}@media(max-width:22.5rem){.datepicker-view .week{width:1.96875rem}.calendar-weeks+.days .datepicker-grid{width:13.78125rem}}.datepicker-cell:not(.disabled):hover{background-color:#f9f9f9;cursor:pointer}.datepicker-cell.focused:not(.selected){background-color:#f1f3f5}.datepicker-cell.selected,.datepicker-cell.selected:hover{background-color:var(--yafowil-accent-color,#0d6efd);color:var(--yafowil-accent-font-color,#fff);font-weight:600}.datepicker-cell.disabled,.datepicker-cell.next:not(.disabled),.datepicker-cell.prev:not(.disabled){color:#cdd0d4}.datepicker-cell.next.selected,.datepicker-cell.prev.selected{color:#e6e6e6}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today){background-color:#f8f9fa;border-radius:0}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today).focused,.datepicker-cell.highlighted:not(.selected):not(.range):not(.today):not(.disabled):hover{background-color:#f1f3f5}.datepicker-cell.today:not(.selected){background-color:#eee}.datepicker-cell.today:not(.selected):not(.disabled){color:#000}.datepicker-cell.today.focused:not(.selected){background-color:#eee}.datepicker-cell.range-end:not(.selected),.datepicker-cell.range-start:not(.selected){background-color:#6c757d;color:#fff}.datepicker-cell.range-end.focused:not(.selected),.datepicker-cell.range-start.focused:not(.selected){background-color:#666f76}.datepicker-cell.range-start{border-radius:.25rem 0 0 .25rem}.datepicker-cell.range-end{border-radius:0 .25rem .25rem 0}.datepicker-cell.range{background-color:#e9ecef;border-radius:0}.datepicker-cell.range:not(.disabled):not(.focused):not(.today):hover{background-color:#e2e6ea}.datepicker-cell.range.disabled{color:#cbd3da}.datepicker-cell.range.focused{background-color:#dadfe4}.datepicker-view.datepicker-grid .datepicker-cell{height:4.5rem;line-height:4.5rem}.datepicker-input.in-edit{border-color:var(--yafowil-accent-color,#0d6efd)}.datepicker-input.in-edit:active,.datepicker-input.in-edit:focus{box-shadow:0 0 .25em .25em rgba(102,176,255,.2)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
input.timeinput{display:inline-block;margin-right:45px;width:6em}button.timepicker-trigger{height:34px;margin:0;padding:0;position:absolute;transform:translateX(calc(-100% - 5px));width:34px}.timepicker-dropdown{background-color:#fff;border-radius:6px;box-shadow:0 .5rem 1rem rgba(0,0,0,.18);display:none;margin-top:4px;padding:5px;position:absolute;z-index:1000}.timepicker-container{display:flex;height:100%}.timepicker-container .header{background:none;border-radius:5px;font-weight:700;height:30px;padding:5px}.timepicker-container .header:hover{background:#dae0e5}.timepicker-container .cell{align-items:center;border-radius:3px;cursor:pointer;display:flex;justify-content:center;padding:5px;user-select:none}.timepicker-container .cell:hover{background:#f9f9f9}.timepicker-container .cell.selected{background-color:var(--yafowil-accent-color,#0d6efd);color:var(--yafowil-accent-font-color,#fff);font-weight:600}.timepicker-container .timepicker-hours{background:#fff;margin-right:6px}.timepicker-container .timepicker-hours .hours-content{display:grid;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr;grid-template-rows:1fr 1fr 1fr 1fr;width:100%}.timepicker-container .timepicker-hours div.am,.timepicker-container .timepicker-hours div.pm{display:grid;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr;grid-template-rows:1fr 1fr}.timepicker-container .timepicker-hours div.am{border-bottom:1px solid #e7e7e7}.timepicker-container .timepicker-hours span.am,.timepicker-container .timepicker-hours span.pm{float:left;font-size:10px;font-weight:600;padding:0 6px;position:relative;top:25px}.timepicker-container .timepicker-minutes{background:#fff;flex:auto}.timepicker-container .timepicker-minutes .minutes-content{display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr 1fr 1fr 1fr;width:100%}.timepicker-container .timepicker-minutes .minutes-content:before{border-left:1px solid #e7e7e7;bottom:0;content:"";height:100%;position:absolute;transform:translateX(-4px)}.datetime-picker>div{display:inline-block}
|