tsichart-core 2.1.0 → 2.1.2
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.
- package/dist/index.js +12173 -493
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11979 -298
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1270 -16
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TsiClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function _mergeNamespaces(n, m) {
|
|
8
|
+
m.forEach(function (e) {
|
|
9
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !(k in n)) {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
function ascending$3(a, b) {
|
|
8
23
|
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
9
24
|
}
|
|
@@ -21599,6 +21614,8 @@
|
|
|
21599
21614
|
return voronoi;
|
|
21600
21615
|
}
|
|
21601
21616
|
|
|
21617
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
21618
|
+
|
|
21602
21619
|
function getDefaultExportFromCjs (x) {
|
|
21603
21620
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
21604
21621
|
}
|
|
@@ -31620,9 +31637,9 @@
|
|
|
31620
31637
|
// maintainable code, while at the same time manually optimizing for tiny minified file size,
|
|
31621
31638
|
// browser compatibility without additional requirements
|
|
31622
31639
|
// and very few assumptions about the user's page layout.
|
|
31623
|
-
var global = typeof window !== 'undefined' ? window : null;
|
|
31624
|
-
var ssr = global === null;
|
|
31625
|
-
var document$1 = !ssr ? global.document : undefined;
|
|
31640
|
+
var global$1 = typeof window !== 'undefined' ? window : null;
|
|
31641
|
+
var ssr = global$1 === null;
|
|
31642
|
+
var document$1 = !ssr ? global$1.document : undefined;
|
|
31626
31643
|
|
|
31627
31644
|
// Save a couple long function names that are used frequently.
|
|
31628
31645
|
// This optimization saves around 400 bytes.
|
|
@@ -32088,11 +32105,11 @@
|
|
|
32088
32105
|
self.dragging = false;
|
|
32089
32106
|
|
|
32090
32107
|
// Remove the stored event listeners. This is why we store them.
|
|
32091
|
-
global[removeEventListener]('mouseup', self.stop);
|
|
32092
|
-
global[removeEventListener]('touchend', self.stop);
|
|
32093
|
-
global[removeEventListener]('touchcancel', self.stop);
|
|
32094
|
-
global[removeEventListener]('mousemove', self.move);
|
|
32095
|
-
global[removeEventListener]('touchmove', self.move);
|
|
32108
|
+
global$1[removeEventListener]('mouseup', self.stop);
|
|
32109
|
+
global$1[removeEventListener]('touchend', self.stop);
|
|
32110
|
+
global$1[removeEventListener]('touchcancel', self.stop);
|
|
32111
|
+
global$1[removeEventListener]('mousemove', self.move);
|
|
32112
|
+
global$1[removeEventListener]('touchmove', self.move);
|
|
32096
32113
|
|
|
32097
32114
|
// Clear bound function references
|
|
32098
32115
|
self.stop = null;
|
|
@@ -32149,11 +32166,11 @@
|
|
|
32149
32166
|
self.stop = stopDragging.bind(self);
|
|
32150
32167
|
|
|
32151
32168
|
// All the binding. `window` gets the stop events in case we drag out of the elements.
|
|
32152
|
-
global[addEventListener]('mouseup', self.stop);
|
|
32153
|
-
global[addEventListener]('touchend', self.stop);
|
|
32154
|
-
global[addEventListener]('touchcancel', self.stop);
|
|
32155
|
-
global[addEventListener]('mousemove', self.move);
|
|
32156
|
-
global[addEventListener]('touchmove', self.move);
|
|
32169
|
+
global$1[addEventListener]('mouseup', self.stop);
|
|
32170
|
+
global$1[addEventListener]('touchend', self.stop);
|
|
32171
|
+
global$1[addEventListener]('touchcancel', self.stop);
|
|
32172
|
+
global$1[addEventListener]('mousemove', self.move);
|
|
32173
|
+
global$1[addEventListener]('touchmove', self.move);
|
|
32157
32174
|
|
|
32158
32175
|
// Disable selection. Disable!
|
|
32159
32176
|
a[addEventListener]('selectstart', NOOP);
|
|
@@ -37333,26 +37350,1263 @@
|
|
|
37333
37350
|
var momentExports = requireMoment();
|
|
37334
37351
|
var moment = /*@__PURE__*/getDefaultExportFromCjs(momentExports);
|
|
37335
37352
|
|
|
37353
|
+
var pikaday$2 = {exports: {}};
|
|
37354
|
+
|
|
37355
|
+
/*!
|
|
37356
|
+
* Pikaday
|
|
37357
|
+
*
|
|
37358
|
+
* Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
|
|
37359
|
+
*/
|
|
37360
|
+
var pikaday$1 = pikaday$2.exports;
|
|
37361
|
+
|
|
37362
|
+
var hasRequiredPikaday;
|
|
37363
|
+
|
|
37364
|
+
function requirePikaday () {
|
|
37365
|
+
if (hasRequiredPikaday) return pikaday$2.exports;
|
|
37366
|
+
hasRequiredPikaday = 1;
|
|
37367
|
+
(function (module, exports) {
|
|
37368
|
+
(function (root, factory) {
|
|
37369
|
+
|
|
37370
|
+
var moment;
|
|
37371
|
+
{
|
|
37372
|
+
// CommonJS module
|
|
37373
|
+
// Load moment.js as an optional dependency
|
|
37374
|
+
try { moment = requireMoment(); } catch (e) { moment = (typeof window !== 'undefined' && window.moment) || undefined; }
|
|
37375
|
+
module.exports = factory(moment);
|
|
37376
|
+
}
|
|
37377
|
+
}(typeof self !== 'undefined' ? self :
|
|
37378
|
+
typeof window !== 'undefined' ? window :
|
|
37379
|
+
typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
|
|
37380
|
+
pikaday$1, function (moment) {
|
|
37381
|
+
|
|
37382
|
+
/**
|
|
37383
|
+
* feature detection and helper functions
|
|
37384
|
+
*/
|
|
37385
|
+
var hasMoment = typeof moment === 'function' || (moment && typeof moment.version === 'string'),
|
|
37386
|
+
|
|
37387
|
+
hasEventListeners = !!window.addEventListener,
|
|
37388
|
+
|
|
37389
|
+
document = window.document,
|
|
37390
|
+
|
|
37391
|
+
sto = window.setTimeout,
|
|
37392
|
+
|
|
37393
|
+
addEvent = function (el, e, callback, capture) {
|
|
37394
|
+
if (hasEventListeners) {
|
|
37395
|
+
el.addEventListener(e, callback, !!capture);
|
|
37396
|
+
} else {
|
|
37397
|
+
el.attachEvent('on' + e, callback);
|
|
37398
|
+
}
|
|
37399
|
+
},
|
|
37400
|
+
|
|
37401
|
+
removeEvent = function (el, e, callback, capture) {
|
|
37402
|
+
if (hasEventListeners) {
|
|
37403
|
+
el.removeEventListener(e, callback, !!capture);
|
|
37404
|
+
} else {
|
|
37405
|
+
el.detachEvent('on' + e, callback);
|
|
37406
|
+
}
|
|
37407
|
+
},
|
|
37408
|
+
|
|
37409
|
+
trim = function (str) {
|
|
37410
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
|
37411
|
+
},
|
|
37412
|
+
|
|
37413
|
+
hasClass = function (el, cn) {
|
|
37414
|
+
return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
|
|
37415
|
+
},
|
|
37416
|
+
|
|
37417
|
+
addClass = function (el, cn) {
|
|
37418
|
+
if (!hasClass(el, cn)) {
|
|
37419
|
+
el.className = (el.className === '') ? cn : el.className + ' ' + cn;
|
|
37420
|
+
}
|
|
37421
|
+
},
|
|
37422
|
+
|
|
37423
|
+
removeClass = function (el, cn) {
|
|
37424
|
+
el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
|
|
37425
|
+
},
|
|
37426
|
+
|
|
37427
|
+
isArray = function (obj) {
|
|
37428
|
+
return (/Array/).test(Object.prototype.toString.call(obj));
|
|
37429
|
+
},
|
|
37430
|
+
|
|
37431
|
+
isDate = function (obj) {
|
|
37432
|
+
return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
|
|
37433
|
+
},
|
|
37434
|
+
|
|
37435
|
+
isWeekend = function (date) {
|
|
37436
|
+
var day = date.getDay();
|
|
37437
|
+
return day === 0 || day === 6;
|
|
37438
|
+
},
|
|
37439
|
+
|
|
37440
|
+
isLeapYear = function (year) {
|
|
37441
|
+
// solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
|
|
37442
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
37443
|
+
},
|
|
37444
|
+
|
|
37445
|
+
getDaysInMonth = function (year, month) {
|
|
37446
|
+
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
|
37447
|
+
},
|
|
37448
|
+
|
|
37449
|
+
setToStartOfDay = function (date) {
|
|
37450
|
+
if (isDate(date)) date.setHours(0, 0, 0, 0);
|
|
37451
|
+
},
|
|
37452
|
+
|
|
37453
|
+
compareDates = function (a, b) {
|
|
37454
|
+
// weak date comparison (use setToStartOfDay(date) to ensure correct result)
|
|
37455
|
+
return a.getTime() === b.getTime();
|
|
37456
|
+
},
|
|
37457
|
+
|
|
37458
|
+
extend = function (to, from, overwrite) {
|
|
37459
|
+
var prop, hasProp;
|
|
37460
|
+
for (prop in from) {
|
|
37461
|
+
hasProp = to[prop] !== undefined;
|
|
37462
|
+
if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
|
|
37463
|
+
if (isDate(from[prop])) {
|
|
37464
|
+
if (overwrite) {
|
|
37465
|
+
to[prop] = new Date(from[prop].getTime());
|
|
37466
|
+
}
|
|
37467
|
+
}
|
|
37468
|
+
else if (isArray(from[prop])) {
|
|
37469
|
+
if (overwrite) {
|
|
37470
|
+
to[prop] = from[prop].slice(0);
|
|
37471
|
+
}
|
|
37472
|
+
} else {
|
|
37473
|
+
to[prop] = extend({}, from[prop], overwrite);
|
|
37474
|
+
}
|
|
37475
|
+
} else if (overwrite || !hasProp) {
|
|
37476
|
+
to[prop] = from[prop];
|
|
37477
|
+
}
|
|
37478
|
+
}
|
|
37479
|
+
return to;
|
|
37480
|
+
},
|
|
37481
|
+
|
|
37482
|
+
fireEvent = function (el, eventName, data) {
|
|
37483
|
+
var ev;
|
|
37484
|
+
|
|
37485
|
+
if (document.createEvent) {
|
|
37486
|
+
ev = document.createEvent('HTMLEvents');
|
|
37487
|
+
ev.initEvent(eventName, true, false);
|
|
37488
|
+
ev = extend(ev, data);
|
|
37489
|
+
el.dispatchEvent(ev);
|
|
37490
|
+
} else if (document.createEventObject) {
|
|
37491
|
+
ev = document.createEventObject();
|
|
37492
|
+
ev = extend(ev, data);
|
|
37493
|
+
el.fireEvent('on' + eventName, ev);
|
|
37494
|
+
}
|
|
37495
|
+
},
|
|
37496
|
+
|
|
37497
|
+
adjustCalendar = function (calendar) {
|
|
37498
|
+
if (calendar.month < 0) {
|
|
37499
|
+
calendar.year -= Math.ceil(Math.abs(calendar.month) / 12);
|
|
37500
|
+
calendar.month += 12;
|
|
37501
|
+
}
|
|
37502
|
+
if (calendar.month > 11) {
|
|
37503
|
+
calendar.year += Math.floor(Math.abs(calendar.month) / 12);
|
|
37504
|
+
calendar.month -= 12;
|
|
37505
|
+
}
|
|
37506
|
+
return calendar;
|
|
37507
|
+
},
|
|
37508
|
+
|
|
37509
|
+
/**
|
|
37510
|
+
* defaults and localisation
|
|
37511
|
+
*/
|
|
37512
|
+
defaults = {
|
|
37513
|
+
|
|
37514
|
+
// bind the picker to a form field
|
|
37515
|
+
field: null,
|
|
37516
|
+
|
|
37517
|
+
// automatically show/hide the picker on `field` focus (default `true` if `field` is set)
|
|
37518
|
+
bound: undefined,
|
|
37519
|
+
|
|
37520
|
+
// position of the datepicker, relative to the field (default to bottom & left)
|
|
37521
|
+
// ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
|
|
37522
|
+
position: 'bottom left',
|
|
37523
|
+
|
|
37524
|
+
// automatically fit in the viewport even if it means repositioning from the position option
|
|
37525
|
+
reposition: true,
|
|
37526
|
+
|
|
37527
|
+
// the default output format for `.toString()` and `field` value
|
|
37528
|
+
format: 'YYYY-MM-DD',
|
|
37529
|
+
|
|
37530
|
+
// the toString function which gets passed a current date object and format
|
|
37531
|
+
// and returns a string
|
|
37532
|
+
toString: null,
|
|
37533
|
+
|
|
37534
|
+
// used to create date object from current input string
|
|
37535
|
+
parse: null,
|
|
37536
|
+
|
|
37537
|
+
// the initial date to view when first opened
|
|
37538
|
+
defaultDate: null,
|
|
37539
|
+
|
|
37540
|
+
// make the `defaultDate` the initial selected value
|
|
37541
|
+
setDefaultDate: false,
|
|
37542
|
+
|
|
37543
|
+
// first day of week (0: Sunday, 1: Monday etc)
|
|
37544
|
+
firstDay: 0,
|
|
37545
|
+
|
|
37546
|
+
// the default flag for moment's strict date parsing
|
|
37547
|
+
formatStrict: false,
|
|
37548
|
+
|
|
37549
|
+
// the minimum/earliest date that can be selected
|
|
37550
|
+
minDate: null,
|
|
37551
|
+
// the maximum/latest date that can be selected
|
|
37552
|
+
maxDate: null,
|
|
37553
|
+
|
|
37554
|
+
// number of years either side, or array of upper/lower range
|
|
37555
|
+
yearRange: 10,
|
|
37556
|
+
|
|
37557
|
+
// show week numbers at head of row
|
|
37558
|
+
showWeekNumber: false,
|
|
37559
|
+
|
|
37560
|
+
// Week picker mode
|
|
37561
|
+
pickWholeWeek: false,
|
|
37562
|
+
|
|
37563
|
+
// used internally (don't config outside)
|
|
37564
|
+
minYear: 0,
|
|
37565
|
+
maxYear: 9999,
|
|
37566
|
+
minMonth: undefined,
|
|
37567
|
+
maxMonth: undefined,
|
|
37568
|
+
|
|
37569
|
+
startRange: null,
|
|
37570
|
+
endRange: null,
|
|
37571
|
+
|
|
37572
|
+
isRTL: false,
|
|
37573
|
+
|
|
37574
|
+
// Additional text to append to the year in the calendar title
|
|
37575
|
+
yearSuffix: '',
|
|
37576
|
+
|
|
37577
|
+
// Render the month after year in the calendar title
|
|
37578
|
+
showMonthAfterYear: false,
|
|
37579
|
+
|
|
37580
|
+
// Render days of the calendar grid that fall in the next or previous month
|
|
37581
|
+
showDaysInNextAndPreviousMonths: false,
|
|
37582
|
+
|
|
37583
|
+
// Allows user to select days that fall in the next or previous month
|
|
37584
|
+
enableSelectionDaysInNextAndPreviousMonths: false,
|
|
37585
|
+
|
|
37586
|
+
// how many months are visible
|
|
37587
|
+
numberOfMonths: 1,
|
|
37588
|
+
|
|
37589
|
+
// when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
|
|
37590
|
+
// only used for the first display or when a selected date is not visible
|
|
37591
|
+
mainCalendar: 'left',
|
|
37592
|
+
|
|
37593
|
+
// Specify a DOM element to render the calendar in
|
|
37594
|
+
container: undefined,
|
|
37595
|
+
|
|
37596
|
+
// Blur field when date is selected
|
|
37597
|
+
blurFieldOnSelect: true,
|
|
37598
|
+
|
|
37599
|
+
// internationalization
|
|
37600
|
+
i18n: {
|
|
37601
|
+
previousMonth: 'Previous Month',
|
|
37602
|
+
nextMonth: 'Next Month',
|
|
37603
|
+
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
37604
|
+
weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
37605
|
+
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
37606
|
+
},
|
|
37607
|
+
|
|
37608
|
+
// Theme Classname
|
|
37609
|
+
theme: null,
|
|
37610
|
+
|
|
37611
|
+
// events array
|
|
37612
|
+
events: [],
|
|
37613
|
+
|
|
37614
|
+
// callback function
|
|
37615
|
+
onSelect: null,
|
|
37616
|
+
onOpen: null,
|
|
37617
|
+
onClose: null,
|
|
37618
|
+
onDraw: null,
|
|
37619
|
+
|
|
37620
|
+
// Enable keyboard input
|
|
37621
|
+
keyboardInput: true
|
|
37622
|
+
},
|
|
37623
|
+
|
|
37624
|
+
|
|
37625
|
+
/**
|
|
37626
|
+
* templating functions to abstract HTML rendering
|
|
37627
|
+
*/
|
|
37628
|
+
renderDayName = function (opts, day, abbr) {
|
|
37629
|
+
day += opts.firstDay;
|
|
37630
|
+
while (day >= 7) {
|
|
37631
|
+
day -= 7;
|
|
37632
|
+
}
|
|
37633
|
+
return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
|
|
37634
|
+
},
|
|
37635
|
+
|
|
37636
|
+
renderDay = function (opts) {
|
|
37637
|
+
var arr = [];
|
|
37638
|
+
var ariaSelected = 'false';
|
|
37639
|
+
if (opts.isEmpty) {
|
|
37640
|
+
if (opts.showDaysInNextAndPreviousMonths) {
|
|
37641
|
+
arr.push('is-outside-current-month');
|
|
37642
|
+
|
|
37643
|
+
if (!opts.enableSelectionDaysInNextAndPreviousMonths) {
|
|
37644
|
+
arr.push('is-selection-disabled');
|
|
37645
|
+
}
|
|
37646
|
+
|
|
37647
|
+
} else {
|
|
37648
|
+
return '<td class="is-empty"></td>';
|
|
37649
|
+
}
|
|
37650
|
+
}
|
|
37651
|
+
if (opts.isDisabled) {
|
|
37652
|
+
arr.push('is-disabled');
|
|
37653
|
+
}
|
|
37654
|
+
if (opts.isToday) {
|
|
37655
|
+
arr.push('is-today');
|
|
37656
|
+
}
|
|
37657
|
+
if (opts.isSelected) {
|
|
37658
|
+
arr.push('is-selected');
|
|
37659
|
+
ariaSelected = 'true';
|
|
37660
|
+
}
|
|
37661
|
+
if (opts.hasEvent) {
|
|
37662
|
+
arr.push('has-event');
|
|
37663
|
+
}
|
|
37664
|
+
if (opts.isInRange) {
|
|
37665
|
+
arr.push('is-inrange');
|
|
37666
|
+
}
|
|
37667
|
+
if (opts.isStartRange) {
|
|
37668
|
+
arr.push('is-startrange');
|
|
37669
|
+
}
|
|
37670
|
+
if (opts.isEndRange) {
|
|
37671
|
+
arr.push('is-endrange');
|
|
37672
|
+
}
|
|
37673
|
+
return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
|
|
37674
|
+
'<button tabIndex="-1" class="pika-button pika-day" type="button" ' +
|
|
37675
|
+
'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
|
|
37676
|
+
opts.day +
|
|
37677
|
+
'</button>' +
|
|
37678
|
+
'</td>';
|
|
37679
|
+
},
|
|
37680
|
+
|
|
37681
|
+
renderWeek = function (d, m, y) {
|
|
37682
|
+
// Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
|
|
37683
|
+
var onejan = new Date(y, 0, 1),
|
|
37684
|
+
weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
|
37685
|
+
return '<td class="pika-week">' + weekNum + '</td>';
|
|
37686
|
+
},
|
|
37687
|
+
|
|
37688
|
+
renderRow = function (days, isRTL, pickWholeWeek, isRowSelected) {
|
|
37689
|
+
return '<tr class="pika-row' + (pickWholeWeek ? ' pick-whole-week' : '') + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>';
|
|
37690
|
+
},
|
|
37691
|
+
|
|
37692
|
+
renderBody = function (rows) {
|
|
37693
|
+
return '<tbody>' + rows.join('') + '</tbody>';
|
|
37694
|
+
},
|
|
37695
|
+
|
|
37696
|
+
renderHead = function (opts) {
|
|
37697
|
+
var i, arr = [];
|
|
37698
|
+
if (opts.showWeekNumber) {
|
|
37699
|
+
arr.push('<th></th>');
|
|
37700
|
+
}
|
|
37701
|
+
for (i = 0; i < 7; i++) {
|
|
37702
|
+
arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
|
|
37703
|
+
}
|
|
37704
|
+
return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
|
|
37705
|
+
},
|
|
37706
|
+
|
|
37707
|
+
renderTitle = function (instance, c, year, month, refYear, randId) {
|
|
37708
|
+
var i, j, arr,
|
|
37709
|
+
opts = instance._o,
|
|
37710
|
+
isMinYear = year === opts.minYear,
|
|
37711
|
+
isMaxYear = year === opts.maxYear,
|
|
37712
|
+
html = '<div id="' + randId + '" class="pika-title">',
|
|
37713
|
+
monthHtml,
|
|
37714
|
+
yearHtml,
|
|
37715
|
+
prev = true,
|
|
37716
|
+
next = true;
|
|
37717
|
+
|
|
37718
|
+
for (arr = [], i = 0; i < 12; i++) {
|
|
37719
|
+
arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
|
|
37720
|
+
(i === month ? ' selected="selected"' : '') +
|
|
37721
|
+
((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
|
|
37722
|
+
opts.i18n.months[i] + '</option>');
|
|
37723
|
+
}
|
|
37724
|
+
|
|
37725
|
+
monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select aria-label="select month" class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
|
|
37726
|
+
|
|
37727
|
+
if (isArray(opts.yearRange)) {
|
|
37728
|
+
i = opts.yearRange[0];
|
|
37729
|
+
j = opts.yearRange[1] + 1;
|
|
37730
|
+
} else {
|
|
37731
|
+
i = year - opts.yearRange;
|
|
37732
|
+
j = 1 + year + opts.yearRange;
|
|
37733
|
+
}
|
|
37734
|
+
|
|
37735
|
+
for (arr = []; i < j && i <= opts.maxYear; i++) {
|
|
37736
|
+
if (i >= opts.minYear) {
|
|
37737
|
+
arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"' : '') + '>' + (i) + '</option>');
|
|
37738
|
+
}
|
|
37739
|
+
}
|
|
37740
|
+
yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select aria-label="select year" class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
|
|
37741
|
+
|
|
37742
|
+
if (opts.showMonthAfterYear) {
|
|
37743
|
+
html += yearHtml + monthHtml;
|
|
37744
|
+
} else {
|
|
37745
|
+
html += monthHtml + yearHtml;
|
|
37746
|
+
}
|
|
37747
|
+
|
|
37748
|
+
if (isMinYear && (month === 0 || opts.minMonth >= month)) {
|
|
37749
|
+
prev = false;
|
|
37750
|
+
}
|
|
37751
|
+
|
|
37752
|
+
if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
|
|
37753
|
+
next = false;
|
|
37754
|
+
}
|
|
37755
|
+
|
|
37756
|
+
if (c === 0) {
|
|
37757
|
+
html += '<button tabIndex="-1" class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
|
|
37758
|
+
}
|
|
37759
|
+
if (c === (instance._o.numberOfMonths - 1)) {
|
|
37760
|
+
html += '<button tabIndex="-1" class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
|
|
37761
|
+
}
|
|
37762
|
+
|
|
37763
|
+
return html += '</div>';
|
|
37764
|
+
},
|
|
37765
|
+
|
|
37766
|
+
renderTable = function (opts, data, randId) {
|
|
37767
|
+
return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
|
|
37768
|
+
},
|
|
37769
|
+
|
|
37770
|
+
|
|
37771
|
+
/**
|
|
37772
|
+
* Pikaday constructor
|
|
37773
|
+
*/
|
|
37774
|
+
Pikaday = function (options) {
|
|
37775
|
+
var self = this,
|
|
37776
|
+
opts = self.config(options);
|
|
37777
|
+
|
|
37778
|
+
self._onMouseDown = function (e) {
|
|
37779
|
+
if (!self._v) {
|
|
37780
|
+
return;
|
|
37781
|
+
}
|
|
37782
|
+
e = e || window.event;
|
|
37783
|
+
var target = e.target || e.srcElement;
|
|
37784
|
+
if (!target) {
|
|
37785
|
+
return;
|
|
37786
|
+
}
|
|
37787
|
+
|
|
37788
|
+
if (!hasClass(target, 'is-disabled')) {
|
|
37789
|
+
if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) {
|
|
37790
|
+
self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
|
|
37791
|
+
if (opts.bound) {
|
|
37792
|
+
sto(function () {
|
|
37793
|
+
self.hide();
|
|
37794
|
+
if (opts.blurFieldOnSelect && opts.field) {
|
|
37795
|
+
opts.field.blur();
|
|
37796
|
+
}
|
|
37797
|
+
}, 100);
|
|
37798
|
+
}
|
|
37799
|
+
}
|
|
37800
|
+
else if (hasClass(target, 'pika-prev')) {
|
|
37801
|
+
self.prevMonth();
|
|
37802
|
+
}
|
|
37803
|
+
else if (hasClass(target, 'pika-next')) {
|
|
37804
|
+
self.nextMonth();
|
|
37805
|
+
}
|
|
37806
|
+
}
|
|
37807
|
+
if (!hasClass(target, 'pika-select')) {
|
|
37808
|
+
// if this is touch event prevent mouse events emulation
|
|
37809
|
+
if (e.preventDefault) {
|
|
37810
|
+
e.preventDefault();
|
|
37811
|
+
} else {
|
|
37812
|
+
e.returnValue = false;
|
|
37813
|
+
return false;
|
|
37814
|
+
}
|
|
37815
|
+
} else {
|
|
37816
|
+
self._c = true;
|
|
37817
|
+
}
|
|
37818
|
+
};
|
|
37819
|
+
|
|
37820
|
+
self._onChange = function (e) {
|
|
37821
|
+
e = e || window.event;
|
|
37822
|
+
var target = e.target || e.srcElement;
|
|
37823
|
+
if (!target) {
|
|
37824
|
+
return;
|
|
37825
|
+
}
|
|
37826
|
+
if (hasClass(target, 'pika-select-month')) {
|
|
37827
|
+
self.gotoMonth(target.value);
|
|
37828
|
+
}
|
|
37829
|
+
else if (hasClass(target, 'pika-select-year')) {
|
|
37830
|
+
self.gotoYear(target.value);
|
|
37831
|
+
}
|
|
37832
|
+
};
|
|
37833
|
+
|
|
37834
|
+
self._onKeyChange = function (e) {
|
|
37835
|
+
e = e || window.event;
|
|
37836
|
+
// ignore if event comes from input box
|
|
37837
|
+
if (self.isVisible() && e.target && e.target.type !== 'text') {
|
|
37838
|
+
|
|
37839
|
+
switch (e.keyCode) {
|
|
37840
|
+
case 13:
|
|
37841
|
+
case 27:
|
|
37842
|
+
if (opts.field) {
|
|
37843
|
+
opts.field.blur();
|
|
37844
|
+
}
|
|
37845
|
+
break;
|
|
37846
|
+
case 37:
|
|
37847
|
+
e.preventDefault();
|
|
37848
|
+
self.adjustDate('subtract', 1);
|
|
37849
|
+
break;
|
|
37850
|
+
case 38:
|
|
37851
|
+
self.adjustDate('subtract', 7);
|
|
37852
|
+
break;
|
|
37853
|
+
case 39:
|
|
37854
|
+
self.adjustDate('add', 1);
|
|
37855
|
+
break;
|
|
37856
|
+
case 40:
|
|
37857
|
+
self.adjustDate('add', 7);
|
|
37858
|
+
break;
|
|
37859
|
+
}
|
|
37860
|
+
}
|
|
37861
|
+
};
|
|
37862
|
+
|
|
37863
|
+
self._onInputChange = function (e) {
|
|
37864
|
+
var date;
|
|
37865
|
+
|
|
37866
|
+
if (e.firedBy === self) {
|
|
37867
|
+
return;
|
|
37868
|
+
}
|
|
37869
|
+
if (opts.parse) {
|
|
37870
|
+
date = opts.parse(opts.field.value, opts.format);
|
|
37871
|
+
} else if (hasMoment) {
|
|
37872
|
+
date = moment(opts.field.value, opts.format, opts.formatStrict);
|
|
37873
|
+
date = (date && date.isValid()) ? date.toDate() : null;
|
|
37874
|
+
}
|
|
37875
|
+
else {
|
|
37876
|
+
date = new Date(Date.parse(opts.field.value));
|
|
37877
|
+
}
|
|
37878
|
+
// if (isDate(date)) {
|
|
37879
|
+
// self.setDate(date);
|
|
37880
|
+
// }
|
|
37881
|
+
// if (!self._v) {
|
|
37882
|
+
// self.show();
|
|
37883
|
+
// }
|
|
37884
|
+
};
|
|
37885
|
+
|
|
37886
|
+
self._onInputFocus = function () {
|
|
37887
|
+
self.show();
|
|
37888
|
+
};
|
|
37889
|
+
|
|
37890
|
+
self._onInputClick = function () {
|
|
37891
|
+
self.show();
|
|
37892
|
+
};
|
|
37893
|
+
|
|
37894
|
+
self._onInputBlur = function () {
|
|
37895
|
+
// IE allows pika div to gain focus; catch blur the input field
|
|
37896
|
+
var pEl = document.activeElement;
|
|
37897
|
+
do {
|
|
37898
|
+
if (hasClass(pEl, 'pika-single')) {
|
|
37899
|
+
return;
|
|
37900
|
+
}
|
|
37901
|
+
}
|
|
37902
|
+
while ((pEl = pEl.parentNode));
|
|
37903
|
+
|
|
37904
|
+
if (!self._c) {
|
|
37905
|
+
self._b = sto(function () {
|
|
37906
|
+
self.hide();
|
|
37907
|
+
}, 50);
|
|
37908
|
+
}
|
|
37909
|
+
self._c = false;
|
|
37910
|
+
};
|
|
37911
|
+
|
|
37912
|
+
self._onClick = function (e) {
|
|
37913
|
+
e = e || window.event;
|
|
37914
|
+
var target = e.target || e.srcElement,
|
|
37915
|
+
pEl = target;
|
|
37916
|
+
if (!target) {
|
|
37917
|
+
return;
|
|
37918
|
+
}
|
|
37919
|
+
if (!hasEventListeners && hasClass(target, 'pika-select')) {
|
|
37920
|
+
if (!target.onchange) {
|
|
37921
|
+
target.setAttribute('onchange', 'return;');
|
|
37922
|
+
addEvent(target, 'change', self._onChange);
|
|
37923
|
+
}
|
|
37924
|
+
}
|
|
37925
|
+
do {
|
|
37926
|
+
if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
|
|
37927
|
+
return;
|
|
37928
|
+
}
|
|
37929
|
+
}
|
|
37930
|
+
while ((pEl = pEl.parentNode));
|
|
37931
|
+
if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
|
|
37932
|
+
self.hide();
|
|
37933
|
+
}
|
|
37934
|
+
};
|
|
37935
|
+
|
|
37936
|
+
self.el = document.createElement('div');
|
|
37937
|
+
self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
|
|
37938
|
+
|
|
37939
|
+
addEvent(self.el, 'mousedown', self._onMouseDown, true);
|
|
37940
|
+
addEvent(self.el, 'touchend', self._onMouseDown, true);
|
|
37941
|
+
addEvent(self.el, 'change', self._onChange);
|
|
37942
|
+
|
|
37943
|
+
if (opts.keyboardInput) {
|
|
37944
|
+
addEvent(document, 'keydown', self._onKeyChange);
|
|
37945
|
+
}
|
|
37946
|
+
|
|
37947
|
+
if (opts.field) {
|
|
37948
|
+
if (opts.container) {
|
|
37949
|
+
opts.container.appendChild(self.el);
|
|
37950
|
+
} else if (opts.bound) {
|
|
37951
|
+
document.body.appendChild(self.el);
|
|
37952
|
+
} else {
|
|
37953
|
+
opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
|
|
37954
|
+
}
|
|
37955
|
+
addEvent(opts.field, 'change', self._onInputChange);
|
|
37956
|
+
|
|
37957
|
+
if (!opts.defaultDate) {
|
|
37958
|
+
if (hasMoment && opts.field.value) {
|
|
37959
|
+
opts.defaultDate = moment(opts.field.value, opts.format).toDate();
|
|
37960
|
+
} else {
|
|
37961
|
+
opts.defaultDate = new Date(Date.parse(opts.field.value));
|
|
37962
|
+
}
|
|
37963
|
+
opts.setDefaultDate = true;
|
|
37964
|
+
}
|
|
37965
|
+
}
|
|
37966
|
+
|
|
37967
|
+
var defDate = opts.defaultDate;
|
|
37968
|
+
|
|
37969
|
+
if (isDate(defDate)) {
|
|
37970
|
+
if (opts.setDefaultDate) {
|
|
37971
|
+
self.setDate(defDate, true);
|
|
37972
|
+
} else {
|
|
37973
|
+
self.gotoDate(defDate);
|
|
37974
|
+
}
|
|
37975
|
+
} else {
|
|
37976
|
+
self.gotoDate(new Date());
|
|
37977
|
+
}
|
|
37978
|
+
|
|
37979
|
+
if (opts.bound) {
|
|
37980
|
+
this.hide();
|
|
37981
|
+
self.el.className += ' is-bound';
|
|
37982
|
+
addEvent(opts.trigger, 'click', self._onInputClick);
|
|
37983
|
+
addEvent(opts.trigger, 'focus', self._onInputFocus);
|
|
37984
|
+
addEvent(opts.trigger, 'blur', self._onInputBlur);
|
|
37985
|
+
} else {
|
|
37986
|
+
this.show();
|
|
37987
|
+
}
|
|
37988
|
+
};
|
|
37989
|
+
|
|
37990
|
+
|
|
37991
|
+
/**
|
|
37992
|
+
* public Pikaday API
|
|
37993
|
+
*/
|
|
37994
|
+
Pikaday.prototype = {
|
|
37995
|
+
|
|
37996
|
+
|
|
37997
|
+
/**
|
|
37998
|
+
* configure functionality
|
|
37999
|
+
*/
|
|
38000
|
+
config: function (options) {
|
|
38001
|
+
if (!this._o) {
|
|
38002
|
+
this._o = extend({}, defaults, true);
|
|
38003
|
+
}
|
|
38004
|
+
|
|
38005
|
+
var opts = extend(this._o, options, true);
|
|
38006
|
+
|
|
38007
|
+
opts.isRTL = !!opts.isRTL;
|
|
38008
|
+
|
|
38009
|
+
opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
|
|
38010
|
+
|
|
38011
|
+
opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
|
|
38012
|
+
|
|
38013
|
+
opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
|
|
38014
|
+
|
|
38015
|
+
opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
|
|
38016
|
+
|
|
38017
|
+
opts.disableWeekends = !!opts.disableWeekends;
|
|
38018
|
+
|
|
38019
|
+
opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
|
|
38020
|
+
|
|
38021
|
+
var nom = parseInt(opts.numberOfMonths, 10) || 1;
|
|
38022
|
+
opts.numberOfMonths = nom > 4 ? 4 : nom;
|
|
38023
|
+
|
|
38024
|
+
if (!isDate(opts.minDate)) {
|
|
38025
|
+
opts.minDate = false;
|
|
38026
|
+
}
|
|
38027
|
+
if (!isDate(opts.maxDate)) {
|
|
38028
|
+
opts.maxDate = false;
|
|
38029
|
+
}
|
|
38030
|
+
if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
|
|
38031
|
+
opts.maxDate = opts.minDate = false;
|
|
38032
|
+
}
|
|
38033
|
+
if (opts.minDate) {
|
|
38034
|
+
this.setMinDate(opts.minDate);
|
|
38035
|
+
}
|
|
38036
|
+
if (opts.maxDate) {
|
|
38037
|
+
this.setMaxDate(opts.maxDate);
|
|
38038
|
+
}
|
|
38039
|
+
|
|
38040
|
+
if (isArray(opts.yearRange)) {
|
|
38041
|
+
var fallback = new Date().getFullYear() - 10;
|
|
38042
|
+
opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
|
|
38043
|
+
opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
|
|
38044
|
+
} else {
|
|
38045
|
+
opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
|
|
38046
|
+
if (opts.yearRange > 100) {
|
|
38047
|
+
opts.yearRange = 100;
|
|
38048
|
+
}
|
|
38049
|
+
}
|
|
38050
|
+
|
|
38051
|
+
return opts;
|
|
38052
|
+
},
|
|
38053
|
+
|
|
38054
|
+
/**
|
|
38055
|
+
* return a formatted string of the current selection (using Moment.js if available)
|
|
38056
|
+
*/
|
|
38057
|
+
toString: function (format) {
|
|
38058
|
+
format = format || this._o.format;
|
|
38059
|
+
if (!isDate(this._d)) {
|
|
38060
|
+
return '';
|
|
38061
|
+
}
|
|
38062
|
+
if (this._o.toString) {
|
|
38063
|
+
return this._o.toString(this._d, format);
|
|
38064
|
+
}
|
|
38065
|
+
if (hasMoment) {
|
|
38066
|
+
return moment(this._d).format(format);
|
|
38067
|
+
}
|
|
38068
|
+
return this._d.toDateString();
|
|
38069
|
+
},
|
|
38070
|
+
|
|
38071
|
+
/**
|
|
38072
|
+
* return a Moment.js object of the current selection (if available)
|
|
38073
|
+
*/
|
|
38074
|
+
getMoment: function () {
|
|
38075
|
+
return hasMoment ? moment(this._d) : null;
|
|
38076
|
+
},
|
|
38077
|
+
|
|
38078
|
+
/**
|
|
38079
|
+
* set the current selection from a Moment.js object (if available)
|
|
38080
|
+
*/
|
|
38081
|
+
setMoment: function (date, preventOnSelect) {
|
|
38082
|
+
if (hasMoment && moment.isMoment(date)) {
|
|
38083
|
+
this.setDate(date.toDate(), preventOnSelect);
|
|
38084
|
+
}
|
|
38085
|
+
},
|
|
38086
|
+
|
|
38087
|
+
/**
|
|
38088
|
+
* return a Date object of the current selection
|
|
38089
|
+
*/
|
|
38090
|
+
getDate: function () {
|
|
38091
|
+
return isDate(this._d) ? new Date(this._d.getTime()) : null;
|
|
38092
|
+
},
|
|
38093
|
+
|
|
38094
|
+
/**
|
|
38095
|
+
* set the current selection
|
|
38096
|
+
*/
|
|
38097
|
+
setDate: function (date, preventOnSelect) {
|
|
38098
|
+
if (!date) {
|
|
38099
|
+
this._d = null;
|
|
38100
|
+
|
|
38101
|
+
if (this._o.field) {
|
|
38102
|
+
this._o.field.value = '';
|
|
38103
|
+
fireEvent(this._o.field, 'change', { firedBy: this });
|
|
38104
|
+
}
|
|
38105
|
+
|
|
38106
|
+
return this.draw();
|
|
38107
|
+
}
|
|
38108
|
+
if (typeof date === 'string') {
|
|
38109
|
+
date = new Date(Date.parse(date));
|
|
38110
|
+
}
|
|
38111
|
+
if (!isDate(date)) {
|
|
38112
|
+
return;
|
|
38113
|
+
}
|
|
38114
|
+
|
|
38115
|
+
var min = this._o.minDate,
|
|
38116
|
+
max = this._o.maxDate;
|
|
38117
|
+
|
|
38118
|
+
if (isDate(min) && date < min) {
|
|
38119
|
+
date = min;
|
|
38120
|
+
} else if (isDate(max) && date > max) {
|
|
38121
|
+
date = max;
|
|
38122
|
+
}
|
|
38123
|
+
|
|
38124
|
+
this._d = new Date(date.getTime());
|
|
38125
|
+
setToStartOfDay(this._d);
|
|
38126
|
+
this.gotoDate(this._d);
|
|
38127
|
+
|
|
38128
|
+
if (this._o.field) {
|
|
38129
|
+
this._o.field.value = this.toString();
|
|
38130
|
+
fireEvent(this._o.field, 'change', { firedBy: this });
|
|
38131
|
+
}
|
|
38132
|
+
if (!preventOnSelect && typeof this._o.onSelect === 'function') {
|
|
38133
|
+
this._o.onSelect.call(this, this.getDate());
|
|
38134
|
+
}
|
|
38135
|
+
},
|
|
38136
|
+
|
|
38137
|
+
/**
|
|
38138
|
+
* change view to a specific date
|
|
38139
|
+
*/
|
|
38140
|
+
gotoDate: function (date) {
|
|
38141
|
+
var newCalendar = true;
|
|
38142
|
+
|
|
38143
|
+
if (!isDate(date)) {
|
|
38144
|
+
return;
|
|
38145
|
+
}
|
|
38146
|
+
|
|
38147
|
+
if (this.calendars) {
|
|
38148
|
+
var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
|
|
38149
|
+
lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1),
|
|
38150
|
+
visibleDate = date.getTime();
|
|
38151
|
+
// get the end of the month
|
|
38152
|
+
lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1);
|
|
38153
|
+
lastVisibleDate.setDate(lastVisibleDate.getDate() - 1);
|
|
38154
|
+
newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
|
|
38155
|
+
}
|
|
38156
|
+
|
|
38157
|
+
if (newCalendar) {
|
|
38158
|
+
this.calendars = [{
|
|
38159
|
+
month: date.getMonth(),
|
|
38160
|
+
year: date.getFullYear()
|
|
38161
|
+
}];
|
|
38162
|
+
if (this._o.mainCalendar === 'right') {
|
|
38163
|
+
this.calendars[0].month += 1 - this._o.numberOfMonths;
|
|
38164
|
+
}
|
|
38165
|
+
}
|
|
38166
|
+
|
|
38167
|
+
this.adjustCalendars();
|
|
38168
|
+
},
|
|
38169
|
+
|
|
38170
|
+
adjustDate: function (sign, days) {
|
|
38171
|
+
|
|
38172
|
+
var day = this.getDate() || new Date();
|
|
38173
|
+
var difference = parseInt(days) * 24 * 60 * 60 * 1000;
|
|
38174
|
+
|
|
38175
|
+
var newDay;
|
|
38176
|
+
|
|
38177
|
+
if (sign === 'add') {
|
|
38178
|
+
newDay = new Date(day.valueOf() + difference);
|
|
38179
|
+
} else if (sign === 'subtract') {
|
|
38180
|
+
newDay = new Date(day.valueOf() - difference);
|
|
38181
|
+
}
|
|
38182
|
+
|
|
38183
|
+
this.setDate(newDay);
|
|
38184
|
+
},
|
|
38185
|
+
|
|
38186
|
+
adjustCalendars: function () {
|
|
38187
|
+
this.calendars[0] = adjustCalendar(this.calendars[0]);
|
|
38188
|
+
for (var c = 1; c < this._o.numberOfMonths; c++) {
|
|
38189
|
+
this.calendars[c] = adjustCalendar({
|
|
38190
|
+
month: this.calendars[0].month + c,
|
|
38191
|
+
year: this.calendars[0].year
|
|
38192
|
+
});
|
|
38193
|
+
}
|
|
38194
|
+
this.draw();
|
|
38195
|
+
},
|
|
38196
|
+
|
|
38197
|
+
gotoToday: function () {
|
|
38198
|
+
this.gotoDate(new Date());
|
|
38199
|
+
},
|
|
38200
|
+
|
|
38201
|
+
/**
|
|
38202
|
+
* change view to a specific month (zero-index, e.g. 0: January)
|
|
38203
|
+
*/
|
|
38204
|
+
gotoMonth: function (month) {
|
|
38205
|
+
if (!isNaN(month)) {
|
|
38206
|
+
this.calendars[0].month = parseInt(month, 10);
|
|
38207
|
+
this.adjustCalendars();
|
|
38208
|
+
}
|
|
38209
|
+
},
|
|
38210
|
+
|
|
38211
|
+
nextMonth: function () {
|
|
38212
|
+
this.calendars[0].month++;
|
|
38213
|
+
this.adjustCalendars();
|
|
38214
|
+
},
|
|
38215
|
+
|
|
38216
|
+
prevMonth: function () {
|
|
38217
|
+
this.calendars[0].month--;
|
|
38218
|
+
this.adjustCalendars();
|
|
38219
|
+
},
|
|
38220
|
+
|
|
38221
|
+
/**
|
|
38222
|
+
* change view to a specific full year (e.g. "2012")
|
|
38223
|
+
*/
|
|
38224
|
+
gotoYear: function (year) {
|
|
38225
|
+
if (!isNaN(year)) {
|
|
38226
|
+
this.calendars[0].year = parseInt(year, 10);
|
|
38227
|
+
this.adjustCalendars();
|
|
38228
|
+
}
|
|
38229
|
+
},
|
|
38230
|
+
|
|
38231
|
+
/**
|
|
38232
|
+
* change the minDate
|
|
38233
|
+
*/
|
|
38234
|
+
setMinDate: function (value) {
|
|
38235
|
+
if (value instanceof Date) {
|
|
38236
|
+
setToStartOfDay(value);
|
|
38237
|
+
this._o.minDate = value;
|
|
38238
|
+
this._o.minYear = value.getFullYear();
|
|
38239
|
+
this._o.minMonth = value.getMonth();
|
|
38240
|
+
} else {
|
|
38241
|
+
this._o.minDate = defaults.minDate;
|
|
38242
|
+
this._o.minYear = defaults.minYear;
|
|
38243
|
+
this._o.minMonth = defaults.minMonth;
|
|
38244
|
+
this._o.startRange = defaults.startRange;
|
|
38245
|
+
}
|
|
38246
|
+
|
|
38247
|
+
this.draw();
|
|
38248
|
+
},
|
|
38249
|
+
|
|
38250
|
+
/**
|
|
38251
|
+
* change the maxDate
|
|
38252
|
+
*/
|
|
38253
|
+
setMaxDate: function (value) {
|
|
38254
|
+
if (value instanceof Date) {
|
|
38255
|
+
setToStartOfDay(value);
|
|
38256
|
+
this._o.maxDate = value;
|
|
38257
|
+
this._o.maxYear = value.getFullYear();
|
|
38258
|
+
this._o.maxMonth = value.getMonth();
|
|
38259
|
+
} else {
|
|
38260
|
+
this._o.maxDate = defaults.maxDate;
|
|
38261
|
+
this._o.maxYear = defaults.maxYear;
|
|
38262
|
+
this._o.maxMonth = defaults.maxMonth;
|
|
38263
|
+
this._o.endRange = defaults.endRange;
|
|
38264
|
+
}
|
|
38265
|
+
|
|
38266
|
+
this.draw();
|
|
38267
|
+
},
|
|
38268
|
+
|
|
38269
|
+
setStartRange: function (value) {
|
|
38270
|
+
this._o.startRange = value;
|
|
38271
|
+
},
|
|
38272
|
+
|
|
38273
|
+
setEndRange: function (value) {
|
|
38274
|
+
this._o.endRange = value;
|
|
38275
|
+
},
|
|
38276
|
+
|
|
38277
|
+
/**
|
|
38278
|
+
* refresh the HTML
|
|
38279
|
+
*/
|
|
38280
|
+
draw: function (force) {
|
|
38281
|
+
if (!this._v && !force) {
|
|
38282
|
+
return;
|
|
38283
|
+
}
|
|
38284
|
+
var opts = this._o,
|
|
38285
|
+
minYear = opts.minYear,
|
|
38286
|
+
maxYear = opts.maxYear,
|
|
38287
|
+
minMonth = opts.minMonth,
|
|
38288
|
+
maxMonth = opts.maxMonth,
|
|
38289
|
+
html = '',
|
|
38290
|
+
randId;
|
|
38291
|
+
|
|
38292
|
+
if (this._y <= minYear) {
|
|
38293
|
+
this._y = minYear;
|
|
38294
|
+
if (!isNaN(minMonth) && this._m < minMonth) {
|
|
38295
|
+
this._m = minMonth;
|
|
38296
|
+
}
|
|
38297
|
+
}
|
|
38298
|
+
if (this._y >= maxYear) {
|
|
38299
|
+
this._y = maxYear;
|
|
38300
|
+
if (!isNaN(maxMonth) && this._m > maxMonth) {
|
|
38301
|
+
this._m = maxMonth;
|
|
38302
|
+
}
|
|
38303
|
+
}
|
|
38304
|
+
|
|
38305
|
+
for (var c = 0; c < opts.numberOfMonths; c++) {
|
|
38306
|
+
randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
|
|
38307
|
+
html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '</div>';
|
|
38308
|
+
}
|
|
38309
|
+
|
|
38310
|
+
this.el.innerHTML = html;
|
|
38311
|
+
|
|
38312
|
+
if (opts.bound) {
|
|
38313
|
+
if (opts.field.type !== 'hidden') {
|
|
38314
|
+
sto(function () {
|
|
38315
|
+
opts.trigger.focus();
|
|
38316
|
+
}, 1);
|
|
38317
|
+
}
|
|
38318
|
+
}
|
|
38319
|
+
|
|
38320
|
+
if (typeof this._o.onDraw === 'function') {
|
|
38321
|
+
this._o.onDraw(this);
|
|
38322
|
+
}
|
|
38323
|
+
|
|
38324
|
+
if (opts.bound) {
|
|
38325
|
+
// let the screen reader user know to use arrow keys
|
|
38326
|
+
opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
|
|
38327
|
+
}
|
|
38328
|
+
},
|
|
38329
|
+
|
|
38330
|
+
adjustPosition: function () {
|
|
38331
|
+
var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
|
|
38332
|
+
|
|
38333
|
+
if (this._o.container) return;
|
|
38334
|
+
|
|
38335
|
+
this.el.style.position = 'absolute';
|
|
38336
|
+
|
|
38337
|
+
field = this._o.trigger;
|
|
38338
|
+
pEl = field;
|
|
38339
|
+
width = this.el.offsetWidth;
|
|
38340
|
+
height = this.el.offsetHeight;
|
|
38341
|
+
viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
38342
|
+
viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
38343
|
+
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
|
|
38344
|
+
|
|
38345
|
+
if (typeof field.getBoundingClientRect === 'function') {
|
|
38346
|
+
clientRect = field.getBoundingClientRect();
|
|
38347
|
+
left = clientRect.left + window.pageXOffset;
|
|
38348
|
+
top = clientRect.bottom + window.pageYOffset;
|
|
38349
|
+
} else {
|
|
38350
|
+
left = pEl.offsetLeft;
|
|
38351
|
+
top = pEl.offsetTop + pEl.offsetHeight;
|
|
38352
|
+
while ((pEl = pEl.offsetParent)) {
|
|
38353
|
+
left += pEl.offsetLeft;
|
|
38354
|
+
top += pEl.offsetTop;
|
|
38355
|
+
}
|
|
38356
|
+
}
|
|
38357
|
+
|
|
38358
|
+
// default position is bottom & left
|
|
38359
|
+
if ((this._o.reposition && left + width > viewportWidth) ||
|
|
38360
|
+
(
|
|
38361
|
+
this._o.position.indexOf('right') > -1 &&
|
|
38362
|
+
left - width + field.offsetWidth > 0
|
|
38363
|
+
)
|
|
38364
|
+
) {
|
|
38365
|
+
left = left - width + field.offsetWidth;
|
|
38366
|
+
}
|
|
38367
|
+
if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
|
|
38368
|
+
(
|
|
38369
|
+
this._o.position.indexOf('top') > -1 &&
|
|
38370
|
+
top - height - field.offsetHeight > 0
|
|
38371
|
+
)
|
|
38372
|
+
) {
|
|
38373
|
+
top = top - height - field.offsetHeight;
|
|
38374
|
+
}
|
|
38375
|
+
|
|
38376
|
+
this.el.style.left = left + 'px';
|
|
38377
|
+
this.el.style.top = top + 'px';
|
|
38378
|
+
},
|
|
38379
|
+
|
|
38380
|
+
/**
|
|
38381
|
+
* render HTML for a particular month
|
|
38382
|
+
*/
|
|
38383
|
+
render: function (year, month, randId) {
|
|
38384
|
+
var opts = this._o,
|
|
38385
|
+
now = new Date(),
|
|
38386
|
+
days = getDaysInMonth(year, month),
|
|
38387
|
+
before = new Date(year, month, 1).getDay(),
|
|
38388
|
+
data = [],
|
|
38389
|
+
row = [];
|
|
38390
|
+
setToStartOfDay(now);
|
|
38391
|
+
if (opts.firstDay > 0) {
|
|
38392
|
+
before -= opts.firstDay;
|
|
38393
|
+
if (before < 0) {
|
|
38394
|
+
before += 7;
|
|
38395
|
+
}
|
|
38396
|
+
}
|
|
38397
|
+
var previousMonth = month === 0 ? 11 : month - 1,
|
|
38398
|
+
nextMonth = month === 11 ? 0 : month + 1,
|
|
38399
|
+
yearOfPreviousMonth = month === 0 ? year - 1 : year,
|
|
38400
|
+
yearOfNextMonth = month === 11 ? year + 1 : year,
|
|
38401
|
+
daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth);
|
|
38402
|
+
var cells = days + before,
|
|
38403
|
+
after = cells;
|
|
38404
|
+
while (after > 7) {
|
|
38405
|
+
after -= 7;
|
|
38406
|
+
}
|
|
38407
|
+
cells += 7 - after;
|
|
38408
|
+
var isWeekSelected = false;
|
|
38409
|
+
for (var i = 0, r = 0; i < cells; i++) {
|
|
38410
|
+
var day = new Date(year, month, 1 + (i - before)),
|
|
38411
|
+
isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
|
|
38412
|
+
isToday = compareDates(day, now),
|
|
38413
|
+
hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false,
|
|
38414
|
+
isEmpty = i < before || i >= (days + before),
|
|
38415
|
+
dayNumber = 1 + (i - before),
|
|
38416
|
+
monthNumber = month,
|
|
38417
|
+
yearNumber = year,
|
|
38418
|
+
isStartRange = opts.startRange && compareDates(opts.startRange, day),
|
|
38419
|
+
isEndRange = opts.endRange && compareDates(opts.endRange, day),
|
|
38420
|
+
isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
|
|
38421
|
+
isDisabled = (opts.minDate && day < opts.minDate) ||
|
|
38422
|
+
(opts.maxDate && day > opts.maxDate) ||
|
|
38423
|
+
(opts.disableWeekends && isWeekend(day)) ||
|
|
38424
|
+
(opts.disableDayFn && opts.disableDayFn(day));
|
|
38425
|
+
|
|
38426
|
+
if (isEmpty) {
|
|
38427
|
+
if (i < before) {
|
|
38428
|
+
dayNumber = daysInPreviousMonth + dayNumber;
|
|
38429
|
+
monthNumber = previousMonth;
|
|
38430
|
+
yearNumber = yearOfPreviousMonth;
|
|
38431
|
+
} else {
|
|
38432
|
+
dayNumber = dayNumber - days;
|
|
38433
|
+
monthNumber = nextMonth;
|
|
38434
|
+
yearNumber = yearOfNextMonth;
|
|
38435
|
+
}
|
|
38436
|
+
}
|
|
38437
|
+
|
|
38438
|
+
var dayConfig = {
|
|
38439
|
+
day: dayNumber,
|
|
38440
|
+
month: monthNumber,
|
|
38441
|
+
year: yearNumber,
|
|
38442
|
+
hasEvent: hasEvent,
|
|
38443
|
+
isSelected: isSelected,
|
|
38444
|
+
isToday: isToday,
|
|
38445
|
+
isDisabled: isDisabled,
|
|
38446
|
+
isEmpty: isEmpty,
|
|
38447
|
+
isStartRange: isStartRange,
|
|
38448
|
+
isEndRange: isEndRange,
|
|
38449
|
+
isInRange: isInRange,
|
|
38450
|
+
showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths,
|
|
38451
|
+
enableSelectionDaysInNextAndPreviousMonths: opts.enableSelectionDaysInNextAndPreviousMonths
|
|
38452
|
+
};
|
|
38453
|
+
|
|
38454
|
+
if (opts.pickWholeWeek && isSelected) {
|
|
38455
|
+
isWeekSelected = true;
|
|
38456
|
+
}
|
|
38457
|
+
|
|
38458
|
+
row.push(renderDay(dayConfig));
|
|
38459
|
+
|
|
38460
|
+
if (++r === 7) {
|
|
38461
|
+
if (opts.showWeekNumber) {
|
|
38462
|
+
row.unshift(renderWeek(i - before, month, year));
|
|
38463
|
+
}
|
|
38464
|
+
data.push(renderRow(row, opts.isRTL, opts.pickWholeWeek, isWeekSelected));
|
|
38465
|
+
row = [];
|
|
38466
|
+
r = 0;
|
|
38467
|
+
isWeekSelected = false;
|
|
38468
|
+
}
|
|
38469
|
+
}
|
|
38470
|
+
return renderTable(opts, data, randId);
|
|
38471
|
+
},
|
|
38472
|
+
|
|
38473
|
+
isVisible: function () {
|
|
38474
|
+
return this._v;
|
|
38475
|
+
},
|
|
38476
|
+
|
|
38477
|
+
show: function () {
|
|
38478
|
+
if (!this.isVisible()) {
|
|
38479
|
+
this._v = true;
|
|
38480
|
+
this.draw();
|
|
38481
|
+
removeClass(this.el, 'is-hidden');
|
|
38482
|
+
if (this._o.bound) {
|
|
38483
|
+
addEvent(document, 'click', this._onClick);
|
|
38484
|
+
this.adjustPosition();
|
|
38485
|
+
}
|
|
38486
|
+
if (typeof this._o.onOpen === 'function') {
|
|
38487
|
+
this._o.onOpen.call(this);
|
|
38488
|
+
}
|
|
38489
|
+
}
|
|
38490
|
+
},
|
|
38491
|
+
|
|
38492
|
+
hide: function () {
|
|
38493
|
+
var v = this._v;
|
|
38494
|
+
if (v !== false) {
|
|
38495
|
+
if (this._o.bound) {
|
|
38496
|
+
removeEvent(document, 'click', this._onClick);
|
|
38497
|
+
}
|
|
38498
|
+
this.el.style.position = 'static'; // reset
|
|
38499
|
+
this.el.style.left = 'auto';
|
|
38500
|
+
this.el.style.top = 'auto';
|
|
38501
|
+
addClass(this.el, 'is-hidden');
|
|
38502
|
+
this._v = false;
|
|
38503
|
+
if (v !== undefined && typeof this._o.onClose === 'function') {
|
|
38504
|
+
this._o.onClose.call(this);
|
|
38505
|
+
}
|
|
38506
|
+
}
|
|
38507
|
+
},
|
|
38508
|
+
|
|
38509
|
+
/**
|
|
38510
|
+
* GAME OVER
|
|
38511
|
+
*/
|
|
38512
|
+
destroy: function () {
|
|
38513
|
+
var opts = this._o;
|
|
38514
|
+
|
|
38515
|
+
this.hide();
|
|
38516
|
+
removeEvent(this.el, 'mousedown', this._onMouseDown, true);
|
|
38517
|
+
removeEvent(this.el, 'touchend', this._onMouseDown, true);
|
|
38518
|
+
removeEvent(this.el, 'change', this._onChange);
|
|
38519
|
+
if (opts.keyboardInput) {
|
|
38520
|
+
removeEvent(document, 'keydown', this._onKeyChange);
|
|
38521
|
+
}
|
|
38522
|
+
if (opts.field) {
|
|
38523
|
+
removeEvent(opts.field, 'change', this._onInputChange);
|
|
38524
|
+
if (opts.bound) {
|
|
38525
|
+
removeEvent(opts.trigger, 'click', this._onInputClick);
|
|
38526
|
+
removeEvent(opts.trigger, 'focus', this._onInputFocus);
|
|
38527
|
+
removeEvent(opts.trigger, 'blur', this._onInputBlur);
|
|
38528
|
+
}
|
|
38529
|
+
}
|
|
38530
|
+
if (this.el.parentNode) {
|
|
38531
|
+
this.el.parentNode.removeChild(this.el);
|
|
38532
|
+
}
|
|
38533
|
+
}
|
|
38534
|
+
|
|
38535
|
+
};
|
|
38536
|
+
|
|
38537
|
+
return Pikaday;
|
|
38538
|
+
}));
|
|
38539
|
+
} (pikaday$2));
|
|
38540
|
+
return pikaday$2.exports;
|
|
38541
|
+
}
|
|
38542
|
+
|
|
38543
|
+
var pikadayExports = /*@__PURE__*/ requirePikaday();
|
|
38544
|
+
var pikaday = /*@__PURE__*/getDefaultExportFromCjs(pikadayExports);
|
|
38545
|
+
|
|
38546
|
+
var pikadayNamespace = /*#__PURE__*/_mergeNamespaces({
|
|
38547
|
+
__proto__: null,
|
|
38548
|
+
default: pikaday
|
|
38549
|
+
}, [pikadayExports]);
|
|
38550
|
+
|
|
37336
38551
|
// Ensure moment is available globally for Pikaday
|
|
37337
38552
|
if (typeof window !== 'undefined') {
|
|
37338
38553
|
window.moment = moment;
|
|
37339
38554
|
}
|
|
38555
|
+
// Get Pikaday from the module or window
|
|
38556
|
+
// The UMD wrapper will execute and either:
|
|
38557
|
+
// 1. Return the constructor via module.exports (Rollup/CommonJS)
|
|
38558
|
+
// 2. Attach it to window.Pikaday (Browser/UMD)
|
|
38559
|
+
let Pikaday$1 = null;
|
|
38560
|
+
if (typeof window !== 'undefined') {
|
|
38561
|
+
// Check window first (UMD attached it there)
|
|
38562
|
+
if (window.Pikaday) {
|
|
38563
|
+
Pikaday$1 = window.Pikaday;
|
|
38564
|
+
}
|
|
38565
|
+
// Check if imported as default (CommonJS module.exports)
|
|
38566
|
+
else if (pikaday && typeof pikaday === 'function') {
|
|
38567
|
+
Pikaday$1 = pikaday;
|
|
38568
|
+
window.Pikaday = Pikaday$1;
|
|
38569
|
+
}
|
|
38570
|
+
// Check if it's the namespace itself (rare)
|
|
38571
|
+
else if (typeof pikadayNamespace === 'function') {
|
|
38572
|
+
Pikaday$1 = pikadayNamespace;
|
|
38573
|
+
window.Pikaday = Pikaday$1;
|
|
38574
|
+
}
|
|
38575
|
+
// Try any other property that might be the constructor
|
|
38576
|
+
else if (pikadayNamespace) {
|
|
38577
|
+
const possiblePikaday = Object.values(pikadayNamespace).find(val => typeof val === 'function');
|
|
38578
|
+
if (possiblePikaday) {
|
|
38579
|
+
Pikaday$1 = possiblePikaday;
|
|
38580
|
+
window.Pikaday = Pikaday$1;
|
|
38581
|
+
}
|
|
38582
|
+
}
|
|
38583
|
+
}
|
|
37340
38584
|
// Export a function to safely create Pikaday instances
|
|
37341
38585
|
function createPikaday(options) {
|
|
37342
38586
|
if (typeof window === 'undefined') {
|
|
37343
38587
|
console.warn('Pikaday requires a browser environment');
|
|
37344
38588
|
return null;
|
|
37345
38589
|
}
|
|
37346
|
-
|
|
37347
|
-
|
|
38590
|
+
// Try multiple sources for Pikaday
|
|
38591
|
+
const PikadayConstructor = Pikaday$1 || window.Pikaday;
|
|
38592
|
+
if (!PikadayConstructor) {
|
|
37348
38593
|
console.error('Pikaday not available. Make sure pikaday.js is loaded.');
|
|
38594
|
+
console.error('Failed to create Pikaday calendar. Check moment.js availability.');
|
|
37349
38595
|
return null;
|
|
37350
38596
|
}
|
|
37351
38597
|
if (!moment || !window.moment) {
|
|
37352
38598
|
console.error('Moment.js not available. Pikaday requires moment.js.');
|
|
38599
|
+
console.error('Failed to create Pikaday calendar. Check moment.js availability.');
|
|
38600
|
+
return null;
|
|
38601
|
+
}
|
|
38602
|
+
try {
|
|
38603
|
+
return new PikadayConstructor(options);
|
|
38604
|
+
}
|
|
38605
|
+
catch (error) {
|
|
38606
|
+
console.error('Failed to create Pikaday instance:', error);
|
|
38607
|
+
console.error('Failed to create Pikaday calendar. Check moment.js availability.');
|
|
37353
38608
|
return null;
|
|
37354
38609
|
}
|
|
37355
|
-
return new Pikaday(options);
|
|
37356
38610
|
}
|
|
37357
38611
|
|
|
37358
38612
|
class DateTimePicker extends ChartComponent {
|