bs4_datetime_picker 0.0.0 → 1.0.4
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.
- checksums.yaml +4 -4
- data/README.md +38 -5
- data/app/assets/javascripts/bs4-datetime-picker.js +2787 -0
- data/app/assets/stylesheets/bs4-datetime-picker.css +211 -0
- data/lib/bs4_datetime_picker.rb +5 -4
- data/lib/bs4_datetime_picker/railtie.rb +18 -1
- data/lib/bs4_datetime_picker/version.rb +1 -1
- metadata +83 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5734fb65d24836c25a9fadf79422d32605c8a285aa7c7707e78578db3209a972
|
4
|
+
data.tar.gz: '02844c000f5ae232038a6286534a3693a7601235d4dac7382de9ad8ca42d5872'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1801df90032db4b9adf5fdc5aeef59dc7e1c48976ad3ca5d1d8f42725ef33b87331173801cdeb2467cc548e223e1317692c0a59191fed559f318b8a33c1dfb27
|
7
|
+
data.tar.gz: 23fe1cc3b50cbc25bdc0c86a49118045fe947b0ca49f10a8061422d3c65bbdce212b54667b4f727b75e513c2dfd34666400eda8177fded79474607783b832e69
|
data/README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# Bootstrap 4 Datetime Picker
|
2
|
+
|
3
|
+
This is just a simple wrapper gem for Tempus Dominus Bootstrap 4, @see https://github.com/tempusdominus/bootstrap-4. This version of the datetime picker is styled to look like the version from Bootstrap 3.
|
3
4
|
|
4
5
|
## Usage
|
5
|
-
|
6
|
+
|
7
|
+
For usage information, please @see https://tempusdominus.github.io/bootstrap-4/Usage/
|
8
|
+
|
9
|
+
## Dependencies
|
10
|
+
|
11
|
+
This gem includes `font-awesome-rails`, `momentjs-rails` and `moment-timezone-rails`. These three libraries are pretty much required to get the datetime picker to work out of the box.
|
6
12
|
|
7
13
|
## Installation
|
14
|
+
|
8
15
|
Add this line to your application's Gemfile:
|
9
16
|
|
10
17
|
```ruby
|
@@ -12,17 +19,43 @@ gem 'bs4_datetime_picker'
|
|
12
19
|
```
|
13
20
|
|
14
21
|
And then execute:
|
22
|
+
|
15
23
|
```bash
|
16
|
-
$ bundle
|
24
|
+
$ bundle install
|
17
25
|
```
|
18
26
|
|
19
27
|
Or install it yourself as:
|
28
|
+
|
20
29
|
```bash
|
21
30
|
$ gem install bs4_datetime_picker
|
22
31
|
```
|
23
32
|
|
33
|
+
To install it in your Rails application:
|
34
|
+
|
35
|
+
`assets/stylesheets/application.scss`
|
36
|
+
|
37
|
+
```css
|
38
|
+
/*
|
39
|
+
*= require bs4-datetime-picker
|
40
|
+
*/
|
41
|
+
@import "font-awesome";
|
42
|
+
```
|
43
|
+
|
44
|
+
`assets/javascripts/application.js`
|
45
|
+
|
46
|
+
```js
|
47
|
+
//= require moment
|
48
|
+
//= require bs4-datetime-picker
|
49
|
+
```
|
50
|
+
|
51
|
+
> _NOTE:_
|
52
|
+
>
|
53
|
+
> Examples assume that you already have `jQuery` and `Bootstrap 4` setup in your application.
|
54
|
+
|
24
55
|
## Contributing
|
25
|
-
|
56
|
+
|
57
|
+
If you wish to contribution, send PRs to https://github.com/rdavid369/bs4-datetime-picker/pulls
|
26
58
|
|
27
59
|
## License
|
60
|
+
|
28
61
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,2787 @@
|
|
1
|
+
/*!
|
2
|
+
* Bs4 Datetime Picker v1.0.0
|
3
|
+
* Licensed under the MIT license
|
4
|
+
*
|
5
|
+
* - We don't need to change anything with the javascript, so just import it
|
6
|
+
* from the `src` and send it to the vendor directory.
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*@preserve
|
10
|
+
* Tempus Dominus Bootstrap4 v5.1.2 (https://tempusdominus.github.io/bootstrap-4/)
|
11
|
+
* Copyright 2016-2018 Jonathan Peterson
|
12
|
+
* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
|
13
|
+
*/
|
14
|
+
|
15
|
+
if (typeof jQuery === 'undefined') {
|
16
|
+
throw new Error('Tempus Dominus Bootstrap4\'s requires jQuery. jQuery must be included before Tempus Dominus Bootstrap4\'s JavaScript.');
|
17
|
+
}
|
18
|
+
|
19
|
+
+function ($) {
|
20
|
+
var version = $.fn.jquery.split(' ')[0].split('.');
|
21
|
+
if ((version[0] < 2 && version[1] < 9) || (version[0] === 1 && version[1] === 9 && version[2] < 1) || (version[0] >= 4)) {
|
22
|
+
throw new Error('Tempus Dominus Bootstrap4\'s requires at least jQuery v3.0.0 but less than v4.0.0');
|
23
|
+
}
|
24
|
+
}(jQuery);
|
25
|
+
|
26
|
+
|
27
|
+
if (typeof moment === 'undefined') {
|
28
|
+
throw new Error('Tempus Dominus Bootstrap4\'s requires moment.js. Moment.js must be included before Tempus Dominus Bootstrap4\'s JavaScript.');
|
29
|
+
}
|
30
|
+
|
31
|
+
var version = moment.version.split('.')
|
32
|
+
if ((version[0] <= 2 && version[1] < 17) || (version[0] >= 3)) {
|
33
|
+
throw new Error('Tempus Dominus Bootstrap4\'s requires at least moment.js v2.17.0 but less than v3.0.0');
|
34
|
+
}
|
35
|
+
|
36
|
+
+function () {
|
37
|
+
|
38
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
39
|
+
|
40
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
41
|
+
|
42
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
43
|
+
|
44
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
45
|
+
|
46
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
47
|
+
|
48
|
+
// ReSharper disable once InconsistentNaming
|
49
|
+
var DateTimePicker = function ($, moment) {
|
50
|
+
// ReSharper disable InconsistentNaming
|
51
|
+
var NAME = 'datetimepicker',
|
52
|
+
DATA_KEY = '' + NAME,
|
53
|
+
EVENT_KEY = '.' + DATA_KEY,
|
54
|
+
DATA_API_KEY = '.data-api',
|
55
|
+
Selector = {
|
56
|
+
DATA_TOGGLE: '[data-toggle="' + DATA_KEY + '"]'
|
57
|
+
},
|
58
|
+
ClassName = {
|
59
|
+
INPUT: NAME + '-input'
|
60
|
+
},
|
61
|
+
Event = {
|
62
|
+
CHANGE: 'change' + EVENT_KEY,
|
63
|
+
BLUR: 'blur' + EVENT_KEY,
|
64
|
+
KEYUP: 'keyup' + EVENT_KEY,
|
65
|
+
KEYDOWN: 'keydown' + EVENT_KEY,
|
66
|
+
FOCUS: 'focus' + EVENT_KEY,
|
67
|
+
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
|
68
|
+
//emitted
|
69
|
+
UPDATE: 'update' + EVENT_KEY,
|
70
|
+
ERROR: 'error' + EVENT_KEY,
|
71
|
+
HIDE: 'hide' + EVENT_KEY,
|
72
|
+
SHOW: 'show' + EVENT_KEY
|
73
|
+
},
|
74
|
+
DatePickerModes = [{
|
75
|
+
CLASS_NAME: 'days',
|
76
|
+
NAV_FUNCTION: 'M',
|
77
|
+
NAV_STEP: 1
|
78
|
+
}, {
|
79
|
+
CLASS_NAME: 'months',
|
80
|
+
NAV_FUNCTION: 'y',
|
81
|
+
NAV_STEP: 1
|
82
|
+
}, {
|
83
|
+
CLASS_NAME: 'years',
|
84
|
+
NAV_FUNCTION: 'y',
|
85
|
+
NAV_STEP: 10
|
86
|
+
}, {
|
87
|
+
CLASS_NAME: 'decades',
|
88
|
+
NAV_FUNCTION: 'y',
|
89
|
+
NAV_STEP: 100
|
90
|
+
}],
|
91
|
+
KeyMap = {
|
92
|
+
'up': 38,
|
93
|
+
38: 'up',
|
94
|
+
'down': 40,
|
95
|
+
40: 'down',
|
96
|
+
'left': 37,
|
97
|
+
37: 'left',
|
98
|
+
'right': 39,
|
99
|
+
39: 'right',
|
100
|
+
'tab': 9,
|
101
|
+
9: 'tab',
|
102
|
+
'escape': 27,
|
103
|
+
27: 'escape',
|
104
|
+
'enter': 13,
|
105
|
+
13: 'enter',
|
106
|
+
'pageUp': 33,
|
107
|
+
33: 'pageUp',
|
108
|
+
'pageDown': 34,
|
109
|
+
34: 'pageDown',
|
110
|
+
'shift': 16,
|
111
|
+
16: 'shift',
|
112
|
+
'control': 17,
|
113
|
+
17: 'control',
|
114
|
+
'space': 32,
|
115
|
+
32: 'space',
|
116
|
+
't': 84,
|
117
|
+
84: 't',
|
118
|
+
'delete': 46,
|
119
|
+
46: 'delete'
|
120
|
+
},
|
121
|
+
ViewModes = ['times', 'days', 'months', 'years', 'decades'],
|
122
|
+
keyState = {},
|
123
|
+
keyPressHandled = {};
|
124
|
+
|
125
|
+
var Default = {
|
126
|
+
timeZone: '',
|
127
|
+
format: false,
|
128
|
+
dayViewHeaderFormat: 'MMMM YYYY',
|
129
|
+
extraFormats: false,
|
130
|
+
stepping: 1,
|
131
|
+
minDate: false,
|
132
|
+
maxDate: false,
|
133
|
+
useCurrent: true,
|
134
|
+
collapse: true,
|
135
|
+
locale: moment.locale(),
|
136
|
+
defaultDate: false,
|
137
|
+
disabledDates: false,
|
138
|
+
enabledDates: false,
|
139
|
+
icons: {
|
140
|
+
time: 'fa fa-clock-o',
|
141
|
+
date: 'fa fa-calendar',
|
142
|
+
up: 'fa fa-arrow-up',
|
143
|
+
down: 'fa fa-arrow-down',
|
144
|
+
previous: 'fa fa-chevron-left',
|
145
|
+
next: 'fa fa-chevron-right',
|
146
|
+
today: 'fa fa-calendar-check-o',
|
147
|
+
clear: 'fa fa-delete',
|
148
|
+
close: 'fa fa-times'
|
149
|
+
},
|
150
|
+
tooltips: {
|
151
|
+
today: 'Go to today',
|
152
|
+
clear: 'Clear selection',
|
153
|
+
close: 'Close the picker',
|
154
|
+
selectMonth: 'Select Month',
|
155
|
+
prevMonth: 'Previous Month',
|
156
|
+
nextMonth: 'Next Month',
|
157
|
+
selectYear: 'Select Year',
|
158
|
+
prevYear: 'Previous Year',
|
159
|
+
nextYear: 'Next Year',
|
160
|
+
selectDecade: 'Select Decade',
|
161
|
+
prevDecade: 'Previous Decade',
|
162
|
+
nextDecade: 'Next Decade',
|
163
|
+
prevCentury: 'Previous Century',
|
164
|
+
nextCentury: 'Next Century',
|
165
|
+
pickHour: 'Pick Hour',
|
166
|
+
incrementHour: 'Increment Hour',
|
167
|
+
decrementHour: 'Decrement Hour',
|
168
|
+
pickMinute: 'Pick Minute',
|
169
|
+
incrementMinute: 'Increment Minute',
|
170
|
+
decrementMinute: 'Decrement Minute',
|
171
|
+
pickSecond: 'Pick Second',
|
172
|
+
incrementSecond: 'Increment Second',
|
173
|
+
decrementSecond: 'Decrement Second',
|
174
|
+
togglePeriod: 'Toggle Period',
|
175
|
+
selectTime: 'Select Time',
|
176
|
+
selectDate: 'Select Date'
|
177
|
+
},
|
178
|
+
useStrict: false,
|
179
|
+
sideBySide: false,
|
180
|
+
daysOfWeekDisabled: false,
|
181
|
+
calendarWeeks: false,
|
182
|
+
viewMode: 'days',
|
183
|
+
toolbarPlacement: 'default',
|
184
|
+
buttons: {
|
185
|
+
showToday: false,
|
186
|
+
showClear: false,
|
187
|
+
showClose: false
|
188
|
+
},
|
189
|
+
widgetPositioning: {
|
190
|
+
horizontal: 'auto',
|
191
|
+
vertical: 'auto'
|
192
|
+
},
|
193
|
+
widgetParent: null,
|
194
|
+
ignoreReadonly: false,
|
195
|
+
keepOpen: false,
|
196
|
+
focusOnShow: true,
|
197
|
+
inline: false,
|
198
|
+
keepInvalid: false,
|
199
|
+
keyBinds: {
|
200
|
+
up: function up() {
|
201
|
+
if (!this.widget) {
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
var d = this._dates[0] || this.getMoment();
|
205
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
206
|
+
this.date(d.clone().subtract(7, 'd'));
|
207
|
+
} else {
|
208
|
+
this.date(d.clone().add(this.stepping(), 'm'));
|
209
|
+
}
|
210
|
+
return true;
|
211
|
+
},
|
212
|
+
down: function down() {
|
213
|
+
if (!this.widget) {
|
214
|
+
this.show();
|
215
|
+
return false;
|
216
|
+
}
|
217
|
+
var d = this._dates[0] || this.getMoment();
|
218
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
219
|
+
this.date(d.clone().add(7, 'd'));
|
220
|
+
} else {
|
221
|
+
this.date(d.clone().subtract(this.stepping(), 'm'));
|
222
|
+
}
|
223
|
+
return true;
|
224
|
+
},
|
225
|
+
'control up': function controlUp() {
|
226
|
+
if (!this.widget) {
|
227
|
+
return false;
|
228
|
+
}
|
229
|
+
var d = this._dates[0] || this.getMoment();
|
230
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
231
|
+
this.date(d.clone().subtract(1, 'y'));
|
232
|
+
} else {
|
233
|
+
this.date(d.clone().add(1, 'h'));
|
234
|
+
}
|
235
|
+
return true;
|
236
|
+
},
|
237
|
+
'control down': function controlDown() {
|
238
|
+
if (!this.widget) {
|
239
|
+
return false;
|
240
|
+
}
|
241
|
+
var d = this._dates[0] || this.getMoment();
|
242
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
243
|
+
this.date(d.clone().add(1, 'y'));
|
244
|
+
} else {
|
245
|
+
this.date(d.clone().subtract(1, 'h'));
|
246
|
+
}
|
247
|
+
return true;
|
248
|
+
},
|
249
|
+
left: function left() {
|
250
|
+
if (!this.widget) {
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
var d = this._dates[0] || this.getMoment();
|
254
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
255
|
+
this.date(d.clone().subtract(1, 'd'));
|
256
|
+
}
|
257
|
+
return true;
|
258
|
+
},
|
259
|
+
right: function right() {
|
260
|
+
if (!this.widget) {
|
261
|
+
return false;
|
262
|
+
}
|
263
|
+
var d = this._dates[0] || this.getMoment();
|
264
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
265
|
+
this.date(d.clone().add(1, 'd'));
|
266
|
+
}
|
267
|
+
return true;
|
268
|
+
},
|
269
|
+
pageUp: function pageUp() {
|
270
|
+
if (!this.widget) {
|
271
|
+
return false;
|
272
|
+
}
|
273
|
+
var d = this._dates[0] || this.getMoment();
|
274
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
275
|
+
this.date(d.clone().subtract(1, 'M'));
|
276
|
+
}
|
277
|
+
return true;
|
278
|
+
},
|
279
|
+
pageDown: function pageDown() {
|
280
|
+
if (!this.widget) {
|
281
|
+
return false;
|
282
|
+
}
|
283
|
+
var d = this._dates[0] || this.getMoment();
|
284
|
+
if (this.widget.find('.datepicker').is(':visible')) {
|
285
|
+
this.date(d.clone().add(1, 'M'));
|
286
|
+
}
|
287
|
+
return true;
|
288
|
+
},
|
289
|
+
enter: function enter() {
|
290
|
+
if (!this.widget) {
|
291
|
+
return false;
|
292
|
+
}
|
293
|
+
this.hide();
|
294
|
+
return true;
|
295
|
+
},
|
296
|
+
escape: function escape() {
|
297
|
+
if (!this.widget) {
|
298
|
+
return false;
|
299
|
+
}
|
300
|
+
this.hide();
|
301
|
+
return true;
|
302
|
+
},
|
303
|
+
'control space': function controlSpace() {
|
304
|
+
if (!this.widget) {
|
305
|
+
return false;
|
306
|
+
}
|
307
|
+
if (this.widget.find('.timepicker').is(':visible')) {
|
308
|
+
this.widget.find('.btn[data-action="togglePeriod"]').click();
|
309
|
+
}
|
310
|
+
return true;
|
311
|
+
},
|
312
|
+
t: function t() {
|
313
|
+
if (!this.widget) {
|
314
|
+
return false;
|
315
|
+
}
|
316
|
+
this.date(this.getMoment());
|
317
|
+
return true;
|
318
|
+
},
|
319
|
+
'delete': function _delete() {
|
320
|
+
if (!this.widget) {
|
321
|
+
return false;
|
322
|
+
}
|
323
|
+
this.clear();
|
324
|
+
return true;
|
325
|
+
}
|
326
|
+
},
|
327
|
+
debug: false,
|
328
|
+
allowInputToggle: false,
|
329
|
+
disabledTimeIntervals: false,
|
330
|
+
disabledHours: false,
|
331
|
+
enabledHours: false,
|
332
|
+
viewDate: false,
|
333
|
+
allowMultidate: false,
|
334
|
+
multidateSeparator: ','
|
335
|
+
};
|
336
|
+
|
337
|
+
// ReSharper restore InconsistentNaming
|
338
|
+
|
339
|
+
// ReSharper disable once DeclarationHides
|
340
|
+
// ReSharper disable once InconsistentNaming
|
341
|
+
|
342
|
+
var DateTimePicker = function () {
|
343
|
+
/** @namespace eData.dateOptions */
|
344
|
+
/** @namespace moment.tz */
|
345
|
+
|
346
|
+
function DateTimePicker(element, options) {
|
347
|
+
_classCallCheck(this, DateTimePicker);
|
348
|
+
|
349
|
+
this._options = this._getOptions(options);
|
350
|
+
this._element = element;
|
351
|
+
this._dates = [];
|
352
|
+
this._datesFormatted = [];
|
353
|
+
this._viewDate = null;
|
354
|
+
this.unset = true;
|
355
|
+
this.component = false;
|
356
|
+
this.widget = false;
|
357
|
+
this.use24Hours = null;
|
358
|
+
this.actualFormat = null;
|
359
|
+
this.parseFormats = null;
|
360
|
+
this.currentViewMode = null;
|
361
|
+
this.MinViewModeNumber = 0;
|
362
|
+
|
363
|
+
this._int();
|
364
|
+
}
|
365
|
+
|
366
|
+
/**
|
367
|
+
* @return {string}
|
368
|
+
*/
|
369
|
+
|
370
|
+
|
371
|
+
//private
|
372
|
+
|
373
|
+
DateTimePicker.prototype._int = function _int() {
|
374
|
+
var targetInput = this._element.data('target-input');
|
375
|
+
if (this._element.is('input')) {
|
376
|
+
this.input = this._element;
|
377
|
+
} else if (targetInput !== undefined) {
|
378
|
+
if (targetInput === 'nearest') {
|
379
|
+
this.input = this._element.find('input');
|
380
|
+
} else {
|
381
|
+
this.input = $(targetInput);
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
this._dates = [];
|
386
|
+
this._dates[0] = this.getMoment();
|
387
|
+
this._viewDate = this.getMoment().clone();
|
388
|
+
|
389
|
+
$.extend(true, this._options, this._dataToOptions());
|
390
|
+
|
391
|
+
this.options(this._options);
|
392
|
+
|
393
|
+
this._initFormatting();
|
394
|
+
|
395
|
+
if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) {
|
396
|
+
this._setValue(this._parseInputDate(this.input.val().trim()), 0);
|
397
|
+
} else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) {
|
398
|
+
this._setValue(this._options.defaultDate, 0);
|
399
|
+
}
|
400
|
+
if (this._options.inline) {
|
401
|
+
this.show();
|
402
|
+
}
|
403
|
+
};
|
404
|
+
|
405
|
+
DateTimePicker.prototype._update = function _update() {
|
406
|
+
if (!this.widget) {
|
407
|
+
return;
|
408
|
+
}
|
409
|
+
this._fillDate();
|
410
|
+
this._fillTime();
|
411
|
+
};
|
412
|
+
|
413
|
+
DateTimePicker.prototype._setValue = function _setValue(targetMoment, index) {
|
414
|
+
var oldDate = this.unset ? null : this._dates[index];
|
415
|
+
var outpValue = '';
|
416
|
+
// case of calling setValue(null or false)
|
417
|
+
if (!targetMoment) {
|
418
|
+
if (!this._options.allowMultidate || this._dates.length === 1) {
|
419
|
+
this.unset = true;
|
420
|
+
this._dates = [];
|
421
|
+
this._datesFormatted = [];
|
422
|
+
} else {
|
423
|
+
outpValue = this._element.data('date') + ',';
|
424
|
+
outpValue = outpValue.replace(oldDate.format(this.actualFormat) + ',', '').replace(',,', '').replace(/,\s*$/, '');
|
425
|
+
this._dates.splice(index, 1);
|
426
|
+
this._datesFormatted.splice(index, 1);
|
427
|
+
}
|
428
|
+
if (this.input !== undefined) {
|
429
|
+
this.input.val(outpValue);
|
430
|
+
this.input.trigger('input');
|
431
|
+
}
|
432
|
+
this._element.data('date', outpValue);
|
433
|
+
this._notifyEvent({
|
434
|
+
type: DateTimePicker.Event.CHANGE,
|
435
|
+
date: false,
|
436
|
+
oldDate: oldDate
|
437
|
+
});
|
438
|
+
this._update();
|
439
|
+
return;
|
440
|
+
}
|
441
|
+
|
442
|
+
targetMoment = targetMoment.clone().locale(this._options.locale);
|
443
|
+
|
444
|
+
if (this._hasTimeZone()) {
|
445
|
+
targetMoment.tz(this._options.timeZone);
|
446
|
+
}
|
447
|
+
|
448
|
+
if (this._options.stepping !== 1) {
|
449
|
+
targetMoment.minutes(Math.round(targetMoment.minutes() / this._options.stepping) * this._options.stepping).seconds(0);
|
450
|
+
}
|
451
|
+
|
452
|
+
if (this._isValid(targetMoment)) {
|
453
|
+
this._dates[index] = targetMoment;
|
454
|
+
this._datesFormatted[index] = targetMoment.format('YYYY-MM-DD');
|
455
|
+
this._viewDate = targetMoment.clone();
|
456
|
+
if (this._options.allowMultidate && this._dates.length > 1) {
|
457
|
+
for (var i = 0; i < this._dates.length; i++) {
|
458
|
+
outpValue += '' + this._dates[i].format(this.actualFormat) + this._options.multidateSeparator;
|
459
|
+
}
|
460
|
+
outpValue = outpValue.replace(/,\s*$/, '');
|
461
|
+
} else {
|
462
|
+
outpValue = this._dates[index].format(this.actualFormat);
|
463
|
+
}
|
464
|
+
if (this.input !== undefined) {
|
465
|
+
this.input.val(outpValue);
|
466
|
+
this.input.trigger('input');
|
467
|
+
}
|
468
|
+
this._element.data('date', outpValue);
|
469
|
+
|
470
|
+
this.unset = false;
|
471
|
+
this._update();
|
472
|
+
this._notifyEvent({
|
473
|
+
type: DateTimePicker.Event.CHANGE,
|
474
|
+
date: this._dates[index].clone(),
|
475
|
+
oldDate: oldDate
|
476
|
+
});
|
477
|
+
} else {
|
478
|
+
if (!this._options.keepInvalid) {
|
479
|
+
if (this.input !== undefined) {
|
480
|
+
this.input.val('' + (this.unset ? '' : this._dates[index].format(this.actualFormat)));
|
481
|
+
this.input.trigger('input');
|
482
|
+
}
|
483
|
+
} else {
|
484
|
+
this._notifyEvent({
|
485
|
+
type: DateTimePicker.Event.CHANGE,
|
486
|
+
date: targetMoment,
|
487
|
+
oldDate: oldDate
|
488
|
+
});
|
489
|
+
}
|
490
|
+
this._notifyEvent({
|
491
|
+
type: DateTimePicker.Event.ERROR,
|
492
|
+
date: targetMoment,
|
493
|
+
oldDate: oldDate
|
494
|
+
});
|
495
|
+
}
|
496
|
+
};
|
497
|
+
|
498
|
+
DateTimePicker.prototype._change = function _change(e) {
|
499
|
+
var val = $(e.target).val().trim(),
|
500
|
+
parsedDate = val ? this._parseInputDate(val) : null;
|
501
|
+
this._setValue(parsedDate);
|
502
|
+
e.stopImmediatePropagation();
|
503
|
+
return false;
|
504
|
+
};
|
505
|
+
|
506
|
+
//noinspection JSMethodCanBeStatic
|
507
|
+
|
508
|
+
|
509
|
+
DateTimePicker.prototype._getOptions = function _getOptions(options) {
|
510
|
+
options = $.extend(true, {}, Default, options);
|
511
|
+
return options;
|
512
|
+
};
|
513
|
+
|
514
|
+
DateTimePicker.prototype._hasTimeZone = function _hasTimeZone() {
|
515
|
+
return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== '';
|
516
|
+
};
|
517
|
+
|
518
|
+
DateTimePicker.prototype._isEnabled = function _isEnabled(granularity) {
|
519
|
+
if (typeof granularity !== 'string' || granularity.length > 1) {
|
520
|
+
throw new TypeError('isEnabled expects a single character string parameter');
|
521
|
+
}
|
522
|
+
switch (granularity) {
|
523
|
+
case 'y':
|
524
|
+
return this.actualFormat.indexOf('Y') !== -1;
|
525
|
+
case 'M':
|
526
|
+
return this.actualFormat.indexOf('M') !== -1;
|
527
|
+
case 'd':
|
528
|
+
return this.actualFormat.toLowerCase().indexOf('d') !== -1;
|
529
|
+
case 'h':
|
530
|
+
case 'H':
|
531
|
+
return this.actualFormat.toLowerCase().indexOf('h') !== -1;
|
532
|
+
case 'm':
|
533
|
+
return this.actualFormat.indexOf('m') !== -1;
|
534
|
+
case 's':
|
535
|
+
return this.actualFormat.indexOf('s') !== -1;
|
536
|
+
case 'a':
|
537
|
+
case 'A':
|
538
|
+
return this.actualFormat.toLowerCase().indexOf('a') !== -1;
|
539
|
+
default:
|
540
|
+
return false;
|
541
|
+
}
|
542
|
+
};
|
543
|
+
|
544
|
+
DateTimePicker.prototype._hasTime = function _hasTime() {
|
545
|
+
return this._isEnabled('h') || this._isEnabled('m') || this._isEnabled('s');
|
546
|
+
};
|
547
|
+
|
548
|
+
DateTimePicker.prototype._hasDate = function _hasDate() {
|
549
|
+
return this._isEnabled('y') || this._isEnabled('M') || this._isEnabled('d');
|
550
|
+
};
|
551
|
+
|
552
|
+
DateTimePicker.prototype._dataToOptions = function _dataToOptions() {
|
553
|
+
var eData = this._element.data();
|
554
|
+
var dataOptions = {};
|
555
|
+
|
556
|
+
if (eData.dateOptions && eData.dateOptions instanceof Object) {
|
557
|
+
dataOptions = $.extend(true, dataOptions, eData.dateOptions);
|
558
|
+
}
|
559
|
+
|
560
|
+
$.each(this._options, function (key) {
|
561
|
+
var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1); //todo data api key
|
562
|
+
if (eData[attributeName] !== undefined) {
|
563
|
+
dataOptions[key] = eData[attributeName];
|
564
|
+
} else {
|
565
|
+
delete dataOptions[key];
|
566
|
+
}
|
567
|
+
});
|
568
|
+
return dataOptions;
|
569
|
+
};
|
570
|
+
|
571
|
+
DateTimePicker.prototype._notifyEvent = function _notifyEvent(e) {
|
572
|
+
if (e.type === DateTimePicker.Event.CHANGE && (e.date && e.date.isSame(e.oldDate)) || !e.date && !e.oldDate) {
|
573
|
+
return;
|
574
|
+
}
|
575
|
+
this._element.trigger(e);
|
576
|
+
};
|
577
|
+
|
578
|
+
DateTimePicker.prototype._viewUpdate = function _viewUpdate(e) {
|
579
|
+
if (e === 'y') {
|
580
|
+
e = 'YYYY';
|
581
|
+
}
|
582
|
+
this._notifyEvent({
|
583
|
+
type: DateTimePicker.Event.UPDATE,
|
584
|
+
change: e,
|
585
|
+
viewDate: this._viewDate.clone()
|
586
|
+
});
|
587
|
+
};
|
588
|
+
|
589
|
+
DateTimePicker.prototype._showMode = function _showMode(dir) {
|
590
|
+
if (!this.widget) {
|
591
|
+
return;
|
592
|
+
}
|
593
|
+
if (dir) {
|
594
|
+
this.currentViewMode = Math.max(this.MinViewModeNumber, Math.min(3, this.currentViewMode + dir));
|
595
|
+
}
|
596
|
+
this.widget.find('.datepicker > div').hide().filter('.datepicker-' + DatePickerModes[this.currentViewMode].CLASS_NAME).show();
|
597
|
+
};
|
598
|
+
|
599
|
+
DateTimePicker.prototype._isInDisabledDates = function _isInDisabledDates(testDate) {
|
600
|
+
return this._options.disabledDates[testDate.format('YYYY-MM-DD')] === true;
|
601
|
+
};
|
602
|
+
|
603
|
+
DateTimePicker.prototype._isInEnabledDates = function _isInEnabledDates(testDate) {
|
604
|
+
return this._options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
|
605
|
+
};
|
606
|
+
|
607
|
+
DateTimePicker.prototype._isInDisabledHours = function _isInDisabledHours(testDate) {
|
608
|
+
return this._options.disabledHours[testDate.format('H')] === true;
|
609
|
+
};
|
610
|
+
|
611
|
+
DateTimePicker.prototype._isInEnabledHours = function _isInEnabledHours(testDate) {
|
612
|
+
return this._options.enabledHours[testDate.format('H')] === true;
|
613
|
+
};
|
614
|
+
|
615
|
+
DateTimePicker.prototype._isValid = function _isValid(targetMoment, granularity) {
|
616
|
+
if (!targetMoment.isValid()) {
|
617
|
+
return false;
|
618
|
+
}
|
619
|
+
if (this._options.disabledDates && granularity === 'd' && this._isInDisabledDates(targetMoment)) {
|
620
|
+
return false;
|
621
|
+
}
|
622
|
+
if (this._options.enabledDates && granularity === 'd' && !this._isInEnabledDates(targetMoment)) {
|
623
|
+
return false;
|
624
|
+
}
|
625
|
+
if (this._options.minDate && targetMoment.isBefore(this._options.minDate, granularity)) {
|
626
|
+
return false;
|
627
|
+
}
|
628
|
+
if (this._options.maxDate && targetMoment.isAfter(this._options.maxDate, granularity)) {
|
629
|
+
return false;
|
630
|
+
}
|
631
|
+
if (this._options.daysOfWeekDisabled && granularity === 'd' && this._options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
|
632
|
+
return false;
|
633
|
+
}
|
634
|
+
if (this._options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && this._isInDisabledHours(targetMoment)) {
|
635
|
+
return false;
|
636
|
+
}
|
637
|
+
if (this._options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !this._isInEnabledHours(targetMoment)) {
|
638
|
+
return false;
|
639
|
+
}
|
640
|
+
if (this._options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
|
641
|
+
var found = false;
|
642
|
+
$.each(this._options.disabledTimeIntervals, function () {
|
643
|
+
if (targetMoment.isBetween(this[0], this[1])) {
|
644
|
+
found = true;
|
645
|
+
return false;
|
646
|
+
}
|
647
|
+
});
|
648
|
+
if (found) {
|
649
|
+
return false;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
return true;
|
653
|
+
};
|
654
|
+
|
655
|
+
DateTimePicker.prototype._parseInputDate = function _parseInputDate(inputDate) {
|
656
|
+
if (this._options.parseInputDate === undefined) {
|
657
|
+
if (!moment.isMoment(inputDate)) {
|
658
|
+
inputDate = this.getMoment(inputDate);
|
659
|
+
}
|
660
|
+
} else {
|
661
|
+
inputDate = this._options.parseInputDate(inputDate);
|
662
|
+
}
|
663
|
+
//inputDate.locale(this.options.locale);
|
664
|
+
return inputDate;
|
665
|
+
};
|
666
|
+
|
667
|
+
DateTimePicker.prototype._keydown = function _keydown(e) {
|
668
|
+
var handler = null,
|
669
|
+
index = void 0,
|
670
|
+
index2 = void 0,
|
671
|
+
keyBindKeys = void 0,
|
672
|
+
allModifiersPressed = void 0;
|
673
|
+
var pressedKeys = [],
|
674
|
+
pressedModifiers = {},
|
675
|
+
currentKey = e.which,
|
676
|
+
pressed = 'p';
|
677
|
+
|
678
|
+
keyState[currentKey] = pressed;
|
679
|
+
|
680
|
+
for (index in keyState) {
|
681
|
+
if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {
|
682
|
+
pressedKeys.push(index);
|
683
|
+
if (parseInt(index, 10) !== currentKey) {
|
684
|
+
pressedModifiers[index] = true;
|
685
|
+
}
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
689
|
+
for (index in this._options.keyBinds) {
|
690
|
+
if (this._options.keyBinds.hasOwnProperty(index) && typeof this._options.keyBinds[index] === 'function') {
|
691
|
+
keyBindKeys = index.split(' ');
|
692
|
+
if (keyBindKeys.length === pressedKeys.length && KeyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {
|
693
|
+
allModifiersPressed = true;
|
694
|
+
for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {
|
695
|
+
if (!(KeyMap[keyBindKeys[index2]] in pressedModifiers)) {
|
696
|
+
allModifiersPressed = false;
|
697
|
+
break;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
if (allModifiersPressed) {
|
701
|
+
handler = this._options.keyBinds[index];
|
702
|
+
break;
|
703
|
+
}
|
704
|
+
}
|
705
|
+
}
|
706
|
+
}
|
707
|
+
|
708
|
+
if (handler) {
|
709
|
+
if (handler.call(this)) {
|
710
|
+
e.stopPropagation();
|
711
|
+
e.preventDefault();
|
712
|
+
}
|
713
|
+
}
|
714
|
+
};
|
715
|
+
|
716
|
+
//noinspection JSMethodCanBeStatic,SpellCheckingInspection
|
717
|
+
|
718
|
+
|
719
|
+
DateTimePicker.prototype._keyup = function _keyup(e) {
|
720
|
+
keyState[e.which] = 'r';
|
721
|
+
if (keyPressHandled[e.which]) {
|
722
|
+
keyPressHandled[e.which] = false;
|
723
|
+
e.stopPropagation();
|
724
|
+
e.preventDefault();
|
725
|
+
}
|
726
|
+
};
|
727
|
+
|
728
|
+
DateTimePicker.prototype._indexGivenDates = function _indexGivenDates(givenDatesArray) {
|
729
|
+
// Store given enabledDates and disabledDates as keys.
|
730
|
+
// This way we can check their existence in O(1) time instead of looping through whole array.
|
731
|
+
// (for example: options.enabledDates['2014-02-27'] === true)
|
732
|
+
var givenDatesIndexed = {},
|
733
|
+
self = this;
|
734
|
+
$.each(givenDatesArray, function () {
|
735
|
+
var dDate = self._parseInputDate(this);
|
736
|
+
if (dDate.isValid()) {
|
737
|
+
givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
|
738
|
+
}
|
739
|
+
});
|
740
|
+
return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;
|
741
|
+
};
|
742
|
+
|
743
|
+
DateTimePicker.prototype._indexGivenHours = function _indexGivenHours(givenHoursArray) {
|
744
|
+
// Store given enabledHours and disabledHours as keys.
|
745
|
+
// This way we can check their existence in O(1) time instead of looping through whole array.
|
746
|
+
// (for example: options.enabledHours['2014-02-27'] === true)
|
747
|
+
var givenHoursIndexed = {};
|
748
|
+
$.each(givenHoursArray, function () {
|
749
|
+
givenHoursIndexed[this] = true;
|
750
|
+
});
|
751
|
+
return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;
|
752
|
+
};
|
753
|
+
|
754
|
+
DateTimePicker.prototype._initFormatting = function _initFormatting() {
|
755
|
+
var format = this._options.format || 'L LT',
|
756
|
+
self = this;
|
757
|
+
|
758
|
+
this.actualFormat = format.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
|
759
|
+
return self._dates[0].localeData().longDateFormat(formatInput) || formatInput; //todo taking the first date should be ok
|
760
|
+
});
|
761
|
+
|
762
|
+
this.parseFormats = this._options.extraFormats ? this._options.extraFormats.slice() : [];
|
763
|
+
if (this.parseFormats.indexOf(format) < 0 && this.parseFormats.indexOf(this.actualFormat) < 0) {
|
764
|
+
this.parseFormats.push(this.actualFormat);
|
765
|
+
}
|
766
|
+
|
767
|
+
this.use24Hours = this.actualFormat.toLowerCase().indexOf('a') < 1 && this.actualFormat.replace(/\[.*?]/g, '').indexOf('h') < 1;
|
768
|
+
|
769
|
+
if (this._isEnabled('y')) {
|
770
|
+
this.MinViewModeNumber = 2;
|
771
|
+
}
|
772
|
+
if (this._isEnabled('M')) {
|
773
|
+
this.MinViewModeNumber = 1;
|
774
|
+
}
|
775
|
+
if (this._isEnabled('d')) {
|
776
|
+
this.MinViewModeNumber = 0;
|
777
|
+
}
|
778
|
+
|
779
|
+
this.currentViewMode = Math.max(this.MinViewModeNumber, this.currentViewMode);
|
780
|
+
|
781
|
+
if (!this.unset) {
|
782
|
+
this._setValue(this._dates[0], 0);
|
783
|
+
}
|
784
|
+
};
|
785
|
+
|
786
|
+
DateTimePicker.prototype._getLastPickedDate = function _getLastPickedDate() {
|
787
|
+
return this._dates[this._getLastPickedDateIndex()];
|
788
|
+
};
|
789
|
+
|
790
|
+
DateTimePicker.prototype._getLastPickedDateIndex = function _getLastPickedDateIndex() {
|
791
|
+
return this._dates.length - 1;
|
792
|
+
};
|
793
|
+
|
794
|
+
//public
|
795
|
+
|
796
|
+
|
797
|
+
DateTimePicker.prototype.getMoment = function getMoment(d) {
|
798
|
+
var returnMoment = void 0;
|
799
|
+
|
800
|
+
if (d === undefined || d === null) {
|
801
|
+
returnMoment = moment(); //TODO should this use format? and locale?
|
802
|
+
} else if (this._hasTimeZone()) {
|
803
|
+
// There is a string to parse and a default time zone
|
804
|
+
// parse with the tz function which takes a default time zone if it is not in the format string
|
805
|
+
returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone);
|
806
|
+
} else {
|
807
|
+
returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict);
|
808
|
+
}
|
809
|
+
|
810
|
+
if (this._hasTimeZone()) {
|
811
|
+
returnMoment.tz(this._options.timeZone);
|
812
|
+
}
|
813
|
+
|
814
|
+
return returnMoment;
|
815
|
+
};
|
816
|
+
|
817
|
+
DateTimePicker.prototype.toggle = function toggle() {
|
818
|
+
return this.widget ? this.hide() : this.show();
|
819
|
+
};
|
820
|
+
|
821
|
+
DateTimePicker.prototype.ignoreReadonly = function ignoreReadonly(_ignoreReadonly) {
|
822
|
+
if (arguments.length === 0) {
|
823
|
+
return this._options.ignoreReadonly;
|
824
|
+
}
|
825
|
+
if (typeof _ignoreReadonly !== 'boolean') {
|
826
|
+
throw new TypeError('ignoreReadonly () expects a boolean parameter');
|
827
|
+
}
|
828
|
+
this._options.ignoreReadonly = _ignoreReadonly;
|
829
|
+
};
|
830
|
+
|
831
|
+
DateTimePicker.prototype.options = function options(newOptions) {
|
832
|
+
if (arguments.length === 0) {
|
833
|
+
return $.extend(true, {}, this._options);
|
834
|
+
}
|
835
|
+
|
836
|
+
if (!(newOptions instanceof Object)) {
|
837
|
+
throw new TypeError('options() this.options parameter should be an object');
|
838
|
+
}
|
839
|
+
$.extend(true, this._options, newOptions);
|
840
|
+
var self = this;
|
841
|
+
$.each(this._options, function (key, value) {
|
842
|
+
if (self[key] !== undefined) {
|
843
|
+
self[key](value);
|
844
|
+
}
|
845
|
+
});
|
846
|
+
};
|
847
|
+
|
848
|
+
DateTimePicker.prototype.date = function date(newDate, index) {
|
849
|
+
index = index || 0;
|
850
|
+
if (arguments.length === 0) {
|
851
|
+
if (this.unset) {
|
852
|
+
return null;
|
853
|
+
}
|
854
|
+
if (this._options.allowMultidate) {
|
855
|
+
return this._dates.join(this._options.multidateSeparator);
|
856
|
+
} else {
|
857
|
+
return this._dates[index].clone();
|
858
|
+
}
|
859
|
+
}
|
860
|
+
|
861
|
+
if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
|
862
|
+
throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
|
863
|
+
}
|
864
|
+
|
865
|
+
this._setValue(newDate === null ? null : this._parseInputDate(newDate), index);
|
866
|
+
};
|
867
|
+
|
868
|
+
DateTimePicker.prototype.format = function format(newFormat) {
|
869
|
+
if (arguments.length === 0) {
|
870
|
+
return this._options.format;
|
871
|
+
}
|
872
|
+
|
873
|
+
if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
|
874
|
+
throw new TypeError('format() expects a string or boolean:false parameter ' + newFormat);
|
875
|
+
}
|
876
|
+
|
877
|
+
this._options.format = newFormat;
|
878
|
+
if (this.actualFormat) {
|
879
|
+
this._initFormatting(); // reinitialize formatting
|
880
|
+
}
|
881
|
+
};
|
882
|
+
|
883
|
+
DateTimePicker.prototype.timeZone = function timeZone(newZone) {
|
884
|
+
if (arguments.length === 0) {
|
885
|
+
return this._options.timeZone;
|
886
|
+
}
|
887
|
+
|
888
|
+
if (typeof newZone !== 'string') {
|
889
|
+
throw new TypeError('newZone() expects a string parameter');
|
890
|
+
}
|
891
|
+
|
892
|
+
this._options.timeZone = newZone;
|
893
|
+
};
|
894
|
+
|
895
|
+
DateTimePicker.prototype.dayViewHeaderFormat = function dayViewHeaderFormat(newFormat) {
|
896
|
+
if (arguments.length === 0) {
|
897
|
+
return this._options.dayViewHeaderFormat;
|
898
|
+
}
|
899
|
+
|
900
|
+
if (typeof newFormat !== 'string') {
|
901
|
+
throw new TypeError('dayViewHeaderFormat() expects a string parameter');
|
902
|
+
}
|
903
|
+
|
904
|
+
this._options.dayViewHeaderFormat = newFormat;
|
905
|
+
};
|
906
|
+
|
907
|
+
DateTimePicker.prototype.extraFormats = function extraFormats(formats) {
|
908
|
+
if (arguments.length === 0) {
|
909
|
+
return this._options.extraFormats;
|
910
|
+
}
|
911
|
+
|
912
|
+
if (formats !== false && !(formats instanceof Array)) {
|
913
|
+
throw new TypeError('extraFormats() expects an array or false parameter');
|
914
|
+
}
|
915
|
+
|
916
|
+
this._options.extraFormats = formats;
|
917
|
+
if (this.parseFormats) {
|
918
|
+
this._initFormatting(); // reinit formatting
|
919
|
+
}
|
920
|
+
};
|
921
|
+
|
922
|
+
DateTimePicker.prototype.disabledDates = function disabledDates(dates) {
|
923
|
+
if (arguments.length === 0) {
|
924
|
+
return this._options.disabledDates ? $.extend({}, this._options.disabledDates) : this._options.disabledDates;
|
925
|
+
}
|
926
|
+
|
927
|
+
if (!dates) {
|
928
|
+
this._options.disabledDates = false;
|
929
|
+
this._update();
|
930
|
+
return true;
|
931
|
+
}
|
932
|
+
if (!(dates instanceof Array)) {
|
933
|
+
throw new TypeError('disabledDates() expects an array parameter');
|
934
|
+
}
|
935
|
+
this._options.disabledDates = this._indexGivenDates(dates);
|
936
|
+
this._options.enabledDates = false;
|
937
|
+
this._update();
|
938
|
+
};
|
939
|
+
|
940
|
+
DateTimePicker.prototype.enabledDates = function enabledDates(dates) {
|
941
|
+
if (arguments.length === 0) {
|
942
|
+
return this._options.enabledDates ? $.extend({}, this._options.enabledDates) : this._options.enabledDates;
|
943
|
+
}
|
944
|
+
|
945
|
+
if (!dates) {
|
946
|
+
this._options.enabledDates = false;
|
947
|
+
this._update();
|
948
|
+
return true;
|
949
|
+
}
|
950
|
+
if (!(dates instanceof Array)) {
|
951
|
+
throw new TypeError('enabledDates() expects an array parameter');
|
952
|
+
}
|
953
|
+
this._options.enabledDates = this._indexGivenDates(dates);
|
954
|
+
this._options.disabledDates = false;
|
955
|
+
this._update();
|
956
|
+
};
|
957
|
+
|
958
|
+
DateTimePicker.prototype.daysOfWeekDisabled = function daysOfWeekDisabled(_daysOfWeekDisabled) {
|
959
|
+
if (arguments.length === 0) {
|
960
|
+
return this._options.daysOfWeekDisabled.splice(0);
|
961
|
+
}
|
962
|
+
|
963
|
+
if (typeof _daysOfWeekDisabled === 'boolean' && !_daysOfWeekDisabled) {
|
964
|
+
this._options.daysOfWeekDisabled = false;
|
965
|
+
this._update();
|
966
|
+
return true;
|
967
|
+
}
|
968
|
+
|
969
|
+
if (!(_daysOfWeekDisabled instanceof Array)) {
|
970
|
+
throw new TypeError('daysOfWeekDisabled() expects an array parameter');
|
971
|
+
}
|
972
|
+
this._options.daysOfWeekDisabled = _daysOfWeekDisabled.reduce(function (previousValue, currentValue) {
|
973
|
+
currentValue = parseInt(currentValue, 10);
|
974
|
+
if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {
|
975
|
+
return previousValue;
|
976
|
+
}
|
977
|
+
if (previousValue.indexOf(currentValue) === -1) {
|
978
|
+
previousValue.push(currentValue);
|
979
|
+
}
|
980
|
+
return previousValue;
|
981
|
+
}, []).sort();
|
982
|
+
if (this._options.useCurrent && !this._options.keepInvalid) {
|
983
|
+
for (var i = 0; i < this._dates.length; i++) {
|
984
|
+
var tries = 0;
|
985
|
+
while (!this._isValid(this._dates[i], 'd')) {
|
986
|
+
this._dates[i].add(1, 'd');
|
987
|
+
if (tries === 31) {
|
988
|
+
throw 'Tried 31 times to find a valid date';
|
989
|
+
}
|
990
|
+
tries++;
|
991
|
+
}
|
992
|
+
this._setValue(this._dates[i], i);
|
993
|
+
}
|
994
|
+
}
|
995
|
+
this._update();
|
996
|
+
};
|
997
|
+
|
998
|
+
DateTimePicker.prototype.maxDate = function maxDate(_maxDate) {
|
999
|
+
if (arguments.length === 0) {
|
1000
|
+
return this._options.maxDate ? this._options.maxDate.clone() : this._options.maxDate;
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
if (typeof _maxDate === 'boolean' && _maxDate === false) {
|
1004
|
+
this._options.maxDate = false;
|
1005
|
+
this._update();
|
1006
|
+
return true;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
if (typeof _maxDate === 'string') {
|
1010
|
+
if (_maxDate === 'now' || _maxDate === 'moment') {
|
1011
|
+
_maxDate = this.getMoment();
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
var parsedDate = this._parseInputDate(_maxDate);
|
1016
|
+
|
1017
|
+
if (!parsedDate.isValid()) {
|
1018
|
+
throw new TypeError('maxDate() Could not parse date parameter: ' + _maxDate);
|
1019
|
+
}
|
1020
|
+
if (this._options.minDate && parsedDate.isBefore(this._options.minDate)) {
|
1021
|
+
throw new TypeError('maxDate() date parameter is before this.options.minDate: ' + parsedDate.format(this.actualFormat));
|
1022
|
+
}
|
1023
|
+
this._options.maxDate = parsedDate;
|
1024
|
+
for (var i = 0; i < this._dates.length; i++) {
|
1025
|
+
if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isAfter(_maxDate)) {
|
1026
|
+
this._setValue(this._options.maxDate, i);
|
1027
|
+
}
|
1028
|
+
}
|
1029
|
+
if (this._viewDate.isAfter(parsedDate)) {
|
1030
|
+
this._viewDate = parsedDate.clone().subtract(this._options.stepping, 'm');
|
1031
|
+
}
|
1032
|
+
this._update();
|
1033
|
+
};
|
1034
|
+
|
1035
|
+
DateTimePicker.prototype.minDate = function minDate(_minDate) {
|
1036
|
+
if (arguments.length === 0) {
|
1037
|
+
return this._options.minDate ? this._options.minDate.clone() : this._options.minDate;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
if (typeof _minDate === 'boolean' && _minDate === false) {
|
1041
|
+
this._options.minDate = false;
|
1042
|
+
this._update();
|
1043
|
+
return true;
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
if (typeof _minDate === 'string') {
|
1047
|
+
if (_minDate === 'now' || _minDate === 'moment') {
|
1048
|
+
_minDate = this.getMoment();
|
1049
|
+
}
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
var parsedDate = this._parseInputDate(_minDate);
|
1053
|
+
|
1054
|
+
if (!parsedDate.isValid()) {
|
1055
|
+
throw new TypeError('minDate() Could not parse date parameter: ' + _minDate);
|
1056
|
+
}
|
1057
|
+
if (this._options.maxDate && parsedDate.isAfter(this._options.maxDate)) {
|
1058
|
+
throw new TypeError('minDate() date parameter is after this.options.maxDate: ' + parsedDate.format(this.actualFormat));
|
1059
|
+
}
|
1060
|
+
this._options.minDate = parsedDate;
|
1061
|
+
for (var i = 0; i < this._dates.length; i++) {
|
1062
|
+
if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isBefore(_minDate)) {
|
1063
|
+
this._setValue(this._options.minDate, i);
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
if (this._viewDate.isBefore(parsedDate)) {
|
1067
|
+
this._viewDate = parsedDate.clone().add(this._options.stepping, 'm');
|
1068
|
+
}
|
1069
|
+
this._update();
|
1070
|
+
};
|
1071
|
+
|
1072
|
+
DateTimePicker.prototype.defaultDate = function defaultDate(_defaultDate) {
|
1073
|
+
if (arguments.length === 0) {
|
1074
|
+
return this._options.defaultDate ? this._options.defaultDate.clone() : this._options.defaultDate;
|
1075
|
+
}
|
1076
|
+
if (!_defaultDate) {
|
1077
|
+
this._options.defaultDate = false;
|
1078
|
+
return true;
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
if (typeof _defaultDate === 'string') {
|
1082
|
+
if (_defaultDate === 'now' || _defaultDate === 'moment') {
|
1083
|
+
_defaultDate = this.getMoment();
|
1084
|
+
} else {
|
1085
|
+
_defaultDate = this.getMoment(_defaultDate);
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
var parsedDate = this._parseInputDate(_defaultDate);
|
1090
|
+
if (!parsedDate.isValid()) {
|
1091
|
+
throw new TypeError('defaultDate() Could not parse date parameter: ' + _defaultDate);
|
1092
|
+
}
|
1093
|
+
if (!this._isValid(parsedDate)) {
|
1094
|
+
throw new TypeError('defaultDate() date passed is invalid according to component setup validations');
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
this._options.defaultDate = parsedDate;
|
1098
|
+
|
1099
|
+
if (this._options.defaultDate && this._options.inline || this.input !== undefined && this.input.val().trim() === '') {
|
1100
|
+
this._setValue(this._options.defaultDate, 0);
|
1101
|
+
}
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
DateTimePicker.prototype.locale = function locale(_locale) {
|
1105
|
+
if (arguments.length === 0) {
|
1106
|
+
return this._options.locale;
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
if (!moment.localeData(_locale)) {
|
1110
|
+
throw new TypeError('locale() locale ' + _locale + ' is not loaded from moment locales!');
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
this._options.locale = _locale;
|
1114
|
+
|
1115
|
+
for (var i = 0; i < this._dates.length; i++) {
|
1116
|
+
this._dates[i].locale(this._options.locale);
|
1117
|
+
}
|
1118
|
+
this._viewDate.locale(this._options.locale);
|
1119
|
+
|
1120
|
+
if (this.actualFormat) {
|
1121
|
+
this._initFormatting(); // reinitialize formatting
|
1122
|
+
}
|
1123
|
+
if (this.widget) {
|
1124
|
+
this.hide();
|
1125
|
+
this.show();
|
1126
|
+
}
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
DateTimePicker.prototype.stepping = function stepping(_stepping) {
|
1130
|
+
if (arguments.length === 0) {
|
1131
|
+
return this._options.stepping;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
_stepping = parseInt(_stepping, 10);
|
1135
|
+
if (isNaN(_stepping) || _stepping < 1) {
|
1136
|
+
_stepping = 1;
|
1137
|
+
}
|
1138
|
+
this._options.stepping = _stepping;
|
1139
|
+
};
|
1140
|
+
|
1141
|
+
DateTimePicker.prototype.useCurrent = function useCurrent(_useCurrent) {
|
1142
|
+
var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];
|
1143
|
+
if (arguments.length === 0) {
|
1144
|
+
return this._options.useCurrent;
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
if (typeof _useCurrent !== 'boolean' && typeof _useCurrent !== 'string') {
|
1148
|
+
throw new TypeError('useCurrent() expects a boolean or string parameter');
|
1149
|
+
}
|
1150
|
+
if (typeof _useCurrent === 'string' && useCurrentOptions.indexOf(_useCurrent.toLowerCase()) === -1) {
|
1151
|
+
throw new TypeError('useCurrent() expects a string parameter of ' + useCurrentOptions.join(', '));
|
1152
|
+
}
|
1153
|
+
this._options.useCurrent = _useCurrent;
|
1154
|
+
};
|
1155
|
+
|
1156
|
+
DateTimePicker.prototype.collapse = function collapse(_collapse) {
|
1157
|
+
if (arguments.length === 0) {
|
1158
|
+
return this._options.collapse;
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
if (typeof _collapse !== 'boolean') {
|
1162
|
+
throw new TypeError('collapse() expects a boolean parameter');
|
1163
|
+
}
|
1164
|
+
if (this._options.collapse === _collapse) {
|
1165
|
+
return true;
|
1166
|
+
}
|
1167
|
+
this._options.collapse = _collapse;
|
1168
|
+
if (this.widget) {
|
1169
|
+
this.hide();
|
1170
|
+
this.show();
|
1171
|
+
}
|
1172
|
+
};
|
1173
|
+
|
1174
|
+
DateTimePicker.prototype.icons = function icons(_icons) {
|
1175
|
+
if (arguments.length === 0) {
|
1176
|
+
return $.extend({}, this._options.icons);
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
if (!(_icons instanceof Object)) {
|
1180
|
+
throw new TypeError('icons() expects parameter to be an Object');
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
$.extend(this._options.icons, _icons);
|
1184
|
+
|
1185
|
+
if (this.widget) {
|
1186
|
+
this.hide();
|
1187
|
+
this.show();
|
1188
|
+
}
|
1189
|
+
};
|
1190
|
+
|
1191
|
+
DateTimePicker.prototype.tooltips = function tooltips(_tooltips) {
|
1192
|
+
if (arguments.length === 0) {
|
1193
|
+
return $.extend({}, this._options.tooltips);
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
if (!(_tooltips instanceof Object)) {
|
1197
|
+
throw new TypeError('tooltips() expects parameter to be an Object');
|
1198
|
+
}
|
1199
|
+
$.extend(this._options.tooltips, _tooltips);
|
1200
|
+
if (this.widget) {
|
1201
|
+
this.hide();
|
1202
|
+
this.show();
|
1203
|
+
}
|
1204
|
+
};
|
1205
|
+
|
1206
|
+
DateTimePicker.prototype.useStrict = function useStrict(_useStrict) {
|
1207
|
+
if (arguments.length === 0) {
|
1208
|
+
return this._options.useStrict;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
if (typeof _useStrict !== 'boolean') {
|
1212
|
+
throw new TypeError('useStrict() expects a boolean parameter');
|
1213
|
+
}
|
1214
|
+
this._options.useStrict = _useStrict;
|
1215
|
+
};
|
1216
|
+
|
1217
|
+
DateTimePicker.prototype.sideBySide = function sideBySide(_sideBySide) {
|
1218
|
+
if (arguments.length === 0) {
|
1219
|
+
return this._options.sideBySide;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
if (typeof _sideBySide !== 'boolean') {
|
1223
|
+
throw new TypeError('sideBySide() expects a boolean parameter');
|
1224
|
+
}
|
1225
|
+
this._options.sideBySide = _sideBySide;
|
1226
|
+
if (this.widget) {
|
1227
|
+
this.hide();
|
1228
|
+
this.show();
|
1229
|
+
}
|
1230
|
+
};
|
1231
|
+
|
1232
|
+
DateTimePicker.prototype.viewMode = function viewMode(_viewMode) {
|
1233
|
+
if (arguments.length === 0) {
|
1234
|
+
return this._options.viewMode;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
if (typeof _viewMode !== 'string') {
|
1238
|
+
throw new TypeError('viewMode() expects a string parameter');
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
if (DateTimePicker.ViewModes.indexOf(_viewMode) === -1) {
|
1242
|
+
throw new TypeError('viewMode() parameter must be one of (' + DateTimePicker.ViewModes.join(', ') + ') value');
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
this._options.viewMode = _viewMode;
|
1246
|
+
this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, this.MinViewModeNumber);
|
1247
|
+
|
1248
|
+
this._showMode();
|
1249
|
+
};
|
1250
|
+
|
1251
|
+
DateTimePicker.prototype.calendarWeeks = function calendarWeeks(_calendarWeeks) {
|
1252
|
+
if (arguments.length === 0) {
|
1253
|
+
return this._options.calendarWeeks;
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
if (typeof _calendarWeeks !== 'boolean') {
|
1257
|
+
throw new TypeError('calendarWeeks() expects parameter to be a boolean value');
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
this._options.calendarWeeks = _calendarWeeks;
|
1261
|
+
this._update();
|
1262
|
+
};
|
1263
|
+
|
1264
|
+
DateTimePicker.prototype.buttons = function buttons(_buttons) {
|
1265
|
+
if (arguments.length === 0) {
|
1266
|
+
return $.extend({}, this._options.buttons);
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
if (!(_buttons instanceof Object)) {
|
1270
|
+
throw new TypeError('buttons() expects parameter to be an Object');
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
$.extend(this._options.buttons, _buttons);
|
1274
|
+
|
1275
|
+
if (typeof this._options.buttons.showToday !== 'boolean') {
|
1276
|
+
throw new TypeError('buttons.showToday expects a boolean parameter');
|
1277
|
+
}
|
1278
|
+
if (typeof this._options.buttons.showClear !== 'boolean') {
|
1279
|
+
throw new TypeError('buttons.showClear expects a boolean parameter');
|
1280
|
+
}
|
1281
|
+
if (typeof this._options.buttons.showClose !== 'boolean') {
|
1282
|
+
throw new TypeError('buttons.showClose expects a boolean parameter');
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
if (this.widget) {
|
1286
|
+
this.hide();
|
1287
|
+
this.show();
|
1288
|
+
}
|
1289
|
+
};
|
1290
|
+
|
1291
|
+
DateTimePicker.prototype.keepOpen = function keepOpen(_keepOpen) {
|
1292
|
+
if (arguments.length === 0) {
|
1293
|
+
return this._options.keepOpen;
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
if (typeof _keepOpen !== 'boolean') {
|
1297
|
+
throw new TypeError('keepOpen() expects a boolean parameter');
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
this._options.keepOpen = _keepOpen;
|
1301
|
+
};
|
1302
|
+
|
1303
|
+
DateTimePicker.prototype.focusOnShow = function focusOnShow(_focusOnShow) {
|
1304
|
+
if (arguments.length === 0) {
|
1305
|
+
return this._options.focusOnShow;
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
if (typeof _focusOnShow !== 'boolean') {
|
1309
|
+
throw new TypeError('focusOnShow() expects a boolean parameter');
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
this._options.focusOnShow = _focusOnShow;
|
1313
|
+
};
|
1314
|
+
|
1315
|
+
DateTimePicker.prototype.inline = function inline(_inline) {
|
1316
|
+
if (arguments.length === 0) {
|
1317
|
+
return this._options.inline;
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
if (typeof _inline !== 'boolean') {
|
1321
|
+
throw new TypeError('inline() expects a boolean parameter');
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
this._options.inline = _inline;
|
1325
|
+
};
|
1326
|
+
|
1327
|
+
DateTimePicker.prototype.clear = function clear() {
|
1328
|
+
this._setValue(null); //todo
|
1329
|
+
};
|
1330
|
+
|
1331
|
+
DateTimePicker.prototype.keyBinds = function keyBinds(_keyBinds) {
|
1332
|
+
if (arguments.length === 0) {
|
1333
|
+
return this._options.keyBinds;
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
this._options.keyBinds = _keyBinds;
|
1337
|
+
};
|
1338
|
+
|
1339
|
+
DateTimePicker.prototype.debug = function debug(_debug) {
|
1340
|
+
if (typeof _debug !== 'boolean') {
|
1341
|
+
throw new TypeError('debug() expects a boolean parameter');
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
this._options.debug = _debug;
|
1345
|
+
};
|
1346
|
+
|
1347
|
+
DateTimePicker.prototype.allowInputToggle = function allowInputToggle(_allowInputToggle) {
|
1348
|
+
if (arguments.length === 0) {
|
1349
|
+
return this._options.allowInputToggle;
|
1350
|
+
}
|
1351
|
+
|
1352
|
+
if (typeof _allowInputToggle !== 'boolean') {
|
1353
|
+
throw new TypeError('allowInputToggle() expects a boolean parameter');
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
this._options.allowInputToggle = _allowInputToggle;
|
1357
|
+
};
|
1358
|
+
|
1359
|
+
DateTimePicker.prototype.keepInvalid = function keepInvalid(_keepInvalid) {
|
1360
|
+
if (arguments.length === 0) {
|
1361
|
+
return this._options.keepInvalid;
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
if (typeof _keepInvalid !== 'boolean') {
|
1365
|
+
throw new TypeError('keepInvalid() expects a boolean parameter');
|
1366
|
+
}
|
1367
|
+
this._options.keepInvalid = _keepInvalid;
|
1368
|
+
};
|
1369
|
+
|
1370
|
+
DateTimePicker.prototype.datepickerInput = function datepickerInput(_datepickerInput) {
|
1371
|
+
if (arguments.length === 0) {
|
1372
|
+
return this._options.datepickerInput;
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
if (typeof _datepickerInput !== 'string') {
|
1376
|
+
throw new TypeError('datepickerInput() expects a string parameter');
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
this._options.datepickerInput = _datepickerInput;
|
1380
|
+
};
|
1381
|
+
|
1382
|
+
DateTimePicker.prototype.parseInputDate = function parseInputDate(_parseInputDate2) {
|
1383
|
+
if (arguments.length === 0) {
|
1384
|
+
return this._options.parseInputDate;
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
if (typeof _parseInputDate2 !== 'function') {
|
1388
|
+
throw new TypeError('parseInputDate() should be as function');
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
this._options.parseInputDate = _parseInputDate2;
|
1392
|
+
};
|
1393
|
+
|
1394
|
+
DateTimePicker.prototype.disabledTimeIntervals = function disabledTimeIntervals(_disabledTimeIntervals) {
|
1395
|
+
if (arguments.length === 0) {
|
1396
|
+
return this._options.disabledTimeIntervals ? $.extend({}, this._options.disabledTimeIntervals) : this._options.disabledTimeIntervals;
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
if (!_disabledTimeIntervals) {
|
1400
|
+
this._options.disabledTimeIntervals = false;
|
1401
|
+
this._update();
|
1402
|
+
return true;
|
1403
|
+
}
|
1404
|
+
if (!(_disabledTimeIntervals instanceof Array)) {
|
1405
|
+
throw new TypeError('disabledTimeIntervals() expects an array parameter');
|
1406
|
+
}
|
1407
|
+
this._options.disabledTimeIntervals = _disabledTimeIntervals;
|
1408
|
+
this._update();
|
1409
|
+
};
|
1410
|
+
|
1411
|
+
DateTimePicker.prototype.disabledHours = function disabledHours(hours) {
|
1412
|
+
if (arguments.length === 0) {
|
1413
|
+
return this._options.disabledHours ? $.extend({}, this._options.disabledHours) : this._options.disabledHours;
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
if (!hours) {
|
1417
|
+
this._options.disabledHours = false;
|
1418
|
+
this._update();
|
1419
|
+
return true;
|
1420
|
+
}
|
1421
|
+
if (!(hours instanceof Array)) {
|
1422
|
+
throw new TypeError('disabledHours() expects an array parameter');
|
1423
|
+
}
|
1424
|
+
this._options.disabledHours = this._indexGivenHours(hours);
|
1425
|
+
this._options.enabledHours = false;
|
1426
|
+
if (this._options.useCurrent && !this._options.keepInvalid) {
|
1427
|
+
for (var i = 0; i < this._dates.length; i++) {
|
1428
|
+
var tries = 0;
|
1429
|
+
while (!this._isValid(this._dates[i], 'h')) {
|
1430
|
+
this._dates[i].add(1, 'h');
|
1431
|
+
if (tries === 24) {
|
1432
|
+
throw 'Tried 24 times to find a valid date';
|
1433
|
+
}
|
1434
|
+
tries++;
|
1435
|
+
}
|
1436
|
+
this._setValue(this._dates[i], i);
|
1437
|
+
}
|
1438
|
+
}
|
1439
|
+
this._update();
|
1440
|
+
};
|
1441
|
+
|
1442
|
+
DateTimePicker.prototype.enabledHours = function enabledHours(hours) {
|
1443
|
+
if (arguments.length === 0) {
|
1444
|
+
return this._options.enabledHours ? $.extend({}, this._options.enabledHours) : this._options.enabledHours;
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
if (!hours) {
|
1448
|
+
this._options.enabledHours = false;
|
1449
|
+
this._update();
|
1450
|
+
return true;
|
1451
|
+
}
|
1452
|
+
if (!(hours instanceof Array)) {
|
1453
|
+
throw new TypeError('enabledHours() expects an array parameter');
|
1454
|
+
}
|
1455
|
+
this._options.enabledHours = this._indexGivenHours(hours);
|
1456
|
+
this._options.disabledHours = false;
|
1457
|
+
if (this._options.useCurrent && !this._options.keepInvalid) {
|
1458
|
+
for (var i = 0; i < this._dates.length; i++) {
|
1459
|
+
var tries = 0;
|
1460
|
+
while (!this._isValid(this._dates[i], 'h')) {
|
1461
|
+
this._dates[i].add(1, 'h');
|
1462
|
+
if (tries === 24) {
|
1463
|
+
throw 'Tried 24 times to find a valid date';
|
1464
|
+
}
|
1465
|
+
tries++;
|
1466
|
+
}
|
1467
|
+
this._setValue(this._dates[i], i);
|
1468
|
+
}
|
1469
|
+
}
|
1470
|
+
this._update();
|
1471
|
+
};
|
1472
|
+
|
1473
|
+
DateTimePicker.prototype.viewDate = function viewDate(newDate) {
|
1474
|
+
if (arguments.length === 0) {
|
1475
|
+
return this._viewDate.clone();
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
if (!newDate) {
|
1479
|
+
this._viewDate = (this._dates[0] || this.getMoment()).clone();
|
1480
|
+
return true;
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
|
1484
|
+
throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
this._viewDate = this._parseInputDate(newDate);
|
1488
|
+
this._viewUpdate();
|
1489
|
+
};
|
1490
|
+
|
1491
|
+
DateTimePicker.prototype.allowMultidate = function allowMultidate(_allowMultidate) {
|
1492
|
+
if (typeof _allowMultidate !== 'boolean') {
|
1493
|
+
throw new TypeError('allowMultidate() expects a boolean parameter');
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
this._options.allowMultidate = _allowMultidate;
|
1497
|
+
};
|
1498
|
+
|
1499
|
+
DateTimePicker.prototype.multidateSeparator = function multidateSeparator(_multidateSeparator) {
|
1500
|
+
if (arguments.length === 0) {
|
1501
|
+
return this._options.multidateSeparator;
|
1502
|
+
}
|
1503
|
+
|
1504
|
+
if (typeof _multidateSeparator !== 'string' || _multidateSeparator.length > 1) {
|
1505
|
+
throw new TypeError('multidateSeparator expects a single character string parameter');
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
this._options.multidateSeparator = _multidateSeparator;
|
1509
|
+
};
|
1510
|
+
|
1511
|
+
_createClass(DateTimePicker, null, [{
|
1512
|
+
key: 'NAME',
|
1513
|
+
get: function get() {
|
1514
|
+
return NAME;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
/**
|
1518
|
+
* @return {string}
|
1519
|
+
*/
|
1520
|
+
|
1521
|
+
}, {
|
1522
|
+
key: 'DATA_KEY',
|
1523
|
+
get: function get() {
|
1524
|
+
return DATA_KEY;
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
/**
|
1528
|
+
* @return {string}
|
1529
|
+
*/
|
1530
|
+
|
1531
|
+
}, {
|
1532
|
+
key: 'EVENT_KEY',
|
1533
|
+
get: function get() {
|
1534
|
+
return EVENT_KEY;
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
/**
|
1538
|
+
* @return {string}
|
1539
|
+
*/
|
1540
|
+
|
1541
|
+
}, {
|
1542
|
+
key: 'DATA_API_KEY',
|
1543
|
+
get: function get() {
|
1544
|
+
return DATA_API_KEY;
|
1545
|
+
}
|
1546
|
+
}, {
|
1547
|
+
key: 'DatePickerModes',
|
1548
|
+
get: function get() {
|
1549
|
+
return DatePickerModes;
|
1550
|
+
}
|
1551
|
+
}, {
|
1552
|
+
key: 'ViewModes',
|
1553
|
+
get: function get() {
|
1554
|
+
return ViewModes;
|
1555
|
+
}
|
1556
|
+
}, {
|
1557
|
+
key: 'Event',
|
1558
|
+
get: function get() {
|
1559
|
+
return Event;
|
1560
|
+
}
|
1561
|
+
}, {
|
1562
|
+
key: 'Selector',
|
1563
|
+
get: function get() {
|
1564
|
+
return Selector;
|
1565
|
+
}
|
1566
|
+
}, {
|
1567
|
+
key: 'Default',
|
1568
|
+
get: function get() {
|
1569
|
+
return Default;
|
1570
|
+
},
|
1571
|
+
set: function set(value) {
|
1572
|
+
Default = value;
|
1573
|
+
}
|
1574
|
+
}, {
|
1575
|
+
key: 'ClassName',
|
1576
|
+
get: function get() {
|
1577
|
+
return ClassName;
|
1578
|
+
}
|
1579
|
+
}]);
|
1580
|
+
|
1581
|
+
return DateTimePicker;
|
1582
|
+
}();
|
1583
|
+
|
1584
|
+
return DateTimePicker;
|
1585
|
+
}(jQuery, moment);
|
1586
|
+
|
1587
|
+
//noinspection JSUnusedGlobalSymbols
|
1588
|
+
/* global DateTimePicker */
|
1589
|
+
var TempusDominusBootstrap4 = function ($) {
|
1590
|
+
// eslint-disable-line no-unused-vars
|
1591
|
+
// ReSharper disable once InconsistentNaming
|
1592
|
+
var JQUERY_NO_CONFLICT = $.fn[DateTimePicker.NAME],
|
1593
|
+
verticalModes = ['top', 'bottom', 'auto'],
|
1594
|
+
horizontalModes = ['left', 'right', 'auto'],
|
1595
|
+
toolbarPlacements = ['default', 'top', 'bottom'],
|
1596
|
+
getSelectorFromElement = function getSelectorFromElement($element) {
|
1597
|
+
var selector = $element.data('target'),
|
1598
|
+
$selector = void 0;
|
1599
|
+
|
1600
|
+
if (!selector) {
|
1601
|
+
selector = $element.attr('href') || '';
|
1602
|
+
selector = /^#[a-z]/i.test(selector) ? selector : null;
|
1603
|
+
}
|
1604
|
+
$selector = $(selector);
|
1605
|
+
if ($selector.length === 0) {
|
1606
|
+
return $selector;
|
1607
|
+
}
|
1608
|
+
|
1609
|
+
if (!$selector.data(DateTimePicker.DATA_KEY)) {
|
1610
|
+
$.extend({}, $selector.data(), $(this).data());
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
return $selector;
|
1614
|
+
};
|
1615
|
+
|
1616
|
+
// ReSharper disable once InconsistentNaming
|
1617
|
+
|
1618
|
+
var TempusDominusBootstrap4 = function (_DateTimePicker) {
|
1619
|
+
_inherits(TempusDominusBootstrap4, _DateTimePicker);
|
1620
|
+
|
1621
|
+
function TempusDominusBootstrap4(element, options) {
|
1622
|
+
_classCallCheck(this, TempusDominusBootstrap4);
|
1623
|
+
|
1624
|
+
var _this = _possibleConstructorReturn(this, _DateTimePicker.call(this, element, options));
|
1625
|
+
|
1626
|
+
_this._init();
|
1627
|
+
return _this;
|
1628
|
+
}
|
1629
|
+
|
1630
|
+
TempusDominusBootstrap4.prototype._init = function _init() {
|
1631
|
+
if (this._element.hasClass('input-group')) {
|
1632
|
+
var datepickerButton = this._element.find('.datepickerbutton');
|
1633
|
+
if (datepickerButton.length === 0) {
|
1634
|
+
this.component = this._element.find('[data-toggle="datetimepicker"]');
|
1635
|
+
} else {
|
1636
|
+
this.component = datepickerButton;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
};
|
1640
|
+
|
1641
|
+
TempusDominusBootstrap4.prototype._getDatePickerTemplate = function _getDatePickerTemplate() {
|
1642
|
+
var headTemplate = $('<thead>').append($('<tr>').append($('<th>').addClass('prev').attr('data-action', 'previous').append($('<span>').addClass(this._options.icons.previous))).append($('<th>').addClass('picker-switch').attr('data-action', 'pickerSwitch').attr('colspan', '' + (this._options.calendarWeeks ? '6' : '5'))).append($('<th>').addClass('next').attr('data-action', 'next').append($('<span>').addClass(this._options.icons.next)))),
|
1643
|
+
contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', '' + (this._options.calendarWeeks ? '8' : '7'))));
|
1644
|
+
|
1645
|
+
return [$('<div>').addClass('datepicker-days').append($('<table>').addClass('table table-sm').append(headTemplate).append($('<tbody>'))), $('<div>').addClass('datepicker-months').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-years').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-decades').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone()))];
|
1646
|
+
};
|
1647
|
+
|
1648
|
+
TempusDominusBootstrap4.prototype._getTimePickerMainTemplate = function _getTimePickerMainTemplate() {
|
1649
|
+
var topRow = $('<tr>'),
|
1650
|
+
middleRow = $('<tr>'),
|
1651
|
+
bottomRow = $('<tr>');
|
1652
|
+
|
1653
|
+
if (this._isEnabled('h')) {
|
1654
|
+
topRow.append($('<td>').append($('<a>').attr({
|
1655
|
+
href: '#',
|
1656
|
+
tabindex: '-1',
|
1657
|
+
'title': this._options.tooltips.incrementHour
|
1658
|
+
}).addClass('btn').attr('data-action', 'incrementHours').append($('<span>').addClass(this._options.icons.up))));
|
1659
|
+
middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({
|
1660
|
+
'data-time-component': 'hours',
|
1661
|
+
'title': this._options.tooltips.pickHour
|
1662
|
+
}).attr('data-action', 'showHours')));
|
1663
|
+
bottomRow.append($('<td>').append($('<a>').attr({
|
1664
|
+
href: '#',
|
1665
|
+
tabindex: '-1',
|
1666
|
+
'title': this._options.tooltips.decrementHour
|
1667
|
+
}).addClass('btn').attr('data-action', 'decrementHours').append($('<span>').addClass(this._options.icons.down))));
|
1668
|
+
}
|
1669
|
+
if (this._isEnabled('m')) {
|
1670
|
+
if (this._isEnabled('h')) {
|
1671
|
+
topRow.append($('<td>').addClass('separator'));
|
1672
|
+
middleRow.append($('<td>').addClass('separator').html(':'));
|
1673
|
+
bottomRow.append($('<td>').addClass('separator'));
|
1674
|
+
}
|
1675
|
+
topRow.append($('<td>').append($('<a>').attr({
|
1676
|
+
href: '#',
|
1677
|
+
tabindex: '-1',
|
1678
|
+
'title': this._options.tooltips.incrementMinute
|
1679
|
+
}).addClass('btn').attr('data-action', 'incrementMinutes').append($('<span>').addClass(this._options.icons.up))));
|
1680
|
+
middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({
|
1681
|
+
'data-time-component': 'minutes',
|
1682
|
+
'title': this._options.tooltips.pickMinute
|
1683
|
+
}).attr('data-action', 'showMinutes')));
|
1684
|
+
bottomRow.append($('<td>').append($('<a>').attr({
|
1685
|
+
href: '#',
|
1686
|
+
tabindex: '-1',
|
1687
|
+
'title': this._options.tooltips.decrementMinute
|
1688
|
+
}).addClass('btn').attr('data-action', 'decrementMinutes').append($('<span>').addClass(this._options.icons.down))));
|
1689
|
+
}
|
1690
|
+
if (this._isEnabled('s')) {
|
1691
|
+
if (this._isEnabled('m')) {
|
1692
|
+
topRow.append($('<td>').addClass('separator'));
|
1693
|
+
middleRow.append($('<td>').addClass('separator').html(':'));
|
1694
|
+
bottomRow.append($('<td>').addClass('separator'));
|
1695
|
+
}
|
1696
|
+
topRow.append($('<td>').append($('<a>').attr({
|
1697
|
+
href: '#',
|
1698
|
+
tabindex: '-1',
|
1699
|
+
'title': this._options.tooltips.incrementSecond
|
1700
|
+
}).addClass('btn').attr('data-action', 'incrementSeconds').append($('<span>').addClass(this._options.icons.up))));
|
1701
|
+
middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({
|
1702
|
+
'data-time-component': 'seconds',
|
1703
|
+
'title': this._options.tooltips.pickSecond
|
1704
|
+
}).attr('data-action', 'showSeconds')));
|
1705
|
+
bottomRow.append($('<td>').append($('<a>').attr({
|
1706
|
+
href: '#',
|
1707
|
+
tabindex: '-1',
|
1708
|
+
'title': this._options.tooltips.decrementSecond
|
1709
|
+
}).addClass('btn').attr('data-action', 'decrementSeconds').append($('<span>').addClass(this._options.icons.down))));
|
1710
|
+
}
|
1711
|
+
|
1712
|
+
if (!this.use24Hours) {
|
1713
|
+
topRow.append($('<td>').addClass('separator'));
|
1714
|
+
middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({
|
1715
|
+
'data-action': 'togglePeriod',
|
1716
|
+
tabindex: '-1',
|
1717
|
+
'title': this._options.tooltips.togglePeriod
|
1718
|
+
})));
|
1719
|
+
bottomRow.append($('<td>').addClass('separator'));
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));
|
1723
|
+
};
|
1724
|
+
|
1725
|
+
TempusDominusBootstrap4.prototype._getTimePickerTemplate = function _getTimePickerTemplate() {
|
1726
|
+
var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed')),
|
1727
|
+
minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed')),
|
1728
|
+
secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed')),
|
1729
|
+
ret = [this._getTimePickerMainTemplate()];
|
1730
|
+
|
1731
|
+
if (this._isEnabled('h')) {
|
1732
|
+
ret.push(hoursView);
|
1733
|
+
}
|
1734
|
+
if (this._isEnabled('m')) {
|
1735
|
+
ret.push(minutesView);
|
1736
|
+
}
|
1737
|
+
if (this._isEnabled('s')) {
|
1738
|
+
ret.push(secondsView);
|
1739
|
+
}
|
1740
|
+
|
1741
|
+
return ret;
|
1742
|
+
};
|
1743
|
+
|
1744
|
+
TempusDominusBootstrap4.prototype._getToolbar = function _getToolbar() {
|
1745
|
+
var row = [];
|
1746
|
+
if (this._options.buttons.showToday) {
|
1747
|
+
row.push($('<td>').append($('<a>').attr({
|
1748
|
+
href: '#',
|
1749
|
+
tabindex: '-1',
|
1750
|
+
'data-action': 'today',
|
1751
|
+
'title': this._options.tooltips.today
|
1752
|
+
}).append($('<span>').addClass(this._options.icons.today))));
|
1753
|
+
}
|
1754
|
+
if (!this._options.sideBySide && this._hasDate() && this._hasTime()) {
|
1755
|
+
var title = void 0,
|
1756
|
+
icon = void 0;
|
1757
|
+
if (this._options.viewMode === 'times') {
|
1758
|
+
title = this._options.tooltips.selectDate;
|
1759
|
+
icon = this._options.icons.date;
|
1760
|
+
} else {
|
1761
|
+
title = this._options.tooltips.selectTime;
|
1762
|
+
icon = this._options.icons.time;
|
1763
|
+
}
|
1764
|
+
row.push($('<td>').append($('<a>').attr({
|
1765
|
+
href: '#',
|
1766
|
+
tabindex: '-1',
|
1767
|
+
'data-action': 'togglePicker',
|
1768
|
+
'title': title
|
1769
|
+
}).append($('<span>').addClass(icon))));
|
1770
|
+
}
|
1771
|
+
if (this._options.buttons.showClear) {
|
1772
|
+
row.push($('<td>').append($('<a>').attr({
|
1773
|
+
href: '#',
|
1774
|
+
tabindex: '-1',
|
1775
|
+
'data-action': 'clear',
|
1776
|
+
'title': this._options.tooltips.clear
|
1777
|
+
}).append($('<span>').addClass(this._options.icons.clear))));
|
1778
|
+
}
|
1779
|
+
if (this._options.buttons.showClose) {
|
1780
|
+
row.push($('<td>').append($('<a>').attr({
|
1781
|
+
href: '#',
|
1782
|
+
tabindex: '-1',
|
1783
|
+
'data-action': 'close',
|
1784
|
+
'title': this._options.tooltips.close
|
1785
|
+
}).append($('<span>').addClass(this._options.icons.close))));
|
1786
|
+
}
|
1787
|
+
return row.length === 0 ? '' : $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
|
1788
|
+
};
|
1789
|
+
|
1790
|
+
TempusDominusBootstrap4.prototype._getTemplate = function _getTemplate() {
|
1791
|
+
var template = $('<div>').addClass('bootstrap-datetimepicker-widget dropdown-menu'),
|
1792
|
+
dateView = $('<div>').addClass('datepicker').append(this._getDatePickerTemplate()),
|
1793
|
+
timeView = $('<div>').addClass('timepicker').append(this._getTimePickerTemplate()),
|
1794
|
+
content = $('<ul>').addClass('list-unstyled'),
|
1795
|
+
toolbar = $('<li>').addClass('picker-switch' + (this._options.collapse ? ' accordion-toggle' : '')).append(this._getToolbar());
|
1796
|
+
|
1797
|
+
if (this._options.inline) {
|
1798
|
+
template.removeClass('dropdown-menu');
|
1799
|
+
}
|
1800
|
+
|
1801
|
+
if (this.use24Hours) {
|
1802
|
+
template.addClass('usetwentyfour');
|
1803
|
+
}
|
1804
|
+
if (this._isEnabled('s') && !this.use24Hours) {
|
1805
|
+
template.addClass('wider');
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
if (this._options.sideBySide && this._hasDate() && this._hasTime()) {
|
1809
|
+
template.addClass('timepicker-sbs');
|
1810
|
+
if (this._options.toolbarPlacement === 'top') {
|
1811
|
+
template.append(toolbar);
|
1812
|
+
}
|
1813
|
+
template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));
|
1814
|
+
if (this._options.toolbarPlacement === 'bottom' || this._options.toolbarPlacement === 'default') {
|
1815
|
+
template.append(toolbar);
|
1816
|
+
}
|
1817
|
+
return template;
|
1818
|
+
}
|
1819
|
+
|
1820
|
+
if (this._options.toolbarPlacement === 'top') {
|
1821
|
+
content.append(toolbar);
|
1822
|
+
}
|
1823
|
+
if (this._hasDate()) {
|
1824
|
+
content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'times' ? '' : 'show').append(dateView));
|
1825
|
+
}
|
1826
|
+
if (this._options.toolbarPlacement === 'default') {
|
1827
|
+
content.append(toolbar);
|
1828
|
+
}
|
1829
|
+
if (this._hasTime()) {
|
1830
|
+
content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'times' ? 'show' : '').append(timeView));
|
1831
|
+
}
|
1832
|
+
if (this._options.toolbarPlacement === 'bottom') {
|
1833
|
+
content.append(toolbar);
|
1834
|
+
}
|
1835
|
+
return template.append(content);
|
1836
|
+
};
|
1837
|
+
|
1838
|
+
TempusDominusBootstrap4.prototype._place = function _place(e) {
|
1839
|
+
var self = e && e.data && e.data.picker || this,
|
1840
|
+
vertical = self._options.widgetPositioning.vertical,
|
1841
|
+
horizontal = self._options.widgetPositioning.horizontal,
|
1842
|
+
parent = void 0;
|
1843
|
+
var position = (self.component && self.component.length ? self.component : self._element).position(),
|
1844
|
+
offset = (self.component && self.component.length ? self.component : self._element).offset();
|
1845
|
+
if (self._options.widgetParent) {
|
1846
|
+
parent = self._options.widgetParent.append(self.widget);
|
1847
|
+
} else if (self._element.is('input')) {
|
1848
|
+
parent = self._element.after(self.widget).parent();
|
1849
|
+
} else if (self._options.inline) {
|
1850
|
+
parent = self._element.append(self.widget);
|
1851
|
+
return;
|
1852
|
+
} else {
|
1853
|
+
parent = self._element;
|
1854
|
+
self._element.children().first().after(self.widget);
|
1855
|
+
}
|
1856
|
+
|
1857
|
+
// Top and bottom logic
|
1858
|
+
if (vertical === 'auto') {
|
1859
|
+
//noinspection JSValidateTypes
|
1860
|
+
if (offset.top + self.widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && self.widget.height() + self._element.outerHeight() < offset.top) {
|
1861
|
+
vertical = 'top';
|
1862
|
+
} else {
|
1863
|
+
vertical = 'bottom';
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
// Left and right logic
|
1868
|
+
if (horizontal === 'auto') {
|
1869
|
+
if (parent.width() < offset.left + self.widget.outerWidth() / 2 && offset.left + self.widget.outerWidth() > $(window).width()) {
|
1870
|
+
horizontal = 'right';
|
1871
|
+
} else {
|
1872
|
+
horizontal = 'left';
|
1873
|
+
}
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
if (vertical === 'top') {
|
1877
|
+
self.widget.addClass('top').removeClass('bottom');
|
1878
|
+
} else {
|
1879
|
+
self.widget.addClass('bottom').removeClass('top');
|
1880
|
+
}
|
1881
|
+
|
1882
|
+
if (horizontal === 'right') {
|
1883
|
+
self.widget.addClass('float-right');
|
1884
|
+
} else {
|
1885
|
+
self.widget.removeClass('float-right');
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
// find the first parent element that has a relative css positioning
|
1889
|
+
if (parent.css('position') !== 'relative') {
|
1890
|
+
parent = parent.parents().filter(function () {
|
1891
|
+
return $(this).css('position') === 'relative';
|
1892
|
+
}).first();
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
if (parent.length === 0) {
|
1896
|
+
throw new Error('datetimepicker component should be placed within a relative positioned container');
|
1897
|
+
}
|
1898
|
+
|
1899
|
+
self.widget.css({
|
1900
|
+
top: vertical === 'top' ? 'auto' : position.top + self._element.outerHeight() + 'px',
|
1901
|
+
bottom: vertical === 'top' ? parent.outerHeight() - (parent === self._element ? 0 : position.top) + 'px' : 'auto',
|
1902
|
+
left: horizontal === 'left' ? (parent === self._element ? 0 : position.left) + 'px' : 'auto',
|
1903
|
+
right: horizontal === 'left' ? 'auto' : parent.outerWidth() - self._element.outerWidth() - (parent === self._element ? 0 : position.left) + 'px'
|
1904
|
+
});
|
1905
|
+
};
|
1906
|
+
|
1907
|
+
TempusDominusBootstrap4.prototype._fillDow = function _fillDow() {
|
1908
|
+
var row = $('<tr>'),
|
1909
|
+
currentDate = this._viewDate.clone().startOf('w').startOf('d');
|
1910
|
+
|
1911
|
+
if (this._options.calendarWeeks === true) {
|
1912
|
+
row.append($('<th>').addClass('cw').text('#'));
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
while (currentDate.isBefore(this._viewDate.clone().endOf('w'))) {
|
1916
|
+
row.append($('<th>').addClass('dow').text(currentDate.format('dd')));
|
1917
|
+
currentDate.add(1, 'd');
|
1918
|
+
}
|
1919
|
+
this.widget.find('.datepicker-days thead').append(row);
|
1920
|
+
};
|
1921
|
+
|
1922
|
+
TempusDominusBootstrap4.prototype._fillMonths = function _fillMonths() {
|
1923
|
+
var spans = [],
|
1924
|
+
monthsShort = this._viewDate.clone().startOf('y').startOf('d');
|
1925
|
+
while (monthsShort.isSame(this._viewDate, 'y')) {
|
1926
|
+
spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
|
1927
|
+
monthsShort.add(1, 'M');
|
1928
|
+
}
|
1929
|
+
this.widget.find('.datepicker-months td').empty().append(spans);
|
1930
|
+
};
|
1931
|
+
|
1932
|
+
TempusDominusBootstrap4.prototype._updateMonths = function _updateMonths() {
|
1933
|
+
var monthsView = this.widget.find('.datepicker-months'),
|
1934
|
+
monthsViewHeader = monthsView.find('th'),
|
1935
|
+
months = monthsView.find('tbody').find('span'),
|
1936
|
+
self = this;
|
1937
|
+
|
1938
|
+
monthsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevYear);
|
1939
|
+
monthsViewHeader.eq(1).attr('title', this._options.tooltips.selectYear);
|
1940
|
+
monthsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextYear);
|
1941
|
+
|
1942
|
+
monthsView.find('.disabled').removeClass('disabled');
|
1943
|
+
|
1944
|
+
if (!this._isValid(this._viewDate.clone().subtract(1, 'y'), 'y')) {
|
1945
|
+
monthsViewHeader.eq(0).addClass('disabled');
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
monthsViewHeader.eq(1).text(this._viewDate.year());
|
1949
|
+
|
1950
|
+
if (!this._isValid(this._viewDate.clone().add(1, 'y'), 'y')) {
|
1951
|
+
monthsViewHeader.eq(2).addClass('disabled');
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
months.removeClass('active');
|
1955
|
+
if (this._getLastPickedDate().isSame(this._viewDate, 'y') && !this.unset) {
|
1956
|
+
months.eq(this._getLastPickedDate().month()).addClass('active');
|
1957
|
+
}
|
1958
|
+
|
1959
|
+
months.each(function (index) {
|
1960
|
+
if (!self._isValid(self._viewDate.clone().month(index), 'M')) {
|
1961
|
+
$(this).addClass('disabled');
|
1962
|
+
}
|
1963
|
+
});
|
1964
|
+
};
|
1965
|
+
|
1966
|
+
TempusDominusBootstrap4.prototype._getStartEndYear = function _getStartEndYear(factor, year) {
|
1967
|
+
var step = factor / 10,
|
1968
|
+
startYear = Math.floor(year / factor) * factor,
|
1969
|
+
endYear = startYear + step * 9,
|
1970
|
+
focusValue = Math.floor(year / step) * step;
|
1971
|
+
return [startYear, endYear, focusValue];
|
1972
|
+
};
|
1973
|
+
|
1974
|
+
TempusDominusBootstrap4.prototype._updateYears = function _updateYears() {
|
1975
|
+
var yearsView = this.widget.find('.datepicker-years'),
|
1976
|
+
yearsViewHeader = yearsView.find('th'),
|
1977
|
+
yearCaps = this._getStartEndYear(10, this._viewDate.year()),
|
1978
|
+
startYear = this._viewDate.clone().year(yearCaps[0]),
|
1979
|
+
endYear = this._viewDate.clone().year(yearCaps[1]);
|
1980
|
+
var html = '';
|
1981
|
+
|
1982
|
+
yearsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevDecade);
|
1983
|
+
yearsViewHeader.eq(1).attr('title', this._options.tooltips.selectDecade);
|
1984
|
+
yearsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextDecade);
|
1985
|
+
|
1986
|
+
yearsView.find('.disabled').removeClass('disabled');
|
1987
|
+
|
1988
|
+
if (this._options.minDate && this._options.minDate.isAfter(startYear, 'y')) {
|
1989
|
+
yearsViewHeader.eq(0).addClass('disabled');
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
yearsViewHeader.eq(1).text(startYear.year() + '-' + endYear.year());
|
1993
|
+
|
1994
|
+
if (this._options.maxDate && this._options.maxDate.isBefore(endYear, 'y')) {
|
1995
|
+
yearsViewHeader.eq(2).addClass('disabled');
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + (startYear.year() - 1) + '</span>';
|
1999
|
+
while (!startYear.isAfter(endYear, 'y')) {
|
2000
|
+
html += '<span data-action="selectYear" class="year' + (startYear.isSame(this._getLastPickedDate(), 'y') && !this.unset ? ' active' : '') + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
|
2001
|
+
startYear.add(1, 'y');
|
2002
|
+
}
|
2003
|
+
html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
|
2004
|
+
|
2005
|
+
yearsView.find('td').html(html);
|
2006
|
+
};
|
2007
|
+
|
2008
|
+
TempusDominusBootstrap4.prototype._updateDecades = function _updateDecades() {
|
2009
|
+
var decadesView = this.widget.find('.datepicker-decades'),
|
2010
|
+
decadesViewHeader = decadesView.find('th'),
|
2011
|
+
yearCaps = this._getStartEndYear(100, this._viewDate.year()),
|
2012
|
+
startDecade = this._viewDate.clone().year(yearCaps[0]),
|
2013
|
+
endDecade = this._viewDate.clone().year(yearCaps[1]);
|
2014
|
+
var minDateDecade = false,
|
2015
|
+
maxDateDecade = false,
|
2016
|
+
endDecadeYear = void 0,
|
2017
|
+
html = '';
|
2018
|
+
|
2019
|
+
decadesViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevCentury);
|
2020
|
+
decadesViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextCentury);
|
2021
|
+
|
2022
|
+
decadesView.find('.disabled').removeClass('disabled');
|
2023
|
+
|
2024
|
+
if (startDecade.year() === 0 || this._options.minDate && this._options.minDate.isAfter(startDecade, 'y')) {
|
2025
|
+
decadesViewHeader.eq(0).addClass('disabled');
|
2026
|
+
}
|
2027
|
+
|
2028
|
+
decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year());
|
2029
|
+
|
2030
|
+
if (this._options.maxDate && this._options.maxDate.isBefore(endDecade, 'y')) {
|
2031
|
+
decadesViewHeader.eq(2).addClass('disabled');
|
2032
|
+
}
|
2033
|
+
|
2034
|
+
if (startDecade.year() - 10 < 0) {
|
2035
|
+
html += '<span> </span>';
|
2036
|
+
} else {
|
2037
|
+
html += '<span data-action="selectDecade" class="decade old" data-selection="' + (startDecade.year() + 6) + '">' + (startDecade.year() - 10) + '</span>';
|
2038
|
+
}
|
2039
|
+
|
2040
|
+
while (!startDecade.isAfter(endDecade, 'y')) {
|
2041
|
+
endDecadeYear = startDecade.year() + 11;
|
2042
|
+
minDateDecade = this._options.minDate && this._options.minDate.isAfter(startDecade, 'y') && this._options.minDate.year() <= endDecadeYear;
|
2043
|
+
maxDateDecade = this._options.maxDate && this._options.maxDate.isAfter(startDecade, 'y') && this._options.maxDate.year() <= endDecadeYear;
|
2044
|
+
html += '<span data-action="selectDecade" class="decade' + (this._getLastPickedDate().isAfter(startDecade) && this._getLastPickedDate().year() <= endDecadeYear ? ' active' : '') + (!this._isValid(startDecade, 'y') && !minDateDecade && !maxDateDecade ? ' disabled' : '') + '" data-selection="' + (startDecade.year() + 6) + '">' + startDecade.year() + '</span>';
|
2045
|
+
startDecade.add(10, 'y');
|
2046
|
+
}
|
2047
|
+
html += '<span data-action="selectDecade" class="decade old" data-selection="' + (startDecade.year() + 6) + '">' + startDecade.year() + '</span>';
|
2048
|
+
|
2049
|
+
decadesView.find('td').html(html);
|
2050
|
+
};
|
2051
|
+
|
2052
|
+
TempusDominusBootstrap4.prototype._fillDate = function _fillDate() {
|
2053
|
+
var daysView = this.widget.find('.datepicker-days'),
|
2054
|
+
daysViewHeader = daysView.find('th'),
|
2055
|
+
html = [];
|
2056
|
+
var currentDate = void 0,
|
2057
|
+
row = void 0,
|
2058
|
+
clsName = void 0,
|
2059
|
+
i = void 0;
|
2060
|
+
|
2061
|
+
if (!this._hasDate()) {
|
2062
|
+
return;
|
2063
|
+
}
|
2064
|
+
|
2065
|
+
daysViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevMonth);
|
2066
|
+
daysViewHeader.eq(1).attr('title', this._options.tooltips.selectMonth);
|
2067
|
+
daysViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextMonth);
|
2068
|
+
|
2069
|
+
daysView.find('.disabled').removeClass('disabled');
|
2070
|
+
daysViewHeader.eq(1).text(this._viewDate.format(this._options.dayViewHeaderFormat));
|
2071
|
+
|
2072
|
+
if (!this._isValid(this._viewDate.clone().subtract(1, 'M'), 'M')) {
|
2073
|
+
daysViewHeader.eq(0).addClass('disabled');
|
2074
|
+
}
|
2075
|
+
if (!this._isValid(this._viewDate.clone().add(1, 'M'), 'M')) {
|
2076
|
+
daysViewHeader.eq(2).addClass('disabled');
|
2077
|
+
}
|
2078
|
+
|
2079
|
+
currentDate = this._viewDate.clone().startOf('M').startOf('w').startOf('d');
|
2080
|
+
|
2081
|
+
for (i = 0; i < 42; i++) {
|
2082
|
+
//always display 42 days (should show 6 weeks)
|
2083
|
+
if (currentDate.weekday() === 0) {
|
2084
|
+
row = $('<tr>');
|
2085
|
+
if (this._options.calendarWeeks) {
|
2086
|
+
row.append('<td class="cw">' + currentDate.week() + '</td>');
|
2087
|
+
}
|
2088
|
+
html.push(row);
|
2089
|
+
}
|
2090
|
+
clsName = '';
|
2091
|
+
if (currentDate.isBefore(this._viewDate, 'M')) {
|
2092
|
+
clsName += ' old';
|
2093
|
+
}
|
2094
|
+
if (currentDate.isAfter(this._viewDate, 'M')) {
|
2095
|
+
clsName += ' new';
|
2096
|
+
}
|
2097
|
+
if (this._options.allowMultidate) {
|
2098
|
+
var index = this._datesFormatted.indexOf(currentDate.format('YYYY-MM-DD'));
|
2099
|
+
if (index !== -1) {
|
2100
|
+
if (currentDate.isSame(this._datesFormatted[index], 'd') && !this.unset) {
|
2101
|
+
clsName += ' active';
|
2102
|
+
}
|
2103
|
+
}
|
2104
|
+
} else {
|
2105
|
+
if (currentDate.isSame(this._getLastPickedDate(), 'd') && !this.unset) {
|
2106
|
+
clsName += ' active';
|
2107
|
+
}
|
2108
|
+
}
|
2109
|
+
if (!this._isValid(currentDate, 'd')) {
|
2110
|
+
clsName += ' disabled';
|
2111
|
+
}
|
2112
|
+
if (currentDate.isSame(this.getMoment(), 'd')) {
|
2113
|
+
clsName += ' today';
|
2114
|
+
}
|
2115
|
+
if (currentDate.day() === 0 || currentDate.day() === 6) {
|
2116
|
+
clsName += ' weekend';
|
2117
|
+
}
|
2118
|
+
row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="day' + clsName + '">' + currentDate.date() + '</td>');
|
2119
|
+
currentDate.add(1, 'd');
|
2120
|
+
}
|
2121
|
+
|
2122
|
+
daysView.find('tbody').empty().append(html);
|
2123
|
+
|
2124
|
+
this._updateMonths();
|
2125
|
+
|
2126
|
+
this._updateYears();
|
2127
|
+
|
2128
|
+
this._updateDecades();
|
2129
|
+
};
|
2130
|
+
|
2131
|
+
TempusDominusBootstrap4.prototype._fillHours = function _fillHours() {
|
2132
|
+
var table = this.widget.find('.timepicker-hours table'),
|
2133
|
+
currentHour = this._viewDate.clone().startOf('d'),
|
2134
|
+
html = [];
|
2135
|
+
var row = $('<tr>');
|
2136
|
+
|
2137
|
+
if (this._viewDate.hour() > 11 && !this.use24Hours) {
|
2138
|
+
currentHour.hour(12);
|
2139
|
+
}
|
2140
|
+
while (currentHour.isSame(this._viewDate, 'd') && (this.use24Hours || this._viewDate.hour() < 12 && currentHour.hour() < 12 || this._viewDate.hour() > 11)) {
|
2141
|
+
if (currentHour.hour() % 4 === 0) {
|
2142
|
+
row = $('<tr>');
|
2143
|
+
html.push(row);
|
2144
|
+
}
|
2145
|
+
row.append('<td data-action="selectHour" class="hour' + (!this._isValid(currentHour, 'h') ? ' disabled' : '') + '">' + currentHour.format(this.use24Hours ? 'HH' : 'hh') + '</td>');
|
2146
|
+
currentHour.add(1, 'h');
|
2147
|
+
}
|
2148
|
+
table.empty().append(html);
|
2149
|
+
};
|
2150
|
+
|
2151
|
+
TempusDominusBootstrap4.prototype._fillMinutes = function _fillMinutes() {
|
2152
|
+
var table = this.widget.find('.timepicker-minutes table'),
|
2153
|
+
currentMinute = this._viewDate.clone().startOf('h'),
|
2154
|
+
html = [],
|
2155
|
+
step = this._options.stepping === 1 ? 5 : this._options.stepping;
|
2156
|
+
var row = $('<tr>');
|
2157
|
+
|
2158
|
+
while (this._viewDate.isSame(currentMinute, 'h')) {
|
2159
|
+
if (currentMinute.minute() % (step * 4) === 0) {
|
2160
|
+
row = $('<tr>');
|
2161
|
+
html.push(row);
|
2162
|
+
}
|
2163
|
+
row.append('<td data-action="selectMinute" class="minute' + (!this._isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>');
|
2164
|
+
currentMinute.add(step, 'm');
|
2165
|
+
}
|
2166
|
+
table.empty().append(html);
|
2167
|
+
};
|
2168
|
+
|
2169
|
+
TempusDominusBootstrap4.prototype._fillSeconds = function _fillSeconds() {
|
2170
|
+
var table = this.widget.find('.timepicker-seconds table'),
|
2171
|
+
currentSecond = this._viewDate.clone().startOf('m'),
|
2172
|
+
html = [];
|
2173
|
+
var row = $('<tr>');
|
2174
|
+
|
2175
|
+
while (this._viewDate.isSame(currentSecond, 'm')) {
|
2176
|
+
if (currentSecond.second() % 20 === 0) {
|
2177
|
+
row = $('<tr>');
|
2178
|
+
html.push(row);
|
2179
|
+
}
|
2180
|
+
row.append('<td data-action="selectSecond" class="second' + (!this._isValid(currentSecond, 's') ? ' disabled' : '') + '">' + currentSecond.format('ss') + '</td>');
|
2181
|
+
currentSecond.add(5, 's');
|
2182
|
+
}
|
2183
|
+
|
2184
|
+
table.empty().append(html);
|
2185
|
+
};
|
2186
|
+
|
2187
|
+
TempusDominusBootstrap4.prototype._fillTime = function _fillTime() {
|
2188
|
+
var toggle = void 0,
|
2189
|
+
newDate = void 0;
|
2190
|
+
var timeComponents = this.widget.find('.timepicker span[data-time-component]');
|
2191
|
+
|
2192
|
+
if (!this.use24Hours) {
|
2193
|
+
toggle = this.widget.find('.timepicker [data-action=togglePeriod]');
|
2194
|
+
newDate = this._getLastPickedDate().clone().add(this._getLastPickedDate().hours() >= 12 ? -12 : 12, 'h');
|
2195
|
+
|
2196
|
+
toggle.text(this._getLastPickedDate().format('A'));
|
2197
|
+
|
2198
|
+
if (this._isValid(newDate, 'h')) {
|
2199
|
+
toggle.removeClass('disabled');
|
2200
|
+
} else {
|
2201
|
+
toggle.addClass('disabled');
|
2202
|
+
}
|
2203
|
+
}
|
2204
|
+
timeComponents.filter('[data-time-component=hours]').text(this._getLastPickedDate().format('' + (this.use24Hours ? 'HH' : 'hh')));
|
2205
|
+
timeComponents.filter('[data-time-component=minutes]').text(this._getLastPickedDate().format('mm'));
|
2206
|
+
timeComponents.filter('[data-time-component=seconds]').text(this._getLastPickedDate().format('ss'));
|
2207
|
+
|
2208
|
+
this._fillHours();
|
2209
|
+
this._fillMinutes();
|
2210
|
+
this._fillSeconds();
|
2211
|
+
};
|
2212
|
+
|
2213
|
+
TempusDominusBootstrap4.prototype._doAction = function _doAction(e, action) {
|
2214
|
+
var lastPicked = this._getLastPickedDate();
|
2215
|
+
if ($(e.currentTarget).is('.disabled')) {
|
2216
|
+
return false;
|
2217
|
+
}
|
2218
|
+
action = action || $(e.currentTarget).data('action');
|
2219
|
+
switch (action) {
|
2220
|
+
case 'next':
|
2221
|
+
{
|
2222
|
+
var navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;
|
2223
|
+
this._viewDate.add(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, navFnc);
|
2224
|
+
this._fillDate();
|
2225
|
+
this._viewUpdate(navFnc);
|
2226
|
+
break;
|
2227
|
+
}
|
2228
|
+
case 'previous':
|
2229
|
+
{
|
2230
|
+
var _navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;
|
2231
|
+
this._viewDate.subtract(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, _navFnc);
|
2232
|
+
this._fillDate();
|
2233
|
+
this._viewUpdate(_navFnc);
|
2234
|
+
break;
|
2235
|
+
}
|
2236
|
+
case 'pickerSwitch':
|
2237
|
+
this._showMode(1);
|
2238
|
+
break;
|
2239
|
+
case 'selectMonth':
|
2240
|
+
{
|
2241
|
+
var month = $(e.target).closest('tbody').find('span').index($(e.target));
|
2242
|
+
this._viewDate.month(month);
|
2243
|
+
if (this.currentViewMode === this.MinViewModeNumber) {
|
2244
|
+
this._setValue(lastPicked.clone().year(this._viewDate.year()).month(this._viewDate.month()), this._getLastPickedDateIndex());
|
2245
|
+
if (!this._options.inline) {
|
2246
|
+
this.hide();
|
2247
|
+
}
|
2248
|
+
} else {
|
2249
|
+
this._showMode(-1);
|
2250
|
+
this._fillDate();
|
2251
|
+
}
|
2252
|
+
this._viewUpdate('M');
|
2253
|
+
break;
|
2254
|
+
}
|
2255
|
+
case 'selectYear':
|
2256
|
+
{
|
2257
|
+
var year = parseInt($(e.target).text(), 10) || 0;
|
2258
|
+
this._viewDate.year(year);
|
2259
|
+
if (this.currentViewMode === this.MinViewModeNumber) {
|
2260
|
+
this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
|
2261
|
+
if (!this._options.inline) {
|
2262
|
+
this.hide();
|
2263
|
+
}
|
2264
|
+
} else {
|
2265
|
+
this._showMode(-1);
|
2266
|
+
this._fillDate();
|
2267
|
+
}
|
2268
|
+
this._viewUpdate('YYYY');
|
2269
|
+
break;
|
2270
|
+
}
|
2271
|
+
case 'selectDecade':
|
2272
|
+
{
|
2273
|
+
var _year = parseInt($(e.target).data('selection'), 10) || 0;
|
2274
|
+
this._viewDate.year(_year);
|
2275
|
+
if (this.currentViewMode === this.MinViewModeNumber) {
|
2276
|
+
this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
|
2277
|
+
if (!this._options.inline) {
|
2278
|
+
this.hide();
|
2279
|
+
}
|
2280
|
+
} else {
|
2281
|
+
this._showMode(-1);
|
2282
|
+
this._fillDate();
|
2283
|
+
}
|
2284
|
+
this._viewUpdate('YYYY');
|
2285
|
+
break;
|
2286
|
+
}
|
2287
|
+
case 'selectDay':
|
2288
|
+
{
|
2289
|
+
var day = this._viewDate.clone();
|
2290
|
+
if ($(e.target).is('.old')) {
|
2291
|
+
day.subtract(1, 'M');
|
2292
|
+
}
|
2293
|
+
if ($(e.target).is('.new')) {
|
2294
|
+
day.add(1, 'M');
|
2295
|
+
}
|
2296
|
+
|
2297
|
+
var selectDate = day.date(parseInt($(e.target).text(), 10)),
|
2298
|
+
index = 0;
|
2299
|
+
if (this._options.allowMultidate) {
|
2300
|
+
index = this._datesFormatted.indexOf(selectDate.format('YYYY-MM-DD'));
|
2301
|
+
if (index !== -1) {
|
2302
|
+
this._setValue(null, index); //deselect multidate
|
2303
|
+
} else {
|
2304
|
+
this._setValue(selectDate, this._getLastPickedDateIndex() + 1);
|
2305
|
+
}
|
2306
|
+
} else {
|
2307
|
+
this._setValue(selectDate, this._getLastPickedDateIndex());
|
2308
|
+
}
|
2309
|
+
|
2310
|
+
if (!this._hasTime() && !this._options.keepOpen && !this._options.inline && !this._options.allowMultidate) {
|
2311
|
+
this.hide();
|
2312
|
+
}
|
2313
|
+
break;
|
2314
|
+
}
|
2315
|
+
case 'incrementHours':
|
2316
|
+
{
|
2317
|
+
var newDate = lastPicked.clone().add(1, 'h');
|
2318
|
+
if (this._isValid(newDate, 'h')) {
|
2319
|
+
this._setValue(newDate, this._getLastPickedDateIndex());
|
2320
|
+
}
|
2321
|
+
break;
|
2322
|
+
}
|
2323
|
+
case 'incrementMinutes':
|
2324
|
+
{
|
2325
|
+
var _newDate = lastPicked.clone().add(this._options.stepping, 'm');
|
2326
|
+
if (this._isValid(_newDate, 'm')) {
|
2327
|
+
this._setValue(_newDate, this._getLastPickedDateIndex());
|
2328
|
+
}
|
2329
|
+
break;
|
2330
|
+
}
|
2331
|
+
case 'incrementSeconds':
|
2332
|
+
{
|
2333
|
+
var _newDate2 = lastPicked.clone().add(1, 's');
|
2334
|
+
if (this._isValid(_newDate2, 's')) {
|
2335
|
+
this._setValue(_newDate2, this._getLastPickedDateIndex());
|
2336
|
+
}
|
2337
|
+
break;
|
2338
|
+
}
|
2339
|
+
case 'decrementHours':
|
2340
|
+
{
|
2341
|
+
var _newDate3 = lastPicked.clone().subtract(1, 'h');
|
2342
|
+
if (this._isValid(_newDate3, 'h')) {
|
2343
|
+
this._setValue(_newDate3, this._getLastPickedDateIndex());
|
2344
|
+
}
|
2345
|
+
break;
|
2346
|
+
}
|
2347
|
+
case 'decrementMinutes':
|
2348
|
+
{
|
2349
|
+
var _newDate4 = lastPicked.clone().subtract(this._options.stepping, 'm');
|
2350
|
+
if (this._isValid(_newDate4, 'm')) {
|
2351
|
+
this._setValue(_newDate4, this._getLastPickedDateIndex());
|
2352
|
+
}
|
2353
|
+
break;
|
2354
|
+
}
|
2355
|
+
case 'decrementSeconds':
|
2356
|
+
{
|
2357
|
+
var _newDate5 = lastPicked.clone().subtract(1, 's');
|
2358
|
+
if (this._isValid(_newDate5, 's')) {
|
2359
|
+
this._setValue(_newDate5, this._getLastPickedDateIndex());
|
2360
|
+
}
|
2361
|
+
break;
|
2362
|
+
}
|
2363
|
+
case 'togglePeriod':
|
2364
|
+
{
|
2365
|
+
this._setValue(lastPicked.clone().add(lastPicked.hours() >= 12 ? -12 : 12, 'h'), this._getLastPickedDateIndex());
|
2366
|
+
break;
|
2367
|
+
}
|
2368
|
+
case 'togglePicker':
|
2369
|
+
{
|
2370
|
+
var $this = $(e.target),
|
2371
|
+
$link = $this.closest('a'),
|
2372
|
+
$parent = $this.closest('ul'),
|
2373
|
+
expanded = $parent.find('.show'),
|
2374
|
+
closed = $parent.find('.collapse:not(.show)'),
|
2375
|
+
$span = $this.is('span') ? $this : $this.find('span');
|
2376
|
+
var collapseData = void 0;
|
2377
|
+
|
2378
|
+
if (expanded && expanded.length) {
|
2379
|
+
collapseData = expanded.data('collapse');
|
2380
|
+
if (collapseData && collapseData.transitioning) {
|
2381
|
+
return true;
|
2382
|
+
}
|
2383
|
+
if (expanded.collapse) {
|
2384
|
+
// if collapse plugin is available through bootstrap.js then use it
|
2385
|
+
expanded.collapse('hide');
|
2386
|
+
closed.collapse('show');
|
2387
|
+
} else {
|
2388
|
+
// otherwise just toggle in class on the two views
|
2389
|
+
expanded.removeClass('show');
|
2390
|
+
closed.addClass('show');
|
2391
|
+
}
|
2392
|
+
$span.toggleClass(this._options.icons.time + ' ' + this._options.icons.date);
|
2393
|
+
|
2394
|
+
if ($span.hasClass(this._options.icons.date)) {
|
2395
|
+
$link.attr('title', this._options.tooltips.selectDate);
|
2396
|
+
} else {
|
2397
|
+
$link.attr('title', this._options.tooltips.selectTime);
|
2398
|
+
}
|
2399
|
+
}
|
2400
|
+
}
|
2401
|
+
break;
|
2402
|
+
case 'showPicker':
|
2403
|
+
this.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
|
2404
|
+
this.widget.find('.timepicker .timepicker-picker').show();
|
2405
|
+
break;
|
2406
|
+
case 'showHours':
|
2407
|
+
this.widget.find('.timepicker .timepicker-picker').hide();
|
2408
|
+
this.widget.find('.timepicker .timepicker-hours').show();
|
2409
|
+
break;
|
2410
|
+
case 'showMinutes':
|
2411
|
+
this.widget.find('.timepicker .timepicker-picker').hide();
|
2412
|
+
this.widget.find('.timepicker .timepicker-minutes').show();
|
2413
|
+
break;
|
2414
|
+
case 'showSeconds':
|
2415
|
+
this.widget.find('.timepicker .timepicker-picker').hide();
|
2416
|
+
this.widget.find('.timepicker .timepicker-seconds').show();
|
2417
|
+
break;
|
2418
|
+
case 'selectHour':
|
2419
|
+
{
|
2420
|
+
var hour = parseInt($(e.target).text(), 10);
|
2421
|
+
|
2422
|
+
if (!this.use24Hours) {
|
2423
|
+
if (lastPicked.hours() >= 12) {
|
2424
|
+
if (hour !== 12) {
|
2425
|
+
hour += 12;
|
2426
|
+
}
|
2427
|
+
} else {
|
2428
|
+
if (hour === 12) {
|
2429
|
+
hour = 0;
|
2430
|
+
}
|
2431
|
+
}
|
2432
|
+
}
|
2433
|
+
this._setValue(lastPicked.clone().hours(hour), this._getLastPickedDateIndex());
|
2434
|
+
if (!this._isEnabled('a') && !this._isEnabled('m') && !this._options.keepOpen && !this._options.inline) {
|
2435
|
+
this.hide();
|
2436
|
+
} else {
|
2437
|
+
this._doAction(e, 'showPicker');
|
2438
|
+
}
|
2439
|
+
break;
|
2440
|
+
}
|
2441
|
+
case 'selectMinute':
|
2442
|
+
this._setValue(lastPicked.clone().minutes(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());
|
2443
|
+
if (!this._isEnabled('a') && !this._isEnabled('s') && !this._options.keepOpen && !this._options.inline) {
|
2444
|
+
this.hide();
|
2445
|
+
} else {
|
2446
|
+
this._doAction(e, 'showPicker');
|
2447
|
+
}
|
2448
|
+
break;
|
2449
|
+
case 'selectSecond':
|
2450
|
+
this._setValue(lastPicked.clone().seconds(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());
|
2451
|
+
if (!this._isEnabled('a') && !this._options.keepOpen && !this._options.inline) {
|
2452
|
+
this.hide();
|
2453
|
+
} else {
|
2454
|
+
this._doAction(e, 'showPicker');
|
2455
|
+
}
|
2456
|
+
break;
|
2457
|
+
case 'clear':
|
2458
|
+
this.clear();
|
2459
|
+
break;
|
2460
|
+
case 'close':
|
2461
|
+
this.hide();
|
2462
|
+
break;
|
2463
|
+
case 'today':
|
2464
|
+
{
|
2465
|
+
var todaysDate = this.getMoment();
|
2466
|
+
if (this._isValid(todaysDate, 'd')) {
|
2467
|
+
this._setValue(todaysDate, this._getLastPickedDateIndex());
|
2468
|
+
}
|
2469
|
+
break;
|
2470
|
+
}
|
2471
|
+
}
|
2472
|
+
return false;
|
2473
|
+
};
|
2474
|
+
|
2475
|
+
//public
|
2476
|
+
|
2477
|
+
|
2478
|
+
TempusDominusBootstrap4.prototype.hide = function hide() {
|
2479
|
+
var transitioning = false;
|
2480
|
+
if (!this.widget) {
|
2481
|
+
return;
|
2482
|
+
}
|
2483
|
+
// Ignore event if in the middle of a picker transition
|
2484
|
+
this.widget.find('.collapse').each(function () {
|
2485
|
+
var collapseData = $(this).data('collapse');
|
2486
|
+
if (collapseData && collapseData.transitioning) {
|
2487
|
+
transitioning = true;
|
2488
|
+
return false;
|
2489
|
+
}
|
2490
|
+
return true;
|
2491
|
+
});
|
2492
|
+
if (transitioning) {
|
2493
|
+
return;
|
2494
|
+
}
|
2495
|
+
if (this.component && this.component.hasClass('btn')) {
|
2496
|
+
this.component.toggleClass('active');
|
2497
|
+
}
|
2498
|
+
this.widget.hide();
|
2499
|
+
|
2500
|
+
$(window).off('resize', this._place());
|
2501
|
+
this.widget.off('click', '[data-action]');
|
2502
|
+
this.widget.off('mousedown', false);
|
2503
|
+
|
2504
|
+
this.widget.remove();
|
2505
|
+
this.widget = false;
|
2506
|
+
|
2507
|
+
this._notifyEvent({
|
2508
|
+
type: DateTimePicker.Event.HIDE,
|
2509
|
+
date: this._getLastPickedDate().clone()
|
2510
|
+
});
|
2511
|
+
|
2512
|
+
if (this.input !== undefined) {
|
2513
|
+
this.input.blur();
|
2514
|
+
}
|
2515
|
+
|
2516
|
+
this._viewDate = this._getLastPickedDate().clone();
|
2517
|
+
};
|
2518
|
+
|
2519
|
+
TempusDominusBootstrap4.prototype.show = function show() {
|
2520
|
+
var currentMoment = void 0;
|
2521
|
+
var useCurrentGranularity = {
|
2522
|
+
'year': function year(m) {
|
2523
|
+
return m.month(0).date(1).hours(0).seconds(0).minutes(0);
|
2524
|
+
},
|
2525
|
+
'month': function month(m) {
|
2526
|
+
return m.date(1).hours(0).seconds(0).minutes(0);
|
2527
|
+
},
|
2528
|
+
'day': function day(m) {
|
2529
|
+
return m.hours(0).seconds(0).minutes(0);
|
2530
|
+
},
|
2531
|
+
'hour': function hour(m) {
|
2532
|
+
return m.seconds(0).minutes(0);
|
2533
|
+
},
|
2534
|
+
'minute': function minute(m) {
|
2535
|
+
return m.seconds(0);
|
2536
|
+
}
|
2537
|
+
};
|
2538
|
+
|
2539
|
+
if (this.input !== undefined) {
|
2540
|
+
if (this.input.prop('disabled') || !this._options.ignoreReadonly && this.input.prop('readonly') || this.widget) {
|
2541
|
+
return;
|
2542
|
+
}
|
2543
|
+
if (this.input.val() !== undefined && this.input.val().trim().length !== 0) {
|
2544
|
+
this._setValue(this._parseInputDate(this.input.val().trim()), 0);
|
2545
|
+
} else if (this.unset && this._options.useCurrent) {
|
2546
|
+
currentMoment = this.getMoment();
|
2547
|
+
if (typeof this._options.useCurrent === 'string') {
|
2548
|
+
currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment);
|
2549
|
+
}
|
2550
|
+
this._setValue(currentMoment, 0);
|
2551
|
+
}
|
2552
|
+
} else if (this.unset && this._options.useCurrent) {
|
2553
|
+
currentMoment = this.getMoment();
|
2554
|
+
if (typeof this._options.useCurrent === 'string') {
|
2555
|
+
currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment);
|
2556
|
+
}
|
2557
|
+
this._setValue(currentMoment, 0);
|
2558
|
+
}
|
2559
|
+
|
2560
|
+
this.widget = this._getTemplate();
|
2561
|
+
|
2562
|
+
this._fillDow();
|
2563
|
+
this._fillMonths();
|
2564
|
+
|
2565
|
+
this.widget.find('.timepicker-hours').hide();
|
2566
|
+
this.widget.find('.timepicker-minutes').hide();
|
2567
|
+
this.widget.find('.timepicker-seconds').hide();
|
2568
|
+
|
2569
|
+
this._update();
|
2570
|
+
this._showMode();
|
2571
|
+
|
2572
|
+
$(window).on('resize', { picker: this }, this._place);
|
2573
|
+
this.widget.on('click', '[data-action]', $.proxy(this._doAction, this)); // this handles clicks on the widget
|
2574
|
+
this.widget.on('mousedown', false);
|
2575
|
+
|
2576
|
+
if (this.component && this.component.hasClass('btn')) {
|
2577
|
+
this.component.toggleClass('active');
|
2578
|
+
}
|
2579
|
+
this._place();
|
2580
|
+
this.widget.show();
|
2581
|
+
if (this.input !== undefined && this._options.focusOnShow && !this.input.is(':focus')) {
|
2582
|
+
this.input.focus();
|
2583
|
+
}
|
2584
|
+
|
2585
|
+
this._notifyEvent({
|
2586
|
+
type: DateTimePicker.Event.SHOW
|
2587
|
+
});
|
2588
|
+
};
|
2589
|
+
|
2590
|
+
TempusDominusBootstrap4.prototype.destroy = function destroy() {
|
2591
|
+
this.hide();
|
2592
|
+
//todo doc off?
|
2593
|
+
this._element.removeData(DateTimePicker.DATA_KEY);
|
2594
|
+
this._element.removeData('date');
|
2595
|
+
};
|
2596
|
+
|
2597
|
+
TempusDominusBootstrap4.prototype.disable = function disable() {
|
2598
|
+
this.hide();
|
2599
|
+
if (this.component && this.component.hasClass('btn')) {
|
2600
|
+
this.component.addClass('disabled');
|
2601
|
+
}
|
2602
|
+
if (this.input !== undefined) {
|
2603
|
+
this.input.prop('disabled', true); //todo disable this/comp if input is null
|
2604
|
+
}
|
2605
|
+
};
|
2606
|
+
|
2607
|
+
TempusDominusBootstrap4.prototype.enable = function enable() {
|
2608
|
+
if (this.component && this.component.hasClass('btn')) {
|
2609
|
+
this.component.removeClass('disabled');
|
2610
|
+
}
|
2611
|
+
if (this.input !== undefined) {
|
2612
|
+
this.input.prop('disabled', false); //todo enable comp/this if input is null
|
2613
|
+
}
|
2614
|
+
};
|
2615
|
+
|
2616
|
+
TempusDominusBootstrap4.prototype.toolbarPlacement = function toolbarPlacement(_toolbarPlacement) {
|
2617
|
+
if (arguments.length === 0) {
|
2618
|
+
return this._options.toolbarPlacement;
|
2619
|
+
}
|
2620
|
+
|
2621
|
+
if (typeof _toolbarPlacement !== 'string') {
|
2622
|
+
throw new TypeError('toolbarPlacement() expects a string parameter');
|
2623
|
+
}
|
2624
|
+
if (toolbarPlacements.indexOf(_toolbarPlacement) === -1) {
|
2625
|
+
throw new TypeError('toolbarPlacement() parameter must be one of (' + toolbarPlacements.join(', ') + ') value');
|
2626
|
+
}
|
2627
|
+
this._options.toolbarPlacement = _toolbarPlacement;
|
2628
|
+
|
2629
|
+
if (this.widget) {
|
2630
|
+
this.hide();
|
2631
|
+
this.show();
|
2632
|
+
}
|
2633
|
+
};
|
2634
|
+
|
2635
|
+
TempusDominusBootstrap4.prototype.widgetPositioning = function widgetPositioning(_widgetPositioning) {
|
2636
|
+
if (arguments.length === 0) {
|
2637
|
+
return $.extend({}, this._options.widgetPositioning);
|
2638
|
+
}
|
2639
|
+
|
2640
|
+
if ({}.toString.call(_widgetPositioning) !== '[object Object]') {
|
2641
|
+
throw new TypeError('widgetPositioning() expects an object variable');
|
2642
|
+
}
|
2643
|
+
if (_widgetPositioning.horizontal) {
|
2644
|
+
if (typeof _widgetPositioning.horizontal !== 'string') {
|
2645
|
+
throw new TypeError('widgetPositioning() horizontal variable must be a string');
|
2646
|
+
}
|
2647
|
+
_widgetPositioning.horizontal = _widgetPositioning.horizontal.toLowerCase();
|
2648
|
+
if (horizontalModes.indexOf(_widgetPositioning.horizontal) === -1) {
|
2649
|
+
throw new TypeError('widgetPositioning() expects horizontal parameter to be one of (' + horizontalModes.join(', ') + ')');
|
2650
|
+
}
|
2651
|
+
this._options.widgetPositioning.horizontal = _widgetPositioning.horizontal;
|
2652
|
+
}
|
2653
|
+
if (_widgetPositioning.vertical) {
|
2654
|
+
if (typeof _widgetPositioning.vertical !== 'string') {
|
2655
|
+
throw new TypeError('widgetPositioning() vertical variable must be a string');
|
2656
|
+
}
|
2657
|
+
_widgetPositioning.vertical = _widgetPositioning.vertical.toLowerCase();
|
2658
|
+
if (verticalModes.indexOf(_widgetPositioning.vertical) === -1) {
|
2659
|
+
throw new TypeError('widgetPositioning() expects vertical parameter to be one of (' + verticalModes.join(', ') + ')');
|
2660
|
+
}
|
2661
|
+
this._options.widgetPositioning.vertical = _widgetPositioning.vertical;
|
2662
|
+
}
|
2663
|
+
this._update();
|
2664
|
+
};
|
2665
|
+
|
2666
|
+
TempusDominusBootstrap4.prototype.widgetParent = function widgetParent(_widgetParent) {
|
2667
|
+
if (arguments.length === 0) {
|
2668
|
+
return this._options.widgetParent;
|
2669
|
+
}
|
2670
|
+
|
2671
|
+
if (typeof _widgetParent === 'string') {
|
2672
|
+
_widgetParent = $(_widgetParent);
|
2673
|
+
}
|
2674
|
+
|
2675
|
+
if (_widgetParent !== null && typeof _widgetParent !== 'string' && !(_widgetParent instanceof $)) {
|
2676
|
+
throw new TypeError('widgetParent() expects a string or a jQuery object parameter');
|
2677
|
+
}
|
2678
|
+
|
2679
|
+
this._options.widgetParent = _widgetParent;
|
2680
|
+
if (this.widget) {
|
2681
|
+
this.hide();
|
2682
|
+
this.show();
|
2683
|
+
}
|
2684
|
+
};
|
2685
|
+
|
2686
|
+
//static
|
2687
|
+
|
2688
|
+
|
2689
|
+
TempusDominusBootstrap4._jQueryHandleThis = function _jQueryHandleThis(me, option, argument) {
|
2690
|
+
var data = $(me).data(DateTimePicker.DATA_KEY);
|
2691
|
+
if ((typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object') {
|
2692
|
+
$.extend({}, DateTimePicker.Default, option);
|
2693
|
+
}
|
2694
|
+
|
2695
|
+
if (!data) {
|
2696
|
+
data = new TempusDominusBootstrap4($(me), option);
|
2697
|
+
$(me).data(DateTimePicker.DATA_KEY, data);
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
if (typeof option === 'string') {
|
2701
|
+
if (data[option] === undefined) {
|
2702
|
+
throw new Error('No method named "' + option + '"');
|
2703
|
+
}
|
2704
|
+
if (argument === undefined) {
|
2705
|
+
return data[option]();
|
2706
|
+
} else {
|
2707
|
+
return data[option](argument);
|
2708
|
+
}
|
2709
|
+
}
|
2710
|
+
};
|
2711
|
+
|
2712
|
+
TempusDominusBootstrap4._jQueryInterface = function _jQueryInterface(option, argument) {
|
2713
|
+
if (this.length === 1) {
|
2714
|
+
return TempusDominusBootstrap4._jQueryHandleThis(this[0], option, argument);
|
2715
|
+
}
|
2716
|
+
return this.each(function () {
|
2717
|
+
TempusDominusBootstrap4._jQueryHandleThis(this, option, argument);
|
2718
|
+
});
|
2719
|
+
};
|
2720
|
+
|
2721
|
+
return TempusDominusBootstrap4;
|
2722
|
+
}(DateTimePicker);
|
2723
|
+
|
2724
|
+
/**
|
2725
|
+
* ------------------------------------------------------------------------
|
2726
|
+
* jQuery
|
2727
|
+
* ------------------------------------------------------------------------
|
2728
|
+
*/
|
2729
|
+
|
2730
|
+
|
2731
|
+
$(document).on(DateTimePicker.Event.CLICK_DATA_API, DateTimePicker.Selector.DATA_TOGGLE, function () {
|
2732
|
+
var $target = getSelectorFromElement($(this));
|
2733
|
+
if ($target.length === 0) {
|
2734
|
+
return;
|
2735
|
+
}
|
2736
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, 'toggle');
|
2737
|
+
}).on(DateTimePicker.Event.CHANGE, '.' + DateTimePicker.ClassName.INPUT, function (event) {
|
2738
|
+
var $target = getSelectorFromElement($(this));
|
2739
|
+
if ($target.length === 0) {
|
2740
|
+
return;
|
2741
|
+
}
|
2742
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, '_change', event);
|
2743
|
+
}).on(DateTimePicker.Event.BLUR, '.' + DateTimePicker.ClassName.INPUT, function (event) {
|
2744
|
+
var $target = getSelectorFromElement($(this)),
|
2745
|
+
config = $target.data(DateTimePicker.DATA_KEY);
|
2746
|
+
if ($target.length === 0) {
|
2747
|
+
return;
|
2748
|
+
}
|
2749
|
+
if (config._options.debug || window.debug) {
|
2750
|
+
return;
|
2751
|
+
}
|
2752
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, 'hide', event);
|
2753
|
+
}).on(DateTimePicker.Event.KEYDOWN, '.' + DateTimePicker.ClassName.INPUT, function (event) {
|
2754
|
+
var $target = getSelectorFromElement($(this));
|
2755
|
+
if ($target.length === 0) {
|
2756
|
+
return;
|
2757
|
+
}
|
2758
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, '_keydown', event);
|
2759
|
+
}).on(DateTimePicker.Event.KEYUP, '.' + DateTimePicker.ClassName.INPUT, function (event) {
|
2760
|
+
var $target = getSelectorFromElement($(this));
|
2761
|
+
if ($target.length === 0) {
|
2762
|
+
return;
|
2763
|
+
}
|
2764
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, '_keyup', event);
|
2765
|
+
}).on(DateTimePicker.Event.FOCUS, '.' + DateTimePicker.ClassName.INPUT, function (event) {
|
2766
|
+
var $target = getSelectorFromElement($(this)),
|
2767
|
+
config = $target.data(DateTimePicker.DATA_KEY);
|
2768
|
+
if ($target.length === 0) {
|
2769
|
+
return;
|
2770
|
+
}
|
2771
|
+
if (!config._options.allowInputToggle) {
|
2772
|
+
return;
|
2773
|
+
}
|
2774
|
+
TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event);
|
2775
|
+
});
|
2776
|
+
|
2777
|
+
$.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface;
|
2778
|
+
$.fn[DateTimePicker.NAME].Constructor = TempusDominusBootstrap4;
|
2779
|
+
$.fn[DateTimePicker.NAME].noConflict = function () {
|
2780
|
+
$.fn[DateTimePicker.NAME] = JQUERY_NO_CONFLICT;
|
2781
|
+
return TempusDominusBootstrap4._jQueryInterface;
|
2782
|
+
};
|
2783
|
+
|
2784
|
+
return TempusDominusBootstrap4;
|
2785
|
+
}(jQuery);
|
2786
|
+
|
2787
|
+
}();
|