inviton-powerduck 0.0.166 → 0.0.168

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.
@@ -0,0 +1,1954 @@
1
+ /* eslint-disable */
2
+ //@ts-nocheck
3
+
4
+ /* =========================================================
5
+ * bootstrap-datetimepicker.js
6
+ * =========================================================
7
+ * Copyright 2012 Stefan Petre
8
+ *
9
+ * Improvements by Andrew Rowls
10
+ * Improvements by Sébastien Malot
11
+ * Improvements by Yun Lai
12
+ * Improvements by Kenneth Henderick
13
+ * Improvements by CuGBabyBeaR
14
+ * Improvements by Christian Vaas <auspex@auspex.eu>
15
+ *
16
+ * Project URL : http://www.malot.fr/bootstrap-datetimepicker
17
+ *
18
+ * Licensed under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License.
20
+ * You may obtain a copy of the License at
21
+ *
22
+ * http://www.apache.org/licenses/LICENSE-2.0
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software
25
+ * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ * See the License for the specific language governing permissions and
28
+ * limitations under the License.
29
+ * ========================================================= */
30
+
31
+ import { globalState } from "@powerduck/app/global-state";
32
+
33
+ (function (factory) {
34
+ factory(globalState.$)
35
+ }(function ($, undefined) {
36
+ if (!globalState.windowExists) {
37
+ return;
38
+ }
39
+
40
+ // Add timezone abbreviation support for ie6+, Chrome, Firefox
41
+ function timeZoneAbbreviation() {
42
+ var abbreviation, date, formattedStr, i, len, matchedStrings, ref, str;
43
+ date = (new Date()).toString();
44
+ formattedStr = ((ref = date.split('(')[1]) != null ? ref.slice(0, -1) : 0) || date.split(' ');
45
+ if (formattedStr instanceof Array) {
46
+ matchedStrings = [];
47
+ for (var i = 0, len = formattedStr.length; i < len; i++) {
48
+ str = formattedStr[i];
49
+ if ((abbreviation = (ref = str.match(/\b[A-Z]+\b/)) !== null) ? ref[0] : 0) {
50
+ matchedStrings.push(abbreviation);
51
+ }
52
+ }
53
+ formattedStr = matchedStrings.pop();
54
+ }
55
+ return formattedStr;
56
+ }
57
+
58
+ function UTCDate() {
59
+ return new Date(Date.UTC.apply(Date, arguments));
60
+ }
61
+
62
+ // Picker object
63
+ var Datetimepicker = function (element, options) {
64
+ var that = this;
65
+
66
+ this.element = $(element);
67
+
68
+ // add container for single page application
69
+ // when page switch the datetimepicker div will be removed also.
70
+ this.container = options.container || 'body';
71
+
72
+ this.language = options.language || this.element.data('date-language') || 'en';
73
+ this.language = this.language in dates ? this.language : this.language.split('-')[0]; // fr-CA fallback to fr
74
+ this.language = this.language in dates ? this.language : 'en';
75
+ this.isRTL = dates[this.language].rtl || false;
76
+ this.formatType = options.formatType || this.element.data('format-type') || 'standard';
77
+ this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
78
+ this.isInline = false;
79
+ this.isVisible = false;
80
+ this.isInput = this.element.is('input');
81
+ this.fontAwesome = options.fontAwesome || this.element.data('font-awesome') || false;
82
+
83
+ this.bootcssVer = options.bootcssVer || (this.isInput ? (this.element.is('.form-control') ? 3 : 2) : (this.bootcssVer = this.element.is('.input-group') ? 3 : 2));
84
+
85
+ this.component = this.element.is('.date') ? (this.bootcssVer === 3 ? this.element.find('.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-remove, .input-group-addon .glyphicon-calendar, .input-group-addon .fa-calendar, .input-group-addon .fa-clock-o').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar, .add-on .fa-calendar, .add-on .fa-clock-o').parent()) : false;
86
+ this.componentReset = this.element.is('.date') ? (this.bootcssVer === 3 ? this.element.find('.input-group-addon .glyphicon-remove, .input-group-addon .fa-times').parent() : this.element.find('.add-on .icon-remove, .add-on .fa-times').parent()) : false;
87
+ this.hasInput = this.component && this.element.find('input').length;
88
+ if (this.component && this.component.length === 0) {
89
+ this.component = false;
90
+ }
91
+ this.linkField = options.linkField || this.element.data('link-field') || false;
92
+ this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
93
+ this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
94
+ this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
95
+ this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
96
+ this.initialDate = options.initialDate || new Date();
97
+ this.zIndex = options.zIndex || this.element.data('z-index') || undefined;
98
+ this.title = typeof options.title === 'undefined' ? false : options.title;
99
+ this.timezone = options.timezone || timeZoneAbbreviation();
100
+
101
+ this.icons = {
102
+ leftArrow: this.fontAwesome ? 'fa-arrow-left' : (this.bootcssVer === 3 ? 'glyphicon-arrow-left' : 'icon-arrow-left'),
103
+ rightArrow: this.fontAwesome ? 'fa-arrow-right' : (this.bootcssVer === 3 ? 'glyphicon-arrow-right' : 'icon-arrow-right')
104
+ }
105
+ this.icontype = this.fontAwesome ? 'fa' : 'glyphicon';
106
+
107
+ this._attachEvents();
108
+
109
+ this.clickedOutside = function (e) {
110
+ // Clicked outside the datetimepicker, hide it
111
+ if ($(e.target).closest('.datetimepicker').length === 0) {
112
+ that.hide();
113
+ }
114
+ }
115
+
116
+ this.formatViewType = 'datetime';
117
+ if ('formatViewType' in options) {
118
+ this.formatViewType = options.formatViewType;
119
+ } else if ('formatViewType' in this.element.data()) {
120
+ this.formatViewType = this.element.data('formatViewType');
121
+ }
122
+
123
+ this.minView = 0;
124
+ if ('minView' in options) {
125
+ this.minView = options.minView;
126
+ } else if ('minView' in this.element.data()) {
127
+ this.minView = this.element.data('min-view');
128
+ }
129
+ this.minView = DPGlobal.convertViewMode(this.minView);
130
+
131
+ this.maxView = DPGlobal.modes.length - 1;
132
+ if ('maxView' in options) {
133
+ this.maxView = options.maxView;
134
+ } else if ('maxView' in this.element.data()) {
135
+ this.maxView = this.element.data('max-view');
136
+ }
137
+ this.maxView = DPGlobal.convertViewMode(this.maxView);
138
+
139
+ this.wheelViewModeNavigation = false;
140
+ if ('wheelViewModeNavigation' in options) {
141
+ this.wheelViewModeNavigation = options.wheelViewModeNavigation;
142
+ } else if ('wheelViewModeNavigation' in this.element.data()) {
143
+ this.wheelViewModeNavigation = this.element.data('view-mode-wheel-navigation');
144
+ }
145
+
146
+ this.wheelViewModeNavigationInverseDirection = false;
147
+
148
+ if ('wheelViewModeNavigationInverseDirection' in options) {
149
+ this.wheelViewModeNavigationInverseDirection = options.wheelViewModeNavigationInverseDirection;
150
+ } else if ('wheelViewModeNavigationInverseDirection' in this.element.data()) {
151
+ this.wheelViewModeNavigationInverseDirection = this.element.data('view-mode-wheel-navigation-inverse-dir');
152
+ }
153
+
154
+ this.wheelViewModeNavigationDelay = 100;
155
+ if ('wheelViewModeNavigationDelay' in options) {
156
+ this.wheelViewModeNavigationDelay = options.wheelViewModeNavigationDelay;
157
+ } else if ('wheelViewModeNavigationDelay' in this.element.data()) {
158
+ this.wheelViewModeNavigationDelay = this.element.data('view-mode-wheel-navigation-delay');
159
+ }
160
+
161
+ this.startViewMode = 2;
162
+ if ('startView' in options) {
163
+ this.startViewMode = options.startView;
164
+ } else if ('startView' in this.element.data()) {
165
+ this.startViewMode = this.element.data('start-view');
166
+ }
167
+ this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
168
+ this.viewMode = this.startViewMode;
169
+
170
+ this.viewSelect = this.minView;
171
+ if ('viewSelect' in options) {
172
+ this.viewSelect = options.viewSelect;
173
+ } else if ('viewSelect' in this.element.data()) {
174
+ this.viewSelect = this.element.data('view-select');
175
+ }
176
+ this.viewSelect = DPGlobal.convertViewMode(this.viewSelect);
177
+
178
+ this.forceParse = true;
179
+ if ('forceParse' in options) {
180
+ this.forceParse = options.forceParse;
181
+ } else if ('dateForceParse' in this.element.data()) {
182
+ this.forceParse = this.element.data('date-force-parse');
183
+ }
184
+ var template = this.bootcssVer === 3 ? DPGlobal.templateV3 : DPGlobal.template;
185
+ while (template.indexOf('{iconType}') !== -1) {
186
+ template = template.replace('{iconType}', this.icontype);
187
+ }
188
+ while (template.indexOf('{leftArrow}') !== -1) {
189
+ template = template.replace('{leftArrow}', this.icons.leftArrow);
190
+ }
191
+ while (template.indexOf('{rightArrow}') !== -1) {
192
+ template = template.replace('{rightArrow}', this.icons.rightArrow);
193
+ }
194
+ this.picker = $(template)
195
+ .appendTo(this.isInline ? this.element : this.container) // 'body')
196
+ .on({
197
+ click: $.proxy(this.click, this),
198
+ mousedown: $.proxy(this.mousedown, this)
199
+ });
200
+
201
+ if (this.wheelViewModeNavigation) {
202
+ if ($.fn.mousewheel) {
203
+ this.picker.on({ mousewheel: $.proxy(this.mousewheel, this) });
204
+ } else {
205
+ console.log('Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option');
206
+ }
207
+ }
208
+
209
+ if (this.isInline) {
210
+ this.picker.addClass('datetimepicker-inline');
211
+ } else {
212
+ this.picker.addClass('datetimepicker-dropdown-' + this.pickerPosition + ' dropdown-menu');
213
+ }
214
+ if (this.isRTL) {
215
+ this.picker.addClass('datetimepicker-rtl');
216
+ var selector = this.bootcssVer === 3 ? '.prev span, .next span' : '.prev i, .next i';
217
+ this.picker.find(selector).toggleClass(this.icons.leftArrow + ' ' + this.icons.rightArrow);
218
+ }
219
+
220
+ $(document).on('mousedown touchend', this.clickedOutside);
221
+
222
+ this.autoclose = false;
223
+ if ('autoclose' in options) {
224
+ this.autoclose = options.autoclose;
225
+ } else if ('dateAutoclose' in this.element.data()) {
226
+ this.autoclose = this.element.data('date-autoclose');
227
+ }
228
+
229
+ this.keyboardNavigation = true;
230
+ if ('keyboardNavigation' in options) {
231
+ this.keyboardNavigation = options.keyboardNavigation;
232
+ } else if ('dateKeyboardNavigation' in this.element.data()) {
233
+ this.keyboardNavigation = this.element.data('date-keyboard-navigation');
234
+ }
235
+
236
+ this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
237
+ this.clearBtn = (options.clearBtn || this.element.data('date-clear-btn') || false);
238
+ this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
239
+
240
+ this.weekStart = 0;
241
+ if (typeof options.weekStart !== 'undefined') {
242
+ this.weekStart = options.weekStart;
243
+ } else if (typeof this.element.data('date-weekstart') !== 'undefined') {
244
+ this.weekStart = this.element.data('date-weekstart');
245
+ } else if (typeof dates[this.language].weekStart !== 'undefined') {
246
+ this.weekStart = dates[this.language].weekStart;
247
+ }
248
+ this.weekStart = this.weekStart % 7;
249
+ this.weekEnd = ((this.weekStart + 6) % 7);
250
+ this.onRenderDay = function (date) {
251
+ var render = (options.onRenderDay || function () { return []; })(date);
252
+ if (typeof render === 'string') {
253
+ render = [render];
254
+ }
255
+ var res = ['day'];
256
+ return res.concat((render ? render : []));
257
+ };
258
+ this.onRenderHour = function (date) {
259
+ var render = (options.onRenderHour || function () { return []; })(date);
260
+ var res = ['hour'];
261
+ if (typeof render === 'string') {
262
+ render = [render];
263
+ }
264
+ return res.concat((render ? render : []));
265
+ };
266
+ this.onRenderMinute = function (date) {
267
+ var render = (options.onRenderMinute || function () { return []; })(date);
268
+ var res = ['minute'];
269
+ if (typeof render === 'string') {
270
+ render = [render];
271
+ }
272
+ if (date < this.startDate || date > this.endDate) {
273
+ res.push('disabled');
274
+ } else if (Math.floor(this.date.getUTCMinutes() / this.minuteStep) === Math.floor(date.getUTCMinutes() / this.minuteStep)) {
275
+ res.push('active');
276
+ }
277
+ return res.concat((render ? render : []));
278
+ };
279
+ this.onRenderYear = function (date) {
280
+ var render = (options.onRenderYear || function () { return []; })(date);
281
+ var res = ['year'];
282
+ if (typeof render === 'string') {
283
+ render = [render];
284
+ }
285
+ if (this.date.getUTCFullYear() === date.getUTCFullYear()) {
286
+ res.push('active');
287
+ }
288
+ var currentYear = date.getUTCFullYear();
289
+ var endYear = this.endDate.getUTCFullYear();
290
+ if (date < this.startDate || currentYear > endYear) {
291
+ res.push('disabled');
292
+ }
293
+ return res.concat((render ? render : []));
294
+ }
295
+ this.onRenderMonth = function (date) {
296
+ var render = (options.onRenderMonth || function () { return []; })(date);
297
+ var res = ['month'];
298
+ if (typeof render === 'string') {
299
+ render = [render];
300
+ }
301
+ return res.concat((render ? render : []));
302
+ }
303
+ this.startDate = new Date(-8639968443048000);
304
+ this.endDate = new Date(8639968443048000);
305
+ this.datesDisabled = [];
306
+ this.daysOfWeekDisabled = [];
307
+ this.setStartDate(options.startDate || this.element.data('date-startdate'));
308
+ this.setEndDate(options.endDate || this.element.data('date-enddate'));
309
+ this.setDatesDisabled(options.datesDisabled || this.element.data('date-dates-disabled'));
310
+ this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
311
+ this.setMinutesDisabled(options.minutesDisabled || this.element.data('date-minute-disabled'));
312
+ this.setHoursDisabled(options.hoursDisabled || this.element.data('date-hour-disabled'));
313
+ this.fillDow();
314
+ this.fillMonths();
315
+ this.update();
316
+ this.showMode();
317
+
318
+ if (this.isInline) {
319
+ this.show();
320
+ }
321
+ };
322
+
323
+ Datetimepicker.prototype = {
324
+ constructor: Datetimepicker,
325
+
326
+ _events: [],
327
+ _attachEvents: function () {
328
+ this._detachEvents();
329
+ if (this.isInput) { // single input
330
+ this._events = [
331
+ [this.element, {
332
+ focus: $.proxy(this.show, this),
333
+ keyup: $.proxy(this.update, this),
334
+ keydown: $.proxy(this.keydown, this)
335
+ }]
336
+ ];
337
+ }
338
+ else if (this.component && this.hasInput) { // component: input + button
339
+ this._events = [
340
+ // For components that are not readonly, allow keyboard nav
341
+ [this.element.find('input'), {
342
+ focus: $.proxy(this.show, this),
343
+ keyup: $.proxy(this.update, this),
344
+ keydown: $.proxy(this.keydown, this)
345
+ }],
346
+ [this.component, {
347
+ click: $.proxy(this.show, this)
348
+ }]
349
+ ];
350
+ if (this.componentReset) {
351
+ this._events.push([
352
+ this.componentReset,
353
+ { click: $.proxy(this.reset, this) }
354
+ ]);
355
+ }
356
+ }
357
+ else if (this.element.is('div')) { // inline datetimepicker
358
+ this.isInline = true;
359
+ }
360
+ else {
361
+ this._events = [
362
+ [this.element, {
363
+ click: $.proxy(this.show, this)
364
+ }]
365
+ ];
366
+ }
367
+ for (var i = 0, el, ev; i < this._events.length; i++) {
368
+ el = this._events[i][0];
369
+ ev = this._events[i][1];
370
+ el.on(ev);
371
+ }
372
+ },
373
+
374
+ _detachEvents: function () {
375
+ for (var i = 0, el, ev; i < this._events.length; i++) {
376
+ el = this._events[i][0];
377
+ ev = this._events[i][1];
378
+ el.off(ev);
379
+ }
380
+ this._events = [];
381
+ },
382
+
383
+ show: function (e) {
384
+ this.picker.show();
385
+ this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
386
+ if (this.forceParse) {
387
+ this.update();
388
+ }
389
+ this.place();
390
+ $(window).on('resize', $.proxy(this.place, this));
391
+ if (e) {
392
+ e.stopPropagation();
393
+ e.preventDefault();
394
+ }
395
+ this.isVisible = true;
396
+ this.element.trigger({
397
+ type: 'show',
398
+ date: this.date
399
+ });
400
+ },
401
+
402
+ hide: function () {
403
+ if (!this.isVisible) return;
404
+ if (this.isInline) return;
405
+ this.picker.hide();
406
+ $(window).off('resize', this.place);
407
+ this.viewMode = this.startViewMode;
408
+ this.showMode();
409
+ if (!this.isInput) {
410
+ $(document).off('mousedown', this.hide);
411
+ }
412
+
413
+ if (
414
+ this.forceParse &&
415
+ (
416
+ this.isInput && this.element.val() ||
417
+ this.hasInput && this.element.find('input').val()
418
+ )
419
+ )
420
+ this.setValue();
421
+ this.isVisible = false;
422
+ this.element.trigger({
423
+ type: 'hide',
424
+ date: this.date
425
+ });
426
+ },
427
+
428
+ remove: function () {
429
+ this._detachEvents();
430
+ $(document).off('mousedown', this.clickedOutside);
431
+ this.picker.remove();
432
+ delete this.picker;
433
+ delete this.element.data().datetimepicker;
434
+ },
435
+
436
+ getDate: function () {
437
+ var d = this.getUTCDate();
438
+ if (d === null) {
439
+ return null;
440
+ }
441
+ return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
442
+ },
443
+
444
+ getUTCDate: function () {
445
+ return this.date;
446
+ },
447
+
448
+ getInitialDate: function () {
449
+ return this.initialDate
450
+ },
451
+
452
+ setInitialDate: function (initialDate) {
453
+ this.initialDate = initialDate;
454
+ },
455
+
456
+ setDate: function (d) {
457
+ this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)));
458
+ },
459
+
460
+ setUTCDate: function (d) {
461
+ if (d >= this.startDate && d <= this.endDate) {
462
+ this.date = d;
463
+ this.setValue();
464
+ this.viewDate = this.date;
465
+ this.fill();
466
+ } else {
467
+ this.element.trigger({
468
+ type: 'outOfRange',
469
+ date: d,
470
+ startDate: this.startDate,
471
+ endDate: this.endDate
472
+ });
473
+ }
474
+ },
475
+
476
+ setFormat: function (format) {
477
+ this.format = DPGlobal.parseFormat(format, this.formatType);
478
+ var element;
479
+ if (this.isInput) {
480
+ element = this.element;
481
+ } else if (this.component) {
482
+ element = this.element.find('input');
483
+ }
484
+ if (element && element.val()) {
485
+ this.setValue();
486
+ }
487
+ },
488
+
489
+ setValue: function () {
490
+ var formatted = this.getFormattedDate();
491
+ if (!this.isInput) {
492
+ if (this.component) {
493
+ this.element.find('input').val(formatted);
494
+ }
495
+ this.element.data('date', formatted);
496
+ } else {
497
+ this.element.val(formatted);
498
+ }
499
+ if (this.linkField) {
500
+ $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
501
+ }
502
+ },
503
+
504
+ getFormattedDate: function (format) {
505
+ format = format || this.format;
506
+ return DPGlobal.formatDate(this.date, format, this.language, this.formatType, this.timezone);
507
+ },
508
+
509
+ setStartDate: function (startDate) {
510
+ this.startDate = startDate || this.startDate;
511
+ if (this.startDate.valueOf() !== 8639968443048000) {
512
+ this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType, this.timezone);
513
+ }
514
+ this.update();
515
+ this.updateNavArrows();
516
+ },
517
+
518
+ setEndDate: function (endDate) {
519
+ this.endDate = endDate || this.endDate;
520
+ if (this.endDate.valueOf() !== 8639968443048000) {
521
+ this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType, this.timezone);
522
+ }
523
+ this.update();
524
+ this.updateNavArrows();
525
+ },
526
+
527
+ setDatesDisabled: function (datesDisabled) {
528
+ this.datesDisabled = datesDisabled || [];
529
+ if (!$.isArray(this.datesDisabled)) {
530
+ this.datesDisabled = this.datesDisabled.split(/,\s*/);
531
+ }
532
+ var mThis = this;
533
+ this.datesDisabled = $.map(this.datesDisabled, function (d) {
534
+ return DPGlobal.parseDate(d, mThis.format, mThis.language, mThis.formatType, mThis.timezone).toDateString();
535
+ });
536
+ this.update();
537
+ this.updateNavArrows();
538
+ },
539
+
540
+ setTitle: function (selector, value) {
541
+ return this.picker.find(selector)
542
+ .find('th:eq(1)')
543
+ .text(this.title === false ? value : this.title);
544
+ },
545
+
546
+ setDaysOfWeekDisabled: function (daysOfWeekDisabled) {
547
+ this.daysOfWeekDisabled = daysOfWeekDisabled || [];
548
+ if (!$.isArray(this.daysOfWeekDisabled)) {
549
+ this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
550
+ }
551
+ this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function (d) {
552
+ return parseInt(d, 10);
553
+ });
554
+ this.update();
555
+ this.updateNavArrows();
556
+ },
557
+
558
+ setMinutesDisabled: function (minutesDisabled) {
559
+ this.minutesDisabled = minutesDisabled || [];
560
+ if (!$.isArray(this.minutesDisabled)) {
561
+ this.minutesDisabled = this.minutesDisabled.split(/,\s*/);
562
+ }
563
+ this.minutesDisabled = $.map(this.minutesDisabled, function (d) {
564
+ return parseInt(d, 10);
565
+ });
566
+ this.update();
567
+ this.updateNavArrows();
568
+ },
569
+
570
+ setHoursDisabled: function (hoursDisabled) {
571
+ this.hoursDisabled = hoursDisabled || [];
572
+ if (!$.isArray(this.hoursDisabled)) {
573
+ this.hoursDisabled = this.hoursDisabled.split(/,\s*/);
574
+ }
575
+ this.hoursDisabled = $.map(this.hoursDisabled, function (d) {
576
+ return parseInt(d, 10);
577
+ });
578
+ this.update();
579
+ this.updateNavArrows();
580
+ },
581
+
582
+ place: function () {
583
+ if (this.isInline) return;
584
+
585
+ if (!this.zIndex) {
586
+ var index_highest = 0;
587
+ $('div').each(function () {
588
+ var index_current = parseInt($(this).css('zIndex'), 10);
589
+ if (index_current > index_highest) {
590
+ index_highest = index_current;
591
+ }
592
+ });
593
+ this.zIndex = index_highest + 10;
594
+ }
595
+
596
+ var offset, top, left, containerOffset;
597
+ if (this.container instanceof $) {
598
+ containerOffset = this.container.offset();
599
+ } else {
600
+ containerOffset = $(this.container).offset();
601
+ }
602
+
603
+ if (this.component) {
604
+ offset = this.component.offset();
605
+ left = offset.left;
606
+ if (this.pickerPosition === 'bottom-left' || this.pickerPosition === 'top-left') {
607
+ left += this.component.outerWidth() - this.picker.outerWidth();
608
+ }
609
+ } else {
610
+ offset = this.element.offset();
611
+ left = offset.left;
612
+ if (this.pickerPosition === 'bottom-left' || this.pickerPosition === 'top-left') {
613
+ left += this.element.outerWidth() - this.picker.outerWidth();
614
+ }
615
+ }
616
+
617
+ var bodyWidth = document.body.clientWidth || window.innerWidth;
618
+ if (left + 220 > bodyWidth) {
619
+ left = bodyWidth - 220;
620
+ }
621
+
622
+ if (this.pickerPosition === 'top-left' || this.pickerPosition === 'top-right') {
623
+ top = offset.top - this.picker.outerHeight();
624
+ } else {
625
+ top = offset.top + this.height;
626
+ }
627
+
628
+ top = top - containerOffset.top;
629
+ left = left - containerOffset.left;
630
+
631
+ this.picker.css({
632
+ top: top,
633
+ left: left,
634
+ zIndex: this.zIndex
635
+ });
636
+ },
637
+
638
+ hour_minute: "^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]",
639
+
640
+ update: function () {
641
+ var date, fromArgs = false;
642
+ if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
643
+ date = arguments[0];
644
+ fromArgs = true;
645
+ } else {
646
+ date = (this.isInput ? this.element.val() : this.element.find('input').val()) || this.element.data('date') || this.initialDate;
647
+ if (typeof date === 'string') {
648
+ date = date.replace(/^\s+|\s+$/g, '');
649
+ }
650
+ }
651
+
652
+ if (!date) {
653
+ date = new Date();
654
+ fromArgs = false;
655
+ }
656
+
657
+ if (typeof date === "string") {
658
+ if (new RegExp(this.hour_minute).test(date) || new RegExp(this.hour_minute + ":[0-5][0-9]").test(date)) {
659
+ date = this.getDate()
660
+ }
661
+ }
662
+
663
+ this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType, this.timezone);
664
+
665
+ if (fromArgs) this.setValue();
666
+
667
+ if (this.date < this.startDate) {
668
+ this.viewDate = new Date(this.startDate);
669
+ } else if (this.date > this.endDate) {
670
+ this.viewDate = new Date(this.endDate);
671
+ } else {
672
+ this.viewDate = new Date(this.date);
673
+ }
674
+ this.fill();
675
+ },
676
+
677
+ fillDow: function () {
678
+ var dowCnt = this.weekStart,
679
+ html = '<tr>';
680
+ while (dowCnt < this.weekStart + 7) {
681
+ html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
682
+ }
683
+ html += '</tr>';
684
+ this.picker.find('.datetimepicker-days thead').append(html);
685
+ },
686
+
687
+ fillMonths: function () {
688
+ var html = '';
689
+ var d = new Date(this.viewDate);
690
+ for (var i = 0; i < 12; i++) {
691
+ d.setUTCMonth(i);
692
+ var classes = this.onRenderMonth(d);
693
+ html += '<span class="' + classes.join(' ') + '">' + dates[this.language].monthsShort[i] + '</span>';
694
+ }
695
+ this.picker.find('.datetimepicker-months td').html(html);
696
+ },
697
+
698
+ fill: function () {
699
+ if (!this.date || !this.viewDate) {
700
+ return;
701
+ }
702
+ var d = new Date(this.viewDate),
703
+ year = d.getUTCFullYear(),
704
+ month = d.getUTCMonth(),
705
+ dayMonth = d.getUTCDate(),
706
+ hours = d.getUTCHours(),
707
+ startYear = this.startDate.getUTCFullYear(),
708
+ startMonth = this.startDate.getUTCMonth(),
709
+ endYear = this.endDate.getUTCFullYear(),
710
+ endMonth = this.endDate.getUTCMonth() + 1,
711
+ currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
712
+ today = new Date();
713
+ this.setTitle('.datetimepicker-days', dates[this.language].months[month] + ' ' + year)
714
+ if (this.formatViewType === 'time') {
715
+ var formatted = this.getFormattedDate();
716
+ this.setTitle('.datetimepicker-hours', formatted);
717
+ this.setTitle('.datetimepicker-minutes', formatted);
718
+ } else {
719
+ this.setTitle('.datetimepicker-hours', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
720
+ this.setTitle('.datetimepicker-minutes', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
721
+ }
722
+ this.picker.find('tfoot th.today')
723
+ .text(dates[this.language].today || dates['en'].today)
724
+ .toggle(this.todayBtn !== false);
725
+ this.picker.find('tfoot th.clear')
726
+ .text(dates[this.language].clear || dates['en'].clear)
727
+ .toggle(this.clearBtn !== false);
728
+ this.updateNavArrows();
729
+ this.fillMonths();
730
+ var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
731
+ day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
732
+ prevMonth.setUTCDate(day);
733
+ prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
734
+ var nextMonth = new Date(prevMonth);
735
+ nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
736
+ nextMonth = nextMonth.valueOf();
737
+ var html = [];
738
+ var classes;
739
+ while (prevMonth.valueOf() < nextMonth) {
740
+ if (prevMonth.getUTCDay() === this.weekStart) {
741
+ html.push('<tr>');
742
+ }
743
+ classes = this.onRenderDay(prevMonth);
744
+ if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() === year && prevMonth.getUTCMonth() < month)) {
745
+ classes.push('old');
746
+ } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() === year && prevMonth.getUTCMonth() > month)) {
747
+ classes.push('new');
748
+ }
749
+ // Compare internal UTC date with local today, not UTC today
750
+ if (this.todayHighlight &&
751
+ prevMonth.getUTCFullYear() === today.getFullYear() &&
752
+ prevMonth.getUTCMonth() === today.getMonth() &&
753
+ prevMonth.getUTCDate() === today.getDate()) {
754
+ classes.push('today');
755
+ }
756
+ if (prevMonth.valueOf() === currentDate) {
757
+ classes.push('active');
758
+ }
759
+ if ((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate ||
760
+ $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1 ||
761
+ $.inArray(prevMonth.toDateString(), this.datesDisabled) !== -1) {
762
+ classes.push('disabled');
763
+ }
764
+ html.push('<td class="' + classes.join(' ') + '">' + prevMonth.getUTCDate() + '</td>');
765
+ if (prevMonth.getUTCDay() === this.weekEnd) {
766
+ html.push('</tr>');
767
+ }
768
+ prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
769
+ }
770
+ this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
771
+
772
+ html = [];
773
+ var txt = '', meridian = '', meridianOld = '';
774
+ var hoursDisabled = this.hoursDisabled || [];
775
+ d = new Date(this.viewDate)
776
+ for (var i = 0; i < 24; i++) {
777
+ d.setUTCHours(i);
778
+ classes = this.onRenderHour(d);
779
+ if (hoursDisabled.indexOf(i) !== -1) {
780
+ classes.push('disabled');
781
+ }
782
+ var actual = UTCDate(year, month, dayMonth, i);
783
+ // We want the previous hour for the startDate
784
+ if ((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
785
+ classes.push('disabled');
786
+ } else if (hours === i) {
787
+ classes.push('active');
788
+ }
789
+ if (this.showMeridian && dates[this.language].meridiem.length === 2) {
790
+ meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
791
+ if (meridian !== meridianOld) {
792
+ if (meridianOld !== '') {
793
+ html.push('</fieldset>');
794
+ }
795
+ html.push('<fieldset class="hour"><legend>' + meridian.toUpperCase() + '</legend>');
796
+ }
797
+ meridianOld = meridian;
798
+ txt = (i % 12 ? i % 12 : 12);
799
+ if (i < 12) {
800
+ classes.push('hour_am');
801
+ } else {
802
+ classes.push('hour_pm');
803
+ }
804
+ html.push('<span class="' + classes.join(' ') + '">' + txt + '</span>');
805
+ if (i === 23) {
806
+ html.push('</fieldset>');
807
+ }
808
+ } else {
809
+ txt = i + ':00';
810
+ html.push('<span class="' + classes.join(' ') + '">' + txt + '</span>');
811
+ }
812
+ }
813
+ this.picker.find('.datetimepicker-hours td').html(html.join(''));
814
+
815
+ html = [];
816
+ txt = '';
817
+ meridian = '';
818
+ meridianOld = '';
819
+ var minutesDisabled = this.minutesDisabled || [];
820
+ d = new Date(this.viewDate);
821
+ for (var i = 0; i < 60; i += this.minuteStep) {
822
+ if (minutesDisabled.indexOf(i) !== -1) continue;
823
+ d.setUTCMinutes(i);
824
+ d.setUTCSeconds(0);
825
+ classes = this.onRenderMinute(d);
826
+ if (this.showMeridian && dates[this.language].meridiem.length === 2) {
827
+ meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
828
+ if (meridian !== meridianOld) {
829
+ if (meridianOld !== '') {
830
+ html.push('</fieldset>');
831
+ }
832
+ html.push('<fieldset class="minute"><legend>' + meridian.toUpperCase() + '</legend>');
833
+ }
834
+ meridianOld = meridian;
835
+ txt = (hours % 12 ? hours % 12 : 12);
836
+ html.push('<span class="' + classes.join(' ') + '">' + txt + ':' + (i < 10 ? '0' + i : i) + '</span>');
837
+ if (i === 59) {
838
+ html.push('</fieldset>');
839
+ }
840
+ } else {
841
+ txt = i + ':00';
842
+ html.push('<span class="' + classes.join(' ') + '">' + hours + ':' + (i < 10 ? '0' + i : i) + '</span>');
843
+ }
844
+ }
845
+ this.picker.find('.datetimepicker-minutes td').html(html.join(''));
846
+
847
+ var currentYear = this.date.getUTCFullYear();
848
+ var months = this.setTitle('.datetimepicker-months', year)
849
+ .end()
850
+ .find('.month').removeClass('active');
851
+ if (currentYear === year) {
852
+ // getUTCMonths() returns 0 based, and we need to select the next one
853
+ // To cater bootstrap 2 we don't need to select the next one
854
+ months.eq(this.date.getUTCMonth()).addClass('active');
855
+ }
856
+ if (year < startYear || year > endYear) {
857
+ months.addClass('disabled');
858
+ }
859
+ if (year === startYear) {
860
+ months.slice(0, startMonth).addClass('disabled');
861
+ }
862
+ if (year === endYear) {
863
+ months.slice(endMonth).addClass('disabled');
864
+ }
865
+
866
+ html = '';
867
+ year = parseInt(year / 10, 10) * 10;
868
+ var yearCont = this.setTitle('.datetimepicker-years', year + '-' + (year + 9))
869
+ .end()
870
+ .find('td');
871
+ year -= 1;
872
+ d = new Date(this.viewDate);
873
+ for (var i = -1; i < 11; i++) {
874
+ d.setUTCFullYear(year);
875
+ classes = this.onRenderYear(d);
876
+ if (i === -1 || i === 10) {
877
+ classes.push(old);
878
+ }
879
+ html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
880
+ year += 1;
881
+ }
882
+ yearCont.html(html);
883
+ this.place();
884
+ },
885
+
886
+ updateNavArrows: function () {
887
+ var d = new Date(this.viewDate),
888
+ year = d.getUTCFullYear(),
889
+ month = d.getUTCMonth(),
890
+ day = d.getUTCDate(),
891
+ hour = d.getUTCHours();
892
+ switch (this.viewMode) {
893
+ case 0:
894
+ if (year <= this.startDate.getUTCFullYear()
895
+ && month <= this.startDate.getUTCMonth()
896
+ && day <= this.startDate.getUTCDate()
897
+ && hour <= this.startDate.getUTCHours()) {
898
+ this.picker.find('.prev').css({ visibility: 'hidden' });
899
+ } else {
900
+ this.picker.find('.prev').css({ visibility: 'visible' });
901
+ }
902
+ if (year >= this.endDate.getUTCFullYear()
903
+ && month >= this.endDate.getUTCMonth()
904
+ && day >= this.endDate.getUTCDate()
905
+ && hour >= this.endDate.getUTCHours()) {
906
+ this.picker.find('.next').css({ visibility: 'hidden' });
907
+ } else {
908
+ this.picker.find('.next').css({ visibility: 'visible' });
909
+ }
910
+ break;
911
+ case 1:
912
+ if (year <= this.startDate.getUTCFullYear()
913
+ && month <= this.startDate.getUTCMonth()
914
+ && day <= this.startDate.getUTCDate()) {
915
+ this.picker.find('.prev').css({ visibility: 'hidden' });
916
+ } else {
917
+ this.picker.find('.prev').css({ visibility: 'visible' });
918
+ }
919
+ if (year >= this.endDate.getUTCFullYear()
920
+ && month >= this.endDate.getUTCMonth()
921
+ && day >= this.endDate.getUTCDate()) {
922
+ this.picker.find('.next').css({ visibility: 'hidden' });
923
+ } else {
924
+ this.picker.find('.next').css({ visibility: 'visible' });
925
+ }
926
+ break;
927
+ case 2:
928
+ if (year <= this.startDate.getUTCFullYear()
929
+ && month <= this.startDate.getUTCMonth()) {
930
+ this.picker.find('.prev').css({ visibility: 'hidden' });
931
+ } else {
932
+ this.picker.find('.prev').css({ visibility: 'visible' });
933
+ }
934
+ if (year >= this.endDate.getUTCFullYear()
935
+ && month >= this.endDate.getUTCMonth()) {
936
+ this.picker.find('.next').css({ visibility: 'hidden' });
937
+ } else {
938
+ this.picker.find('.next').css({ visibility: 'visible' });
939
+ }
940
+ break;
941
+ case 3:
942
+ case 4:
943
+ if (year <= this.startDate.getUTCFullYear()) {
944
+ this.picker.find('.prev').css({ visibility: 'hidden' });
945
+ } else {
946
+ this.picker.find('.prev').css({ visibility: 'visible' });
947
+ }
948
+ if (year >= this.endDate.getUTCFullYear()) {
949
+ this.picker.find('.next').css({ visibility: 'hidden' });
950
+ } else {
951
+ this.picker.find('.next').css({ visibility: 'visible' });
952
+ }
953
+ break;
954
+ }
955
+ },
956
+
957
+ mousewheel: function (e) {
958
+
959
+ e.preventDefault();
960
+ e.stopPropagation();
961
+
962
+ if (this.wheelPause) {
963
+ return;
964
+ }
965
+
966
+ this.wheelPause = true;
967
+
968
+ var originalEvent = e.originalEvent;
969
+
970
+ var delta = originalEvent.wheelDelta;
971
+
972
+ var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
973
+
974
+ if (this.wheelViewModeNavigationInverseDirection) {
975
+ mode = -mode;
976
+ }
977
+
978
+ this.showMode(mode);
979
+
980
+ setTimeout($.proxy(function () {
981
+
982
+ this.wheelPause = false
983
+
984
+ }, this), this.wheelViewModeNavigationDelay);
985
+
986
+ },
987
+
988
+ click: function (e) {
989
+ e.stopPropagation();
990
+ e.preventDefault();
991
+ var target = $(e.target).closest('span, td, th, legend');
992
+ if (target.is('.' + this.icontype)) {
993
+ target = $(target).parent().closest('span, td, th, legend');
994
+ }
995
+ if (target.length === 1) {
996
+ if (target.is('.disabled')) {
997
+ this.element.trigger({
998
+ type: 'outOfRange',
999
+ date: this.viewDate,
1000
+ startDate: this.startDate,
1001
+ endDate: this.endDate
1002
+ });
1003
+ return;
1004
+ }
1005
+ switch (target[0].nodeName.toLowerCase()) {
1006
+ case 'th':
1007
+ switch (target[0].className) {
1008
+ case 'switch':
1009
+ this.showMode(1);
1010
+ break;
1011
+ case 'prev':
1012
+ case 'next':
1013
+ var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
1014
+ switch (this.viewMode) {
1015
+ case 0:
1016
+ this.viewDate = this.moveHour(this.viewDate, dir);
1017
+ break;
1018
+ case 1:
1019
+ this.viewDate = this.moveDate(this.viewDate, dir);
1020
+ break;
1021
+ case 2:
1022
+ this.viewDate = this.moveMonth(this.viewDate, dir);
1023
+ break;
1024
+ case 3:
1025
+ case 4:
1026
+ this.viewDate = this.moveYear(this.viewDate, dir);
1027
+ break;
1028
+ }
1029
+ this.fill();
1030
+ this.element.trigger({
1031
+ type: target[0].className + ':' + this.convertViewModeText(this.viewMode),
1032
+ date: this.viewDate,
1033
+ startDate: this.startDate,
1034
+ endDate: this.endDate
1035
+ });
1036
+ break;
1037
+ case 'clear':
1038
+ this.reset();
1039
+ if (this.autoclose) {
1040
+ this.hide();
1041
+ }
1042
+ break;
1043
+ case 'today':
1044
+ var date = new Date();
1045
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
1046
+
1047
+ // Respect startDate and endDate.
1048
+ if (date < this.startDate) date = this.startDate;
1049
+ else if (date > this.endDate) date = this.endDate;
1050
+
1051
+ this.viewMode = this.startViewMode;
1052
+ this.showMode(0);
1053
+ this._setDate(date);
1054
+ this.fill();
1055
+ if (this.autoclose) {
1056
+ this.hide();
1057
+ }
1058
+ break;
1059
+ }
1060
+ break;
1061
+ case 'span':
1062
+ if (!target.is('.disabled')) {
1063
+ var year = this.viewDate.getUTCFullYear(),
1064
+ month = this.viewDate.getUTCMonth(),
1065
+ day = this.viewDate.getUTCDate(),
1066
+ hours = this.viewDate.getUTCHours(),
1067
+ minutes = this.viewDate.getUTCMinutes(),
1068
+ seconds = this.viewDate.getUTCSeconds();
1069
+
1070
+ if (target.is('.month')) {
1071
+ this.viewDate.setUTCDate(1);
1072
+ month = target.parent().find('span').index(target);
1073
+ day = this.viewDate.getUTCDate();
1074
+ this.viewDate.setUTCMonth(month);
1075
+ this.element.trigger({
1076
+ type: 'changeMonth',
1077
+ date: this.viewDate
1078
+ });
1079
+ if (this.viewSelect >= 3) {
1080
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
1081
+ }
1082
+ } else if (target.is('.year')) {
1083
+ this.viewDate.setUTCDate(1);
1084
+ year = parseInt(target.text(), 10) || 0;
1085
+ this.viewDate.setUTCFullYear(year);
1086
+ this.element.trigger({
1087
+ type: 'changeYear',
1088
+ date: this.viewDate
1089
+ });
1090
+ if (this.viewSelect >= 4) {
1091
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
1092
+ }
1093
+ } else if (target.is('.hour')) {
1094
+ hours = parseInt(target.text(), 10) || 0;
1095
+ if (target.hasClass('hour_am') || target.hasClass('hour_pm')) {
1096
+ if (hours === 12 && target.hasClass('hour_am')) {
1097
+ hours = 0;
1098
+ } else if (hours !== 12 && target.hasClass('hour_pm')) {
1099
+ hours += 12;
1100
+ }
1101
+ }
1102
+ this.viewDate.setUTCHours(hours);
1103
+ this.element.trigger({
1104
+ type: 'changeHour',
1105
+ date: this.viewDate
1106
+ });
1107
+ if (this.viewSelect >= 1) {
1108
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
1109
+ }
1110
+ } else if (target.is('.minute')) {
1111
+ minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
1112
+ this.viewDate.setUTCMinutes(minutes);
1113
+ this.element.trigger({
1114
+ type: 'changeMinute',
1115
+ date: this.viewDate
1116
+ });
1117
+ if (this.viewSelect >= 0) {
1118
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
1119
+ }
1120
+ }
1121
+ if (this.viewMode !== 0) {
1122
+ var oldViewMode = this.viewMode;
1123
+ this.showMode(-1);
1124
+ this.fill();
1125
+ if (oldViewMode === this.viewMode && this.autoclose) {
1126
+ this.hide();
1127
+ }
1128
+ } else {
1129
+ this.fill();
1130
+ if (this.autoclose) {
1131
+ this.hide();
1132
+ }
1133
+ }
1134
+ }
1135
+ break;
1136
+ case 'td':
1137
+ if (target.is('.day') && !target.is('.disabled')) {
1138
+ var day = parseInt(target.text(), 10) || 1;
1139
+ var year = this.viewDate.getUTCFullYear(),
1140
+ month = this.viewDate.getUTCMonth(),
1141
+ hours = this.viewDate.getUTCHours(),
1142
+ minutes = this.viewDate.getUTCMinutes(),
1143
+ seconds = this.viewDate.getUTCSeconds();
1144
+ if (target.is('.old')) {
1145
+ if (month === 0) {
1146
+ month = 11;
1147
+ year -= 1;
1148
+ } else {
1149
+ month -= 1;
1150
+ }
1151
+ } else if (target.is('.new')) {
1152
+ if (month === 11) {
1153
+ month = 0;
1154
+ year += 1;
1155
+ } else {
1156
+ month += 1;
1157
+ }
1158
+ }
1159
+ this.viewDate.setUTCFullYear(year);
1160
+ this.viewDate.setUTCMonth(month, day);
1161
+ this.element.trigger({
1162
+ type: 'changeDay',
1163
+ date: this.viewDate
1164
+ });
1165
+ if (this.viewSelect >= 2) {
1166
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
1167
+ }
1168
+ }
1169
+ var oldViewMode = this.viewMode;
1170
+ this.showMode(-1);
1171
+ this.fill();
1172
+ if (oldViewMode === this.viewMode && this.autoclose) {
1173
+ this.hide();
1174
+ }
1175
+ break;
1176
+ }
1177
+ }
1178
+ },
1179
+
1180
+ _setDate: function (date, which) {
1181
+ if (!which || which === 'date')
1182
+ this.date = date;
1183
+ if (!which || which === 'view')
1184
+ this.viewDate = date;
1185
+ this.fill();
1186
+ this.setValue();
1187
+ var element;
1188
+ if (this.isInput) {
1189
+ element = this.element;
1190
+ } else if (this.component) {
1191
+ element = this.element.find('input');
1192
+ }
1193
+ if (element) {
1194
+ element.change();
1195
+ }
1196
+ this.element.trigger({
1197
+ type: 'changeDate',
1198
+ date: this.getDate()
1199
+ });
1200
+ if (date === null)
1201
+ this.date = this.viewDate;
1202
+ },
1203
+
1204
+ moveMinute: function (date, dir) {
1205
+ if (!dir) return date;
1206
+ var new_date = new Date(date.valueOf());
1207
+ //dir = dir > 0 ? 1 : -1;
1208
+ new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
1209
+ return new_date;
1210
+ },
1211
+
1212
+ moveHour: function (date, dir) {
1213
+ if (!dir) return date;
1214
+ var new_date = new Date(date.valueOf());
1215
+ //dir = dir > 0 ? 1 : -1;
1216
+ new_date.setUTCHours(new_date.getUTCHours() + dir);
1217
+ return new_date;
1218
+ },
1219
+
1220
+ moveDate: function (date, dir) {
1221
+ if (!dir) return date;
1222
+ var new_date = new Date(date.valueOf());
1223
+ //dir = dir > 0 ? 1 : -1;
1224
+ new_date.setUTCDate(new_date.getUTCDate() + dir);
1225
+ return new_date;
1226
+ },
1227
+
1228
+ moveMonth: function (date, dir) {
1229
+ if (!dir) return date;
1230
+ var new_date = new Date(date.valueOf()),
1231
+ day = new_date.getUTCDate(),
1232
+ month = new_date.getUTCMonth(),
1233
+ mag = Math.abs(dir),
1234
+ new_month, test;
1235
+ dir = dir > 0 ? 1 : -1;
1236
+ if (mag === 1) {
1237
+ test = dir === -1
1238
+ // If going back one month, make sure month is not current month
1239
+ // (eg, Mar 31 -> Feb 31 === Feb 28, not Mar 02)
1240
+ ? function () {
1241
+ return new_date.getUTCMonth() === month;
1242
+ }
1243
+ // If going forward one month, make sure month is as expected
1244
+ // (eg, Jan 31 -> Feb 31 === Feb 28, not Mar 02)
1245
+ : function () {
1246
+ return new_date.getUTCMonth() !== new_month;
1247
+ };
1248
+ new_month = month + dir;
1249
+ new_date.setUTCMonth(new_month);
1250
+ // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
1251
+ if (new_month < 0 || new_month > 11)
1252
+ new_month = (new_month + 12) % 12;
1253
+ } else {
1254
+ // For magnitudes >1, move one month at a time...
1255
+ for (var i = 0; i < mag; i++)
1256
+ // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
1257
+ new_date = this.moveMonth(new_date, dir);
1258
+ // ...then reset the day, keeping it in the new month
1259
+ new_month = new_date.getUTCMonth();
1260
+ new_date.setUTCDate(day);
1261
+ test = function () {
1262
+ return new_month !== new_date.getUTCMonth();
1263
+ };
1264
+ }
1265
+ // Common date-resetting loop -- if date is beyond end of month, make it
1266
+ // end of month
1267
+ while (test()) {
1268
+ new_date.setUTCDate(--day);
1269
+ new_date.setUTCMonth(new_month);
1270
+ }
1271
+ return new_date;
1272
+ },
1273
+
1274
+ moveYear: function (date, dir) {
1275
+ return this.moveMonth(date, dir * 12);
1276
+ },
1277
+
1278
+ dateWithinRange: function (date) {
1279
+ return date >= this.startDate && date <= this.endDate;
1280
+ },
1281
+
1282
+ keydown: function (e) {
1283
+ if (this.picker.is(':not(:visible)')) {
1284
+ if (e.keyCode === 27) // allow escape to hide and re-show picker
1285
+ this.show();
1286
+ return;
1287
+ }
1288
+ var dateChanged = false,
1289
+ dir, newDate, newViewDate;
1290
+ switch (e.keyCode) {
1291
+ case 27: // escape
1292
+ this.hide();
1293
+ e.preventDefault();
1294
+ break;
1295
+ case 37: // left
1296
+ case 39: // right
1297
+ if (!this.keyboardNavigation) break;
1298
+ dir = e.keyCode === 37 ? -1 : 1;
1299
+ var viewMode = this.viewMode;
1300
+ if (e.ctrlKey) {
1301
+ viewMode += 2;
1302
+ } else if (e.shiftKey) {
1303
+ viewMode += 1;
1304
+ }
1305
+ if (viewMode === 4) {
1306
+ newDate = this.moveYear(this.date, dir);
1307
+ newViewDate = this.moveYear(this.viewDate, dir);
1308
+ } else if (viewMode === 3) {
1309
+ newDate = this.moveMonth(this.date, dir);
1310
+ newViewDate = this.moveMonth(this.viewDate, dir);
1311
+ } else if (viewMode === 2) {
1312
+ newDate = this.moveDate(this.date, dir);
1313
+ newViewDate = this.moveDate(this.viewDate, dir);
1314
+ } else if (viewMode === 1) {
1315
+ newDate = this.moveHour(this.date, dir);
1316
+ newViewDate = this.moveHour(this.viewDate, dir);
1317
+ } else if (viewMode === 0) {
1318
+ newDate = this.moveMinute(this.date, dir);
1319
+ newViewDate = this.moveMinute(this.viewDate, dir);
1320
+ }
1321
+ if (this.dateWithinRange(newDate)) {
1322
+ this.date = newDate;
1323
+ this.viewDate = newViewDate;
1324
+ this.setValue();
1325
+ this.update();
1326
+ e.preventDefault();
1327
+ dateChanged = true;
1328
+ }
1329
+ break;
1330
+ case 38: // up
1331
+ case 40: // down
1332
+ if (!this.keyboardNavigation) break;
1333
+ dir = e.keyCode === 38 ? -1 : 1;
1334
+ viewMode = this.viewMode;
1335
+ if (e.ctrlKey) {
1336
+ viewMode += 2;
1337
+ } else if (e.shiftKey) {
1338
+ viewMode += 1;
1339
+ }
1340
+ if (viewMode === 4) {
1341
+ newDate = this.moveYear(this.date, dir);
1342
+ newViewDate = this.moveYear(this.viewDate, dir);
1343
+ } else if (viewMode === 3) {
1344
+ newDate = this.moveMonth(this.date, dir);
1345
+ newViewDate = this.moveMonth(this.viewDate, dir);
1346
+ } else if (viewMode === 2) {
1347
+ newDate = this.moveDate(this.date, dir * 7);
1348
+ newViewDate = this.moveDate(this.viewDate, dir * 7);
1349
+ } else if (viewMode === 1) {
1350
+ if (this.showMeridian) {
1351
+ newDate = this.moveHour(this.date, dir * 6);
1352
+ newViewDate = this.moveHour(this.viewDate, dir * 6);
1353
+ } else {
1354
+ newDate = this.moveHour(this.date, dir * 4);
1355
+ newViewDate = this.moveHour(this.viewDate, dir * 4);
1356
+ }
1357
+ } else if (viewMode === 0) {
1358
+ newDate = this.moveMinute(this.date, dir * 4);
1359
+ newViewDate = this.moveMinute(this.viewDate, dir * 4);
1360
+ }
1361
+ if (this.dateWithinRange(newDate)) {
1362
+ this.date = newDate;
1363
+ this.viewDate = newViewDate;
1364
+ this.setValue();
1365
+ this.update();
1366
+ e.preventDefault();
1367
+ dateChanged = true;
1368
+ }
1369
+ break;
1370
+ case 13: // enter
1371
+ if (this.viewMode !== 0) {
1372
+ var oldViewMode = this.viewMode;
1373
+ this.showMode(-1);
1374
+ this.fill();
1375
+ if (oldViewMode === this.viewMode && this.autoclose) {
1376
+ this.hide();
1377
+ }
1378
+ } else {
1379
+ this.fill();
1380
+ if (this.autoclose) {
1381
+ this.hide();
1382
+ }
1383
+ }
1384
+ e.preventDefault();
1385
+ break;
1386
+ case 9: // tab
1387
+ this.hide();
1388
+ break;
1389
+ }
1390
+ if (dateChanged) {
1391
+ var element;
1392
+ if (this.isInput) {
1393
+ element = this.element;
1394
+ } else if (this.component) {
1395
+ element = this.element.find('input');
1396
+ }
1397
+ if (element) {
1398
+ element.change();
1399
+ }
1400
+ this.element.trigger({
1401
+ type: 'changeDate',
1402
+ date: this.getDate()
1403
+ });
1404
+ }
1405
+ },
1406
+
1407
+ showMode: function (dir) {
1408
+ if (dir) {
1409
+ var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
1410
+ if (newViewMode >= this.minView && newViewMode <= this.maxView) {
1411
+ this.element.trigger({
1412
+ type: 'changeMode',
1413
+ date: this.viewDate,
1414
+ oldViewMode: this.viewMode,
1415
+ newViewMode: newViewMode
1416
+ });
1417
+
1418
+ this.viewMode = newViewMode;
1419
+ }
1420
+ }
1421
+ /*
1422
+ vitalets: fixing bug of very special conditions:
1423
+ jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
1424
+ Method show() does not set display css correctly and datetimepicker is not shown.
1425
+ Changed to .css('display', 'block') solve the problem.
1426
+ See https://github.com/vitalets/x-editable/issues/37
1427
+
1428
+ In jquery 1.7.2+ everything works fine.
1429
+ */
1430
+ //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
1431
+ this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
1432
+ this.updateNavArrows();
1433
+ },
1434
+
1435
+ reset: function () {
1436
+ this._setDate(null, 'date');
1437
+ },
1438
+
1439
+ convertViewModeText: function (viewMode) {
1440
+ switch (viewMode) {
1441
+ case 4:
1442
+ return 'decade';
1443
+ case 3:
1444
+ return 'year';
1445
+ case 2:
1446
+ return 'month';
1447
+ case 1:
1448
+ return 'day';
1449
+ case 0:
1450
+ return 'hour';
1451
+ }
1452
+ }
1453
+ };
1454
+
1455
+ var old = $.fn.datetimepicker;
1456
+ $.fn.datetimepicker = function (option) {
1457
+ var args = Array.apply(null, arguments);
1458
+ args.shift();
1459
+ var internal_return;
1460
+ this.each(function () {
1461
+ var $this = $(this),
1462
+ data = $this.data('datetimepicker'),
1463
+ options = typeof option === 'object' && option;
1464
+ if (!data) {
1465
+ $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({}, $.fn.datetimepicker.defaults, options))));
1466
+ }
1467
+ if (typeof option === 'string' && typeof data[option] === 'function') {
1468
+ internal_return = data[option].apply(data, args);
1469
+ if (internal_return !== undefined) {
1470
+ return false;
1471
+ }
1472
+ }
1473
+ });
1474
+ if (internal_return !== undefined)
1475
+ return internal_return;
1476
+ else
1477
+ return this;
1478
+ };
1479
+
1480
+ $.fn.datetimepicker.defaults = {
1481
+ };
1482
+ $.fn.datetimepicker.Constructor = Datetimepicker;
1483
+ var dates = $.fn.datetimepicker.dates = {
1484
+ en: {
1485
+ days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
1486
+ daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
1487
+ daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
1488
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
1489
+ monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1490
+ meridiem: ['am', 'pm'],
1491
+ suffix: ['st', 'nd', 'rd', 'th'],
1492
+ today: 'Today',
1493
+ clear: 'Clear'
1494
+ }
1495
+ };
1496
+
1497
+ var DPGlobal = {
1498
+ modes: [
1499
+ {
1500
+ clsName: 'minutes',
1501
+ navFnc: 'Hours',
1502
+ navStep: 1
1503
+ },
1504
+ {
1505
+ clsName: 'hours',
1506
+ navFnc: 'Date',
1507
+ navStep: 1
1508
+ },
1509
+ {
1510
+ clsName: 'days',
1511
+ navFnc: 'Month',
1512
+ navStep: 1
1513
+ },
1514
+ {
1515
+ clsName: 'months',
1516
+ navFnc: 'FullYear',
1517
+ navStep: 1
1518
+ },
1519
+ {
1520
+ clsName: 'years',
1521
+ navFnc: 'FullYear',
1522
+ navStep: 10
1523
+ }
1524
+ ],
1525
+ isLeapYear: function (year) {
1526
+ return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
1527
+ },
1528
+ getDaysInMonth: function (year, month) {
1529
+ return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
1530
+ },
1531
+ getDefaultFormat: function (type, field) {
1532
+ if (type === 'standard') {
1533
+ if (field === 'input')
1534
+ return 'yyyy-mm-dd hh:ii';
1535
+ else
1536
+ return 'yyyy-mm-dd hh:ii:ss';
1537
+ } else if (type === 'php') {
1538
+ if (field === 'input')
1539
+ return 'Y-m-d H:i';
1540
+ else
1541
+ return 'Y-m-d H:i:s';
1542
+ } else {
1543
+ throw new Error('Invalid format type.');
1544
+ }
1545
+ },
1546
+ validParts: function (type) {
1547
+ if (type === 'standard') {
1548
+ return /t|hh?|HH?|p|P|z|Z|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
1549
+ } else if (type === 'php') {
1550
+ return /[dDjlNwzFmMnStyYaABgGhHis]/g;
1551
+ } else {
1552
+ throw new Error('Invalid format type.');
1553
+ }
1554
+ },
1555
+ nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
1556
+ parseFormat: function (format, type) {
1557
+ // IE treats \0 as a string end in inputs (truncating the value),
1558
+ // so it's a bad format delimiter, anyway
1559
+ var separators = format.replace(this.validParts(type), '\0').split('\0'),
1560
+ parts = format.match(this.validParts(type));
1561
+ if (!separators || !separators.length || !parts || parts.length === 0) {
1562
+ throw new Error('Invalid date format.');
1563
+ }
1564
+ return { separators: separators, parts: parts };
1565
+ },
1566
+ parseDate: function (date, format, language, type, timezone) {
1567
+ if (date instanceof Date) {
1568
+ var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
1569
+ dateUTC.setMilliseconds(0);
1570
+ return dateUTC;
1571
+ }
1572
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
1573
+ format = this.parseFormat('yyyy-mm-dd', type);
1574
+ }
1575
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
1576
+ format = this.parseFormat('yyyy-mm-dd hh:ii', type);
1577
+ }
1578
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
1579
+ format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
1580
+ }
1581
+ if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
1582
+ var part_re = /([-+]\d+)([dmwy])/,
1583
+ parts = date.match(/([-+]\d+)([dmwy])/g),
1584
+ part, dir;
1585
+ date = new Date();
1586
+ for (var i = 0; i < parts.length; i++) {
1587
+ part = part_re.exec(parts[i]);
1588
+ dir = parseInt(part[1]);
1589
+ switch (part[2]) {
1590
+ case 'd':
1591
+ date.setUTCDate(date.getUTCDate() + dir);
1592
+ break;
1593
+ case 'm':
1594
+ date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
1595
+ break;
1596
+ case 'w':
1597
+ date.setUTCDate(date.getUTCDate() + dir * 7);
1598
+ break;
1599
+ case 'y':
1600
+ date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
1601
+ break;
1602
+ }
1603
+ }
1604
+ return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
1605
+ }
1606
+ var parts = date && date.toString().match(this.nonpunctuation) || [],
1607
+ date = new Date(0, 0, 0, 0, 0, 0, 0),
1608
+ parsed = {},
1609
+ setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P', 'z', 'Z'],
1610
+ setters_map = {
1611
+ hh: function (d, v) {
1612
+ return d.setUTCHours(v);
1613
+ },
1614
+ h: function (d, v) {
1615
+ return d.setUTCHours(v);
1616
+ },
1617
+ HH: function (d, v) {
1618
+ return d.setUTCHours(v === 12 ? 0 : v);
1619
+ },
1620
+ H: function (d, v) {
1621
+ return d.setUTCHours(v === 12 ? 0 : v);
1622
+ },
1623
+ ii: function (d, v) {
1624
+ return d.setUTCMinutes(v);
1625
+ },
1626
+ i: function (d, v) {
1627
+ return d.setUTCMinutes(v);
1628
+ },
1629
+ ss: function (d, v) {
1630
+ return d.setUTCSeconds(v);
1631
+ },
1632
+ s: function (d, v) {
1633
+ return d.setUTCSeconds(v);
1634
+ },
1635
+ yyyy: function (d, v) {
1636
+ return d.setUTCFullYear(v);
1637
+ },
1638
+ yy: function (d, v) {
1639
+ return d.setUTCFullYear(2000 + v);
1640
+ },
1641
+ m: function (d, v) {
1642
+ v -= 1;
1643
+ while (v < 0) v += 12;
1644
+ v %= 12;
1645
+ d.setUTCMonth(v);
1646
+ while (d.getUTCMonth() !== v)
1647
+ if (isNaN(d.getUTCMonth()))
1648
+ return d;
1649
+ else
1650
+ d.setUTCDate(d.getUTCDate() - 1);
1651
+ return d;
1652
+ },
1653
+ d: function (d, v) {
1654
+ return d.setUTCDate(v);
1655
+ },
1656
+ p: function (d, v) {
1657
+ return d.setUTCHours(v === 1 ? d.getUTCHours() + 12 : d.getUTCHours());
1658
+ },
1659
+ z: function () {
1660
+ return timezone
1661
+ }
1662
+ },
1663
+ val, filtered, part;
1664
+ setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1665
+ setters_map['dd'] = setters_map['d'];
1666
+ setters_map['P'] = setters_map['p'];
1667
+ setters_map['Z'] = setters_map['z'];
1668
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
1669
+ if (parts.length === format.parts.length) {
1670
+ for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
1671
+ val = parseInt(parts[i], 10);
1672
+ part = format.parts[i];
1673
+ if (isNaN(val)) {
1674
+ switch (part) {
1675
+ case 'MM':
1676
+ filtered = $(dates[language].months).filter(function () {
1677
+ var m = this.slice(0, parts[i].length),
1678
+ p = parts[i].slice(0, m.length);
1679
+ return m === p;
1680
+ });
1681
+ val = $.inArray(filtered[0], dates[language].months) + 1;
1682
+ break;
1683
+ case 'M':
1684
+ filtered = $(dates[language].monthsShort).filter(function () {
1685
+ var m = this.slice(0, parts[i].length),
1686
+ p = parts[i].slice(0, m.length);
1687
+ return m.toLowerCase() === p.toLowerCase();
1688
+ });
1689
+ val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1690
+ break;
1691
+ case 'p':
1692
+ case 'P':
1693
+ val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
1694
+ break;
1695
+ case 'z':
1696
+ case 'Z':
1697
+ timezone;
1698
+ break;
1699
+
1700
+ }
1701
+ }
1702
+ parsed[part] = val;
1703
+ }
1704
+ for (var i = 0, s; i < setters_order.length; i++) {
1705
+ s = setters_order[i];
1706
+ if (s in parsed && !isNaN(parsed[s]))
1707
+ setters_map[s](date, parsed[s])
1708
+ }
1709
+ }
1710
+ return date;
1711
+ },
1712
+ formatDate: function (date, format, language, type, timezone) {
1713
+ if (date === null) {
1714
+ return '';
1715
+ }
1716
+ var val;
1717
+ if (type === 'standard') {
1718
+ val = {
1719
+ t: date.getTime(),
1720
+ // year
1721
+ yy: date.getUTCFullYear().toString().substring(2),
1722
+ yyyy: date.getUTCFullYear(),
1723
+ // month
1724
+ m: date.getUTCMonth() + 1,
1725
+ M: dates[language].monthsShort[date.getUTCMonth()],
1726
+ MM: dates[language].months[date.getUTCMonth()],
1727
+ // day
1728
+ d: date.getUTCDate(),
1729
+ D: dates[language].daysShort[date.getUTCDay()],
1730
+ DD: dates[language].days[date.getUTCDay()],
1731
+ p: (dates[language].meridiem.length === 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
1732
+ // hour
1733
+ h: date.getUTCHours(),
1734
+ // minute
1735
+ i: date.getUTCMinutes(),
1736
+ // second
1737
+ s: date.getUTCSeconds(),
1738
+ // timezone
1739
+ z: timezone
1740
+ };
1741
+
1742
+ if (dates[language].meridiem.length === 2) {
1743
+ val.H = (val.h % 12 === 0 ? 12 : val.h % 12);
1744
+ }
1745
+ else {
1746
+ val.H = val.h;
1747
+ }
1748
+ val.HH = (val.H < 10 ? '0' : '') + val.H;
1749
+ val.P = val.p.toUpperCase();
1750
+ val.Z = val.z;
1751
+ val.hh = (val.h < 10 ? '0' : '') + val.h;
1752
+ val.ii = (val.i < 10 ? '0' : '') + val.i;
1753
+ val.ss = (val.s < 10 ? '0' : '') + val.s;
1754
+ val.dd = (val.d < 10 ? '0' : '') + val.d;
1755
+ val.mm = (val.m < 10 ? '0' : '') + val.m;
1756
+ } else if (type === 'php') {
1757
+ // php format
1758
+ val = {
1759
+ // year
1760
+ y: date.getUTCFullYear().toString().substring(2),
1761
+ Y: date.getUTCFullYear(),
1762
+ // month
1763
+ F: dates[language].months[date.getUTCMonth()],
1764
+ M: dates[language].monthsShort[date.getUTCMonth()],
1765
+ n: date.getUTCMonth() + 1,
1766
+ t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
1767
+ // day
1768
+ j: date.getUTCDate(),
1769
+ l: dates[language].days[date.getUTCDay()],
1770
+ D: dates[language].daysShort[date.getUTCDay()],
1771
+ w: date.getUTCDay(), // 0 -> 6
1772
+ N: (date.getUTCDay() === 0 ? 7 : date.getUTCDay()), // 1 -> 7
1773
+ S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
1774
+ // hour
1775
+ a: (dates[language].meridiem.length === 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
1776
+ g: (date.getUTCHours() % 12 === 0 ? 12 : date.getUTCHours() % 12),
1777
+ G: date.getUTCHours(),
1778
+ // minute
1779
+ i: date.getUTCMinutes(),
1780
+ // second
1781
+ s: date.getUTCSeconds()
1782
+ };
1783
+ val.m = (val.n < 10 ? '0' : '') + val.n;
1784
+ val.d = (val.j < 10 ? '0' : '') + val.j;
1785
+ val.A = val.a.toString().toUpperCase();
1786
+ val.h = (val.g < 10 ? '0' : '') + val.g;
1787
+ val.H = (val.G < 10 ? '0' : '') + val.G;
1788
+ val.i = (val.i < 10 ? '0' : '') + val.i;
1789
+ val.s = (val.s < 10 ? '0' : '') + val.s;
1790
+ } else {
1791
+ throw new Error('Invalid format type.');
1792
+ }
1793
+ var date = [],
1794
+ seps = $.extend([], format.separators);
1795
+ for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
1796
+ if (seps.length) {
1797
+ date.push(seps.shift());
1798
+ }
1799
+ date.push(val[format.parts[i]]);
1800
+ }
1801
+ if (seps.length) {
1802
+ date.push(seps.shift());
1803
+ }
1804
+ return date.join('');
1805
+ },
1806
+ convertViewMode: function (viewMode) {
1807
+ switch (viewMode) {
1808
+ case 4:
1809
+ case 'decade':
1810
+ viewMode = 4;
1811
+ break;
1812
+ case 3:
1813
+ case 'year':
1814
+ viewMode = 3;
1815
+ break;
1816
+ case 2:
1817
+ case 'month':
1818
+ viewMode = 2;
1819
+ break;
1820
+ case 1:
1821
+ case 'day':
1822
+ viewMode = 1;
1823
+ break;
1824
+ case 0:
1825
+ case 'hour':
1826
+ viewMode = 0;
1827
+ break;
1828
+ }
1829
+
1830
+ return viewMode;
1831
+ },
1832
+ headTemplate: '<thead>' +
1833
+ '<tr>' +
1834
+ '<th class="prev"><i class="{iconType} {leftArrow}"/></th>' +
1835
+ '<th colspan="5" class="switch"></th>' +
1836
+ '<th class="next"><i class="{iconType} {rightArrow}"/></th>' +
1837
+ '</tr>' +
1838
+ '</thead>',
1839
+ headTemplateV3: '<thead>' +
1840
+ '<tr>' +
1841
+ '<th class="prev"><span class="{iconType} {leftArrow}"></span> </th>' +
1842
+ '<th colspan="5" class="switch"></th>' +
1843
+ '<th class="next"><span class="{iconType} {rightArrow}"></span> </th>' +
1844
+ '</tr>' +
1845
+ '</thead>',
1846
+ contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1847
+ footTemplate: '<tfoot>' +
1848
+ '<tr><th colspan="7" class="today"></th></tr>' +
1849
+ '<tr><th colspan="7" class="clear"></th></tr>' +
1850
+ '</tfoot>'
1851
+ };
1852
+ DPGlobal.template = '<div class="datetimepicker">' +
1853
+ '<div class="datetimepicker-minutes">' +
1854
+ '<table class=" table-condensed">' +
1855
+ DPGlobal.headTemplate +
1856
+ DPGlobal.contTemplate +
1857
+ DPGlobal.footTemplate +
1858
+ '</table>' +
1859
+ '</div>' +
1860
+ '<div class="datetimepicker-hours">' +
1861
+ '<table class=" table-condensed">' +
1862
+ DPGlobal.headTemplate +
1863
+ DPGlobal.contTemplate +
1864
+ DPGlobal.footTemplate +
1865
+ '</table>' +
1866
+ '</div>' +
1867
+ '<div class="datetimepicker-days">' +
1868
+ '<table class=" table-condensed">' +
1869
+ DPGlobal.headTemplate +
1870
+ '<tbody></tbody>' +
1871
+ DPGlobal.footTemplate +
1872
+ '</table>' +
1873
+ '</div>' +
1874
+ '<div class="datetimepicker-months">' +
1875
+ '<table class="table-condensed">' +
1876
+ DPGlobal.headTemplate +
1877
+ DPGlobal.contTemplate +
1878
+ DPGlobal.footTemplate +
1879
+ '</table>' +
1880
+ '</div>' +
1881
+ '<div class="datetimepicker-years">' +
1882
+ '<table class="table-condensed">' +
1883
+ DPGlobal.headTemplate +
1884
+ DPGlobal.contTemplate +
1885
+ DPGlobal.footTemplate +
1886
+ '</table>' +
1887
+ '</div>' +
1888
+ '</div>';
1889
+ DPGlobal.templateV3 = '<div class="datetimepicker">' +
1890
+ '<div class="datetimepicker-minutes">' +
1891
+ '<table class=" table-condensed">' +
1892
+ DPGlobal.headTemplateV3 +
1893
+ DPGlobal.contTemplate +
1894
+ DPGlobal.footTemplate +
1895
+ '</table>' +
1896
+ '</div>' +
1897
+ '<div class="datetimepicker-hours">' +
1898
+ '<table class=" table-condensed">' +
1899
+ DPGlobal.headTemplateV3 +
1900
+ DPGlobal.contTemplate +
1901
+ DPGlobal.footTemplate +
1902
+ '</table>' +
1903
+ '</div>' +
1904
+ '<div class="datetimepicker-days">' +
1905
+ '<table class=" table-condensed">' +
1906
+ DPGlobal.headTemplateV3 +
1907
+ '<tbody></tbody>' +
1908
+ DPGlobal.footTemplate +
1909
+ '</table>' +
1910
+ '</div>' +
1911
+ '<div class="datetimepicker-months">' +
1912
+ '<table class="table-condensed">' +
1913
+ DPGlobal.headTemplateV3 +
1914
+ DPGlobal.contTemplate +
1915
+ DPGlobal.footTemplate +
1916
+ '</table>' +
1917
+ '</div>' +
1918
+ '<div class="datetimepicker-years">' +
1919
+ '<table class="table-condensed">' +
1920
+ DPGlobal.headTemplateV3 +
1921
+ DPGlobal.contTemplate +
1922
+ DPGlobal.footTemplate +
1923
+ '</table>' +
1924
+ '</div>' +
1925
+ '</div>';
1926
+ $.fn.datetimepicker.DPGlobal = DPGlobal;
1927
+
1928
+ /* DATETIMEPICKER NO CONFLICT
1929
+ * =================== */
1930
+
1931
+ $.fn.datetimepicker.noConflict = function () {
1932
+ $.fn.datetimepicker = old;
1933
+ return this;
1934
+ };
1935
+
1936
+ /* DATETIMEPICKER DATA-API
1937
+ * ================== */
1938
+
1939
+ $(document).on(
1940
+ 'focus.datetimepicker.data-api click.datetimepicker.data-api',
1941
+ '[data-provide="datetimepicker"]',
1942
+ function (e) {
1943
+ var $this = $(this);
1944
+ if ($this.data('datetimepicker')) return;
1945
+ e.preventDefault();
1946
+ // component click requires us to explicitly show it
1947
+ $this.datetimepicker('show');
1948
+ }
1949
+ );
1950
+ $(function () {
1951
+ $('[data-provide="datetimepicker-inline"]').datetimepicker();
1952
+ });
1953
+
1954
+ }));