1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305 | 3×
1×
4181×
8044×
8044×
158×
158×
7886×
7886×
3913×
48×
3865×
3865×
7838×
7838×
1×
3865×
3865×
3762×
103×
103×
103×
103×
103×
1×
1×
60×
1×
24×
1×
12×
1×
1×
1×
73×
73×
73×
4380×
73×
73×
146×
114×
32×
32×
32×
32×
6×
6×
32×
1×
1×
32×
720×
73×
1×
5445×
1×
170×
147×
23×
23×
23×
23×
3×
3×
20×
20×
72×
20×
20×
1×
157×
157×
107×
107×
50×
50×
16×
16×
50×
50×
50×
50×
50×
50×
50×
50×
50×
8×
8×
76×
1616×
1616×
1616×
4×
1612×
1612×
16906×
16906×
16906×
4338×
12568×
4628×
7940×
3433×
4507×
4507×
1612×
1612×
1612×
42×
42×
673×
673×
1628×
31×
1597×
49×
1548×
1548×
1548×
50×
16×
16×
16×
32×
32×
50×
1×
5×
5×
5×
3×
2×
1×
1×
5×
5×
5×
1×
1×
1×
1×
1×
1×
1×
4×
4×
4×
4×
2×
2×
4×
4×
4×
1×
13×
1×
59×
1×
98×
1×
59×
1×
59×
1×
1×
1×
| (function(f){Eif(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dpicker_time = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){Iif(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = function yoyoifyAppendChild(el, childs) {
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
yoyoifyAppendChild(el, node);
continue;
}
Iif (typeof node === 'number' || typeof node === 'boolean' || node instanceof Date || node instanceof RegExp) {
node = node.toString();
}
if (typeof node === 'string') {
if (/^[\n\r\s]+$/.test(node))
continue;
Iif (el.lastChild && el.lastChild.nodeName === '#text') {
el.lastChild.nodeValue += node;
continue;
}
node = document.createTextNode(node);
}
Eif (node && node.nodeType) {
el.appendChild(node);
}
}
};
},{}],2:[function(require,module,exports){
'use strict';
var _appendChild = require('yo-yoify/lib/appendChild'), _setAttribute = function x(el, attr, value) {
Iif (typeof attr === 'object') {
for (var i in attr) {
if (Object.prototype.hasOwnProperty.call(attr, i)) {
x(el, i, attr[i]);
}
}
return;
}
if (!attr)
return;
Iif (attr === 'className')
attr = 'class';
Iif (attr === 'htmlFor')
attr = 'for';
Iif (attr.slice(0, 2) === 'on')
el[attr] = value;
else {
Iif (value === true)
value = attr;
el.setAttribute(attr, value);
}
};
module.exports = function (DPicker) {
var MINUTES = new Array(60).fill(0).map(function (e, i) {
return i;
});
var HOURS24 = new Array(24).fill(0).map(function (e, i) {
return i;
});
var HOURS12 = new Array(12).fill(0).map(function (e, i) {
return i === 0 ? 12 : i;
});
HOURS12.push(HOURS12.shift());
var MERIDIEM_TOKENS = [
'AM',
'PM'
];
function getHoursMinutes(data) {
var hours = data.meridiem ? HOURS12 : HOURS24;
var step = parseInt(data.step);
var minutes = MINUTES.filter(function (e) {
return e % step === 0;
});
var modelHours = DPicker.dateAdapter.getHours(data.model);
[
data.min,
data.max
].map(function (e, i) {
if (!DPicker.dateAdapter.isSameDay(data.model, e)) {
return;
}
var xHours = DPicker.dateAdapter.getHours(e);
var xMinutes = DPicker.dateAdapter.getMinutes(e);
var x = e;
if (i === 0 && xMinutes + step > 60) {
x = DPicker.dateAdapter.setMinutes(DPicker.dateAdapter.setHours(x, i === 0 ? ++xHours : --xHours), 0);
xMinutes = 0;
}
if (data.meridiem === true) {
Iif (xHours > 12) {
xHours = xHours - 12;
} else Iif (xHours === 0) {
xHours = 12;
}
}
hours = hours.filter(function (e) {
return i === 0 ? e >= xHours : e <= xHours;
});
});
return {
hours: hours,
minutes: minutes
};
}
function padLeftZero(v) {
return v < 10 ? '0' + v : '' + v;
}
function minutesStep() {
if (!this.data.time || parseInt(this.data.step, 10) <= 1) {
return;
}
var _getHoursMinutes = getHoursMinutes(this.data), minutes = _getHoursMinutes.minutes;
var modelMinutes = DPicker.dateAdapter.getMinutes(this.data.model);
Iif (modelMinutes < minutes[0]) {
this.data.model = DPicker.dateAdapter.setMinutes(this.data.model, minutes[0]);
modelMinutes = minutes[0];
}
if (modelMinutes > minutes[minutes.length - 1]) {
this.data.model = DPicker.dateAdapter.setMinutes(DPicker.dateAdapter.addHours(this.data.model, 1), 0);
return;
}
minutes[minutes.length] = 60;
modelMinutes = minutes.reduce(function (prev, curr) {
return Math.abs(curr - modelMinutes) < Math.abs(prev - modelMinutes) ? curr : prev;
});
minutes.length--;
this.data.model = DPicker.dateAdapter.setMinutes(this.data.model, modelMinutes);
}
DPicker.renders.time = function renderTime(events, data) {
var _dpickerTime2;
if (!data.time) {
var _dpickerTime;
return _dpickerTime = document.createElement('span'), _dpickerTime.setAttribute('style', 'display: none;'), _dpickerTime.setAttribute('class', 'dpicker-time'), _dpickerTime;
}
var modelHours = DPicker.dateAdapter.getHours(data.model);
if (data.meridiem !== false) {
modelHours = modelHours > 12 ? modelHours - 12 : modelHours;
modelHours = modelHours === 0 ? 12 : modelHours;
}
var _getHoursMinutes2 = getHoursMinutes(data), hours = _getHoursMinutes2.hours, minutes = _getHoursMinutes2.minutes;
var modelMinutes = DPicker.dateAdapter.getMinutes(data.model);
var selects = [];
var modelStringValue = modelHours + ':' + modelMinutes;
var minHours = DPicker.dateAdapter.getHours(data.min);
var minMinutes = DPicker.dateAdapter.getMinutes(data.min);
var maxHours = DPicker.dateAdapter.getHours(data.max);
var maxMinutes = DPicker.dateAdapter.getMinutes(data.max);
if (data.concatHoursAndMinutes) {
var _select;
selects.push((_select = document.createElement('select'), _select.onchange = events.minuteHoursChange, _select.setAttribute('name', 'dpicker-time'), _select.setAttribute('aria-label', 'time'), _appendChild(_select, [
' ',
[].concat.apply([], minutes.map(function (minute) {
return hours.map(function (hour) {
return hour + ':' + minute;
});
})).filter(function (e) {
var hm = e.split(':').map(parseFloat);
if (DPicker.dateAdapter.isSameDay(data.model, data.min) && hm[0] === minHours && hm[1] < minMinutes) {
return false;
}
Iif (DPicker.dateAdapter.isSameDay(data.model, data.max) && hm[0] === maxHours && hm[1] > maxMinutes) {
return false;
}
return true;
}).sort(function (a, b) {
a = a.split(':').map(parseFloat);
b = b.split(':').map(parseFloat);
if (a[0] < b[0]) {
return -1;
}
if (a[0] > b[0]) {
return 1;
}
if (a[1] < b[1]) {
return -1;
}
Eif (a[1] > b[1]) {
return 1;
}
return 0;
}).map(function (value) {
var _option;
var text = value.split(':').map(padLeftZero).join(':');
return _option = document.createElement('option'), _setAttribute(_option, value === modelStringValue ? 'selected' : '', value === modelStringValue ? 'selected' : ''), _option.setAttribute('value', '' + String(value) + ''), _appendChild(_option, [text]), _option;
}),
' '
]), _select));
} else {
var _select2, _select3;
selects.push((_select2 = document.createElement('select'), _select2.onchange = events.hoursChange, _select2.setAttribute('name', 'dpicker-hours'), _select2.setAttribute('aria-label', 'Hours'), _appendChild(_select2, [hours.map(function (e, i) {
var _option2;
return _option2 = document.createElement('option'), _setAttribute(_option2, e === modelHours ? 'selected' : '', e === modelHours ? 'selected' : ''), _option2.setAttribute('value', '' + String(e) + ''), _appendChild(_option2, [padLeftZero(e)]), _option2;
})]), _select2), (_select3 = document.createElement('select'), _select3.onchange = events.minutesChange, _select3.setAttribute('name', 'dpicker-minutes'), _select3.setAttribute('aria-label', 'Minutes'), _appendChild(_select3, [minutes.filter(function (e) {
if (DPicker.dateAdapter.isSameDay(data.model, data.min) && modelHours === minHours && e < minMinutes) {
return false;
}
if (DPicker.dateAdapter.isSameDay(data.model, data.max) && modelHours === maxHours && e > maxMinutes) {
return false;
}
return true;
}).map(function (e, i) {
var _option3;
return _option3 = document.createElement('option'), _setAttribute(_option3, e === modelMinutes ? 'selected' : '', e === modelMinutes ? 'selected' : ''), _option3.setAttribute('value', '' + String(e) + ''), _appendChild(_option3, [padLeftZero(e)]), _option3;
})]), _select3));
}
if (data.meridiem !== false) {
var _select4;
var modelMeridiem = DPicker.dateAdapter.getMeridiem(data.model);
selects.push((_select4 = document.createElement('select'), _select4.onchange = events.meridiemChange, _select4.setAttribute('name', 'dpicker-meridiem'), _appendChild(_select4, [
' ',
MERIDIEM_TOKENS.map(function (e) {
var _option4;
return _option4 = document.createElement('option'), _setAttribute(_option4, modelMeridiem === e ? 'selected' : '', modelMeridiem === e ? 'selected' : ''), _option4.setAttribute('value', '' + String(e) + ''), _appendChild(_option4, [e]), _option4;
}),
' '
]), _select4));
}
return _dpickerTime2 = document.createElement('span'), _dpickerTime2.setAttribute('class', 'dpicker-time'), _appendChild(_dpickerTime2, [selects]), _dpickerTime2;
};
DPicker.events.hoursChange = function hoursChange(evt) {
this.data.empty = false;
var val = parseInt(evt.target.options[evt.target.selectedIndex].value, 10);
if (this.data.meridiem !== false) {
if (DPicker.dateAdapter.getMeridiem(this.data.model) === MERIDIEM_TOKENS[1]) {
val = val === 12 ? 12 : val + 12;
} else Eif (val === 12) {
val = 0;
}
}
this.model = DPicker.dateAdapter.setHours(this.data.model, val);
Iif (evt.redraw === false) {
this.redraw();
}
this.onChange({
modelChanged: true,
name: 'hoursChange',
event: evt
});
};
DPicker.events.minutesChange = function minutesChange(evt) {
this.data.empty = false;
this.model = DPicker.dateAdapter.setMinutes(this.data.model, evt.target.options[evt.target.selectedIndex].value);
Iif (evt.redraw === false) {
this.redraw();
}
this.onChange({
modelChanged: true,
name: 'minutesChange',
event: evt
});
};
DPicker.events.minuteHoursChange = function minuteHoursChange(evt) {
var val = evt.target.options[evt.target.selectedIndex].value.split(':');
this.events.hoursChange({
target: {
options: [{ value: val[0] }],
selectedIndex: 0
},
redraw: false
});
this.events.minutesChange({
target: {
options: [{ value: val[1] }],
selectedIndex: 0
},
redraw: false
});
this.redraw();
};
DPicker.events.meridiemChange = function meridiemChange(evt) {
this.data.empty = false;
var val = evt.target.options[evt.target.selectedIndex].value;
var hours = DPicker.dateAdapter.getHours(this.data.model);
if (val === MERIDIEM_TOKENS[0]) {
hours = hours === 12 ? 0 : hours - 12;
} else {
hours = hours === 12 ? 12 : hours + 12;
}
this.model = DPicker.dateAdapter.setHours(this.data.model, hours);
this.redraw();
this.onChange({
modelChanged: true,
name: 'meridiemChange',
event: evt
});
};
DPicker.events.inputChange = DPicker.decorate(DPicker.events.inputChange, function timeInputChange() {
minutesStep.apply(this);
});
DPicker.prototype.initialize = DPicker.decorate(DPicker.prototype.initialize, function timeInitialize() {
minutesStep.apply(this);
});
DPicker.prototype.redraw = DPicker.decorate(DPicker.prototype.redraw, function timeRedraw() {
minutesStep.apply(this);
});
DPicker.properties.time = function getTimeAttribute(attributes) {
return attributes.type === 'datetime';
};
DPicker.properties.step = function getStepAttribute(attributes) {
return attributes.step ? parseInt(attributes.step, 10) : 1;
};
DPicker.properties.meridiem = false;
DPicker.properties.concatHoursAndMinutes = false;
return DPicker;
};
},{"yo-yoify/lib/appendChild":1}]},{},[2])(2)
}); |