matrix_components 2.0.300

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.
Files changed (68) hide show
  1. package/README.md +438 -0
  2. package/dist/ComponentDemo/DialogDemo.vue +208 -0
  3. package/dist/ComponentDemo/ExcelDemo.vue +263 -0
  4. package/dist/ComponentDemo/OfficeDemo.vue +189 -0
  5. package/dist/ComponentDemo/PdfDemo.vue +207 -0
  6. package/dist/ComponentDemo/Test.vue +6 -0
  7. package/dist/ComponentDemo/VideoDemo.vue +273 -0
  8. package/dist/ComponentDemo/WordDemo.vue +191 -0
  9. package/dist/cdn/ezuikit/ezuikit.js +27 -0
  10. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl1/HasSIMD/Decoder.js +168 -0
  11. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl1/NoSIMD/Decoder.js +168 -0
  12. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/HasSIMD/Decoder.js +21 -0
  13. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/HasSIMD/Decoder.wasm +0 -0
  14. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/HasSIMD/Decoder.worker.js +1 -0
  15. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/NoSIMD/Decoder.js +21 -0
  16. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/NoSIMD/Decoder.wasm +0 -0
  17. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/hasWorker/NoSIMD/Decoder.worker.js +1 -0
  18. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/noWorker/Decoder.js +21 -0
  19. package/dist/cdn/ezuikit/ezuikit_static/PlayCtrlWasm/playCtrl3/noWorker/Decoder.wasm +0 -0
  20. package/dist/cdn/ezuikit/ezuikit_static/css/component.css +1257 -0
  21. package/dist/cdn/ezuikit/ezuikit_static/css/inspectTheme.css +354 -0
  22. package/dist/cdn/ezuikit/ezuikit_static/css/theme copy.css +126 -0
  23. package/dist/cdn/ezuikit/ezuikit_static/css/theme.css +140 -0
  24. package/dist/cdn/ezuikit/ezuikit_static/imgs/bg.png +0 -0
  25. package/dist/cdn/ezuikit/ezuikit_static/imgs/bg.svg +33 -0
  26. package/dist/cdn/ezuikit/ezuikit_static/imgs/empty.png +0 -0
  27. package/dist/cdn/ezuikit/ezuikit_static/imgs/end.png +0 -0
  28. package/dist/cdn/ezuikit/ezuikit_static/imgs/fallback.svg +52 -0
  29. package/dist/cdn/ezuikit/ezuikit_static/imgs/start.png +0 -0
  30. package/dist/cdn/ezuikit/ezuikit_static/rec/datepicker.js +1522 -0
  31. package/dist/cdn/ezuikit/ezuikit_static/rec/datepicker.min.css +36 -0
  32. package/dist/cdn/ezuikit/ezuikit_static/rec/datepicker.zh-CN.js +19 -0
  33. package/dist/cdn/ezuikit/ezuikit_static/rec/jquery.min.js +2 -0
  34. package/dist/cdn/ezuikit/ezuikit_static/speed/speed.css +145 -0
  35. package/dist/cdn/ezuikit/ezuikit_static/talk/adapeter.js +5497 -0
  36. package/dist/cdn/ezuikit/ezuikit_static/talk/janus.js +3507 -0
  37. package/dist/cdn/ezuikit/ezuikit_static/talk/tts-v4.js +343 -0
  38. package/dist/cdn/ezuikit.js +27 -0
  39. package/dist/cdn/h5player/h5player.min.js +313 -0
  40. package/dist/cdn/h5player/playctrl1/DecodeWorker.js +642 -0
  41. package/dist/cdn/h5player/playctrl1/Decoder.js +1 -0
  42. package/dist/cdn/h5player/playctrl1simd/DecodeWorker.js +642 -0
  43. package/dist/cdn/h5player/playctrl1simd/Decoder.js +1 -0
  44. package/dist/cdn/h5player/playctrl2/Decoder.js +21 -0
  45. package/dist/cdn/h5player/playctrl2/Decoder.wasm +0 -0
  46. package/dist/cdn/h5player/playctrl2/Decoder.worker.js +1 -0
  47. package/dist/cdn/h5player/playctrl3/Decoder.js +21 -0
  48. package/dist/cdn/h5player/playctrl3/Decoder.wasm +0 -0
  49. package/dist/cdn/h5player/playctrl3/Decoder.worker.js +1 -0
  50. package/dist/cdn/h5player/talk/AudioInterCom.js +21 -0
  51. package/dist/cdn/h5player/talk/AudioInterCom.wasm +0 -0
  52. package/dist/cdn/h5player/talkW/AudioInterCom.js +21 -0
  53. package/dist/cdn/h5player/talkW/AudioInterCom.wasm +0 -0
  54. package/dist/cdn/h5player/talkW/AudioInterCom.worker.js +1 -0
  55. package/dist/cdn/h5player/transform/libSystemTransform.js +6525 -0
  56. package/dist/cdn/h5player/transform/libSystemTransform.wasm +0 -0
  57. package/dist/cdn/h5player/transform/systemTransform-worker.js +120 -0
  58. package/dist/cdn/md5.js +254 -0
  59. package/dist/favicon.ico +0 -0
  60. package/dist/js/EasyPlayer-decode.js +1 -0
  61. package/dist/js/EasyPlayer-lib.js +1 -0
  62. package/dist/js/EasyPlayer-pro.js +1 -0
  63. package/dist/js/EasyPlayer-pro.wasm +0 -0
  64. package/dist/js/EasyPlayer-snap.wasm +0 -0
  65. package/dist/matrix_components.css +1 -0
  66. package/dist/matrix_components.js +60018 -0
  67. package/dist/matrix_components.umd.cjs +1 -0
  68. package/package.json +81 -0
@@ -0,0 +1,1522 @@
1
+ /*!
2
+ * Datepicker v1.0.10
3
+ * https://fengyuanchen.github.io/datepicker
4
+ *
5
+ * Copyright 2014-present Chen Fengyuan
6
+ * Released under the MIT license
7
+ *
8
+ * Date: 2020-09-29T14:46:10.983Z
9
+ */
10
+
11
+ (function (global, factory) {
12
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
13
+ typeof define === 'function' && define.amd ? define(['jquery'], factory) :
14
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jQuery));
15
+ }(this, (function ($) { 'use strict';
16
+
17
+ $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
18
+
19
+ function _classCallCheck(instance, Constructor) {
20
+ if (!(instance instanceof Constructor)) {
21
+ throw new TypeError("Cannot call a class as a function");
22
+ }
23
+ }
24
+
25
+ function _defineProperties(target, props) {
26
+ for (var i = 0; i < props.length; i++) {
27
+ var descriptor = props[i];
28
+ descriptor.enumerable = descriptor.enumerable || false;
29
+ descriptor.configurable = true;
30
+ if ("value" in descriptor) descriptor.writable = true;
31
+ Object.defineProperty(target, descriptor.key, descriptor);
32
+ }
33
+ }
34
+
35
+ function _createClass(Constructor, protoProps, staticProps) {
36
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
37
+ if (staticProps) _defineProperties(Constructor, staticProps);
38
+ return Constructor;
39
+ }
40
+
41
+ var DEFAULTS = {
42
+ // Show the datepicker automatically when initialized
43
+ autoShow: false,
44
+ // Hide the datepicker automatically when picked
45
+ autoHide: false,
46
+ // Pick the initial date automatically when initialized
47
+ autoPick: false,
48
+ // Enable inline mode
49
+ inline: false,
50
+ // A element (or selector) for putting the datepicker
51
+ container: null,
52
+ // A element (or selector) for triggering the datepicker
53
+ trigger: null,
54
+ // The ISO language code (built-in: en-US)
55
+ language: '',
56
+ // The date string format
57
+ format: 'mm/dd/yyyy',
58
+ // The initial date
59
+ date: null,
60
+ // The start view date
61
+ startDate: null,
62
+ // The end view date
63
+ endDate: null,
64
+ // The start view when initialized
65
+ startView: 0,
66
+ // 0 for days, 1 for months, 2 for years
67
+ // The start day of the week
68
+ // 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday,
69
+ // 4 for Thursday, 5 for Friday, 6 for Saturday
70
+ weekStart: 0,
71
+ // Show year before month on the datepicker header
72
+ yearFirst: false,
73
+ // A string suffix to the year number.
74
+ yearSuffix: '',
75
+ // Days' name of the week.
76
+ days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
77
+ // Shorter days' name
78
+ daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
79
+ // Shortest days' name
80
+ daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
81
+ // Months' name
82
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
83
+ // Shorter months' name
84
+ monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
85
+ // A element tag for each item of years, months and days
86
+ itemTag: 'li',
87
+ // A class (CSS) for muted date item
88
+ mutedClass: 'muted',
89
+ // A class (CSS) for picked date item
90
+ pickedClass: 'picked',
91
+ // A class (CSS) for disabled date item
92
+ disabledClass: 'disabled',
93
+ // A class (CSS) for highlight date item
94
+ highlightedClass: 'highlighted',
95
+ // The template of the datepicker
96
+ template: '<div class="datepicker-container">' + '<div class="datepicker-panel" data-view="years picker">' + '<ul>' + '<li data-view="years prev">&lsaquo;</li>' + '<li data-view="years current"></li>' + '<li data-view="years next">&rsaquo;</li>' + '</ul>' + '<ul data-view="years"></ul>' + '</div>' + '<div class="datepicker-panel" data-view="months picker">' + '<ul>' + '<li data-view="year prev">&lsaquo;</li>' + '<li data-view="year current"></li>' + '<li data-view="year next">&rsaquo;</li>' + '</ul>' + '<ul data-view="months"></ul>' + '</div>' + '<div class="datepicker-panel" data-view="days picker">' + '<ul>' + '<li data-view="month prev">&lsaquo;</li>' + '<li data-view="month current"></li>' + '<li data-view="month next">&rsaquo;</li>' + '</ul>' + '<ul data-view="week"></ul>' + '<ul data-view="days"></ul>' + '</div>' + '</div>',
97
+ // The offset top or bottom of the datepicker from the element
98
+ offset: 10,
99
+ // The `z-index` of the datepicker
100
+ zIndex: 1000,
101
+ // Filter each date item (return `false` to disable a date item)
102
+ filter: null,
103
+ // Event shortcuts
104
+ show: null,
105
+ hide: null,
106
+ pick: null
107
+ };
108
+
109
+ var IS_BROWSER = typeof window !== 'undefined';
110
+ var WINDOW = IS_BROWSER ? window : {};
111
+ var IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
112
+ var NAMESPACE = 'datepicker';
113
+ var EVENT_CLICK = "click.".concat(NAMESPACE);
114
+ var EVENT_FOCUS = "focus.".concat(NAMESPACE);
115
+ var EVENT_HIDE = "hide.".concat(NAMESPACE);
116
+ var EVENT_KEYUP = "keyup.".concat(NAMESPACE);
117
+ var EVENT_PICK = "pick.".concat(NAMESPACE);
118
+ var EVENT_RESIZE = "resize.".concat(NAMESPACE);
119
+ var EVENT_SCROLL = "scroll.".concat(NAMESPACE);
120
+ var EVENT_SHOW = "show.".concat(NAMESPACE);
121
+ var EVENT_TOUCH_START = "touchstart.".concat(NAMESPACE);
122
+ var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
123
+ var LANGUAGES = {};
124
+ var VIEWS = {
125
+ DAYS: 0,
126
+ MONTHS: 1,
127
+ YEARS: 2
128
+ };
129
+
130
+ var toString = Object.prototype.toString;
131
+ function typeOf(obj) {
132
+ return toString.call(obj).slice(8, -1).toLowerCase();
133
+ }
134
+ function isString(value) {
135
+ return typeof value === 'string';
136
+ }
137
+ var isNaN = Number.isNaN || WINDOW.isNaN;
138
+ function isNumber(value) {
139
+ return typeof value === 'number' && !isNaN(value);
140
+ }
141
+ function isUndefined(value) {
142
+ return typeof value === 'undefined';
143
+ }
144
+ function isDate(value) {
145
+ return typeOf(value) === 'date' && !isNaN(value.getTime());
146
+ }
147
+ function proxy(fn, context) {
148
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
149
+ args[_key - 2] = arguments[_key];
150
+ }
151
+
152
+ return function () {
153
+ for (var _len2 = arguments.length, args2 = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
154
+ args2[_key2] = arguments[_key2];
155
+ }
156
+
157
+ return fn.apply(context, args.concat(args2));
158
+ };
159
+ }
160
+ function selectorOf(view) {
161
+ return "[data-view=\"".concat(view, "\"]");
162
+ }
163
+ function isLeapYear(year) {
164
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
165
+ }
166
+ function getDaysInMonth(year, month) {
167
+ return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
168
+ }
169
+ function getMinDay(year, month, day) {
170
+ return Math.min(day, getDaysInMonth(year, month));
171
+ }
172
+ var formatParts = /(y|m|d)+/g;
173
+ function parseFormat(format) {
174
+ var source = String(format).toLowerCase();
175
+ var parts = source.match(formatParts);
176
+
177
+ if (!parts || parts.length === 0) {
178
+ throw new Error('Invalid date format.');
179
+ }
180
+
181
+ format = {
182
+ source: source,
183
+ parts: parts
184
+ };
185
+ $.each(parts, function (i, part) {
186
+ switch (part) {
187
+ case 'dd':
188
+ case 'd':
189
+ format.hasDay = true;
190
+ break;
191
+
192
+ case 'mm':
193
+ case 'm':
194
+ format.hasMonth = true;
195
+ break;
196
+
197
+ case 'yyyy':
198
+ case 'yy':
199
+ format.hasYear = true;
200
+ break;
201
+ }
202
+ });
203
+ return format;
204
+ }
205
+ function getScrollParent(element) {
206
+ var includeHidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
207
+ var $element = $(element);
208
+ var position = $element.css('position');
209
+ var excludeStaticParent = position === 'absolute';
210
+ var overflowRegex = includeHidden ? /auto|scroll|hidden/ : /auto|scroll/;
211
+ var scrollParent = $element.parents().filter(function (index, parent) {
212
+ var $parent = $(parent);
213
+
214
+ if (excludeStaticParent && $parent.css('position') === 'static') {
215
+ return false;
216
+ }
217
+
218
+ return overflowRegex.test($parent.css('overflow') + $parent.css('overflow-y') + $parent.css('overflow-x'));
219
+ }).eq(0);
220
+ return position === 'fixed' || !scrollParent.length ? $(element.ownerDocument || document) : scrollParent;
221
+ }
222
+ /**
223
+ * Add leading zeroes to the given value
224
+ * @param {number} value - The value to add.
225
+ * @param {number} [length=1] - The expected value length.
226
+ * @returns {string} Returns converted value.
227
+ */
228
+
229
+ function addLeadingZero(value) {
230
+ var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
231
+ var str = String(Math.abs(value));
232
+ var i = str.length;
233
+ var result = '';
234
+
235
+ if (value < 0) {
236
+ result += '-';
237
+ }
238
+
239
+ while (i < length) {
240
+ i += 1;
241
+ result += '0';
242
+ }
243
+
244
+ return result + str;
245
+ }
246
+
247
+ var REGEXP_DIGITS = /\d+/g;
248
+ var methods = {
249
+ // Show the datepicker
250
+ show: function show() {
251
+ if (!this.built) {
252
+ this.build();
253
+ }
254
+
255
+ if (this.shown) {
256
+ return;
257
+ }
258
+
259
+ if (this.trigger(EVENT_SHOW).isDefaultPrevented()) {
260
+ return;
261
+ }
262
+
263
+ this.shown = true;
264
+ this.$picker.removeClass(CLASS_HIDE).on(EVENT_CLICK, $.proxy(this.click, this));
265
+ this.showView(this.options.startView);
266
+
267
+ if (!this.inline) {
268
+ this.$scrollParent.on(EVENT_SCROLL, $.proxy(this.place, this));
269
+ $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this));
270
+ $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this));
271
+ $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this));
272
+
273
+ if (IS_TOUCH_DEVICE) {
274
+ $(document).on(EVENT_TOUCH_START, this.onTouchStart = proxy(this.touchstart, this));
275
+ }
276
+
277
+ this.place();
278
+ }
279
+ },
280
+ // Hide the datepicker
281
+ hide: function hide() {
282
+ if (!this.shown) {
283
+ return;
284
+ }
285
+
286
+ if (this.trigger(EVENT_HIDE).isDefaultPrevented()) {
287
+ return;
288
+ }
289
+
290
+ this.shown = false;
291
+ this.$picker.addClass(CLASS_HIDE).off(EVENT_CLICK, this.click);
292
+
293
+ if (!this.inline) {
294
+ this.$scrollParent.off(EVENT_SCROLL, this.place);
295
+ $(window).off(EVENT_RESIZE, this.onResize);
296
+ $(document).off(EVENT_CLICK, this.onGlobalClick);
297
+ $(document).off(EVENT_KEYUP, this.onGlobalKeyup);
298
+
299
+ if (IS_TOUCH_DEVICE) {
300
+ $(document).off(EVENT_TOUCH_START, this.onTouchStart);
301
+ }
302
+ }
303
+ },
304
+ toggle: function toggle() {
305
+ if (this.shown) {
306
+ this.hide();
307
+ } else {
308
+ this.show();
309
+ }
310
+ },
311
+ // Update the datepicker with the current input value
312
+ update: function update() {
313
+ var value = this.getValue();
314
+
315
+ if (value === this.oldValue) {
316
+ return;
317
+ }
318
+
319
+ this.setDate(value, true);
320
+ this.oldValue = value;
321
+ },
322
+
323
+ /**
324
+ * Pick the current date to the element
325
+ *
326
+ * @param {String} _view (private)
327
+ */
328
+ pick: function pick(_view) {
329
+ var $this = this.$element;
330
+ var date = this.date;
331
+
332
+ if (this.trigger(EVENT_PICK, {
333
+ view: _view || '',
334
+ date: date
335
+ }).isDefaultPrevented()) {
336
+ return;
337
+ }
338
+
339
+ date = this.formatDate(this.date);
340
+ this.setValue(date);
341
+
342
+ if (this.isInput) {
343
+ $this.trigger('input');
344
+ $this.trigger('change');
345
+ }
346
+ },
347
+ // Reset the datepicker
348
+ reset: function reset() {
349
+ this.setDate(this.initialDate, true);
350
+ this.setValue(this.initialValue);
351
+
352
+ if (this.shown) {
353
+ this.showView(this.options.startView);
354
+ }
355
+ },
356
+
357
+ /**
358
+ * Get the month name with given argument or the current date
359
+ *
360
+ * @param {Number} month (optional)
361
+ * @param {Boolean} shortForm (optional)
362
+ * @return {String} (month name)
363
+ */
364
+ getMonthName: function getMonthName(month, shortForm) {
365
+ var options = this.options;
366
+ var monthsShort = options.monthsShort;
367
+ var months = options.months;
368
+
369
+ if ($.isNumeric(month)) {
370
+ month = Number(month);
371
+ } else if (isUndefined(shortForm)) {
372
+ shortForm = month;
373
+ }
374
+
375
+ if (shortForm === true) {
376
+ months = monthsShort;
377
+ }
378
+
379
+ return months[isNumber(month) ? month : this.date.getMonth()];
380
+ },
381
+
382
+ /**
383
+ * Get the day name with given argument or the current date
384
+ *
385
+ * @param {Number} day (optional)
386
+ * @param {Boolean} shortForm (optional)
387
+ * @param {Boolean} min (optional)
388
+ * @return {String} (day name)
389
+ */
390
+ getDayName: function getDayName(day, shortForm, min) {
391
+ var options = this.options;
392
+ var days = options.days;
393
+
394
+ if ($.isNumeric(day)) {
395
+ day = Number(day);
396
+ } else {
397
+ if (isUndefined(min)) {
398
+ min = shortForm;
399
+ }
400
+
401
+ if (isUndefined(shortForm)) {
402
+ shortForm = day;
403
+ }
404
+ }
405
+
406
+ if (min) {
407
+ days = options.daysMin;
408
+ } else if (shortForm) {
409
+ days = options.daysShort;
410
+ }
411
+
412
+ return days[isNumber(day) ? day : this.date.getDay()];
413
+ },
414
+
415
+ /**
416
+ * Get the current date
417
+ *
418
+ * @param {Boolean} formatted (optional)
419
+ * @return {Date|String} (date)
420
+ */
421
+ getDate: function getDate(formatted) {
422
+ var date = this.date;
423
+ return formatted ? this.formatDate(date) : new Date(date);
424
+ },
425
+
426
+ /**
427
+ * Set the current date with a new date
428
+ *
429
+ * @param {Date} date
430
+ * @param {Boolean} _updated (private)
431
+ */
432
+ setDate: function setDate(date, _updated) {
433
+ var filter = this.options.filter;
434
+
435
+ if (isDate(date) || isString(date)) {
436
+ date = this.parseDate(date);
437
+
438
+ if ($.isFunction(filter) && filter.call(this.$element, date, 'day') === false) {
439
+ return;
440
+ }
441
+
442
+ this.date = date;
443
+ this.viewDate = new Date(date);
444
+
445
+ if (!_updated) {
446
+ this.pick();
447
+ }
448
+
449
+ if (this.built) {
450
+ this.render();
451
+ }
452
+ }
453
+ },
454
+
455
+ /**
456
+ * Set the start view date with a new date
457
+ *
458
+ * @param {Date|string|null} date
459
+ */
460
+ setStartDate: function setStartDate(date) {
461
+ if (isDate(date) || isString(date)) {
462
+ this.startDate = this.parseDate(date);
463
+ } else {
464
+ this.startDate = null;
465
+ }
466
+
467
+ if (this.built) {
468
+ this.render();
469
+ }
470
+ },
471
+
472
+ /**
473
+ * Set the end view date with a new date
474
+ *
475
+ * @param {Date|string|null} date
476
+ */
477
+ setEndDate: function setEndDate(date) {
478
+ if (isDate(date) || isString(date)) {
479
+ this.endDate = this.parseDate(date);
480
+ } else {
481
+ this.endDate = null;
482
+ }
483
+
484
+ if (this.built) {
485
+ this.render();
486
+ }
487
+ },
488
+
489
+ /**
490
+ * Parse a date string with the set date format
491
+ *
492
+ * @param {String} date
493
+ * @return {Date} (parsed date)
494
+ */
495
+ parseDate: function parseDate(date) {
496
+ var format = this.format;
497
+ var parts = [];
498
+
499
+ if (!isDate(date)) {
500
+ if (isString(date)) {
501
+ parts = date.match(REGEXP_DIGITS) || [];
502
+ }
503
+
504
+ date = date ? new Date(date) : new Date();
505
+
506
+ if (!isDate(date)) {
507
+ date = new Date();
508
+ }
509
+
510
+ if (parts.length === format.parts.length) {
511
+ // Set year and month first
512
+ $.each(parts, function (i, part) {
513
+ var value = parseInt(part, 10);
514
+
515
+ switch (format.parts[i]) {
516
+ case 'yy':
517
+ date.setFullYear(2000 + value);
518
+ break;
519
+
520
+ case 'yyyy':
521
+ // Converts 2-digit year to 2000+
522
+ date.setFullYear(part.length === 2 ? 2000 + value : value);
523
+ break;
524
+
525
+ case 'mm':
526
+ case 'm':
527
+ date.setMonth(value - 1);
528
+ break;
529
+ }
530
+ }); // Set day in the last to avoid converting `31/10/2019` to `01/10/2019`
531
+
532
+ $.each(parts, function (i, part) {
533
+ var value = parseInt(part, 10);
534
+
535
+ switch (format.parts[i]) {
536
+ case 'dd':
537
+ case 'd':
538
+ date.setDate(value);
539
+ break;
540
+ }
541
+ });
542
+ }
543
+ } // Ignore hours, minutes, seconds and milliseconds to avoid side effect (#192)
544
+
545
+
546
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
547
+ },
548
+
549
+ /**
550
+ * Format a date object to a string with the set date format
551
+ *
552
+ * @param {Date} date
553
+ * @return {String} (formatted date)
554
+ */
555
+ formatDate: function formatDate(date) {
556
+ var format = this.format;
557
+ var formatted = '';
558
+
559
+ if (isDate(date)) {
560
+ var year = date.getFullYear();
561
+ var month = date.getMonth();
562
+ var day = date.getDate();
563
+ var values = {
564
+ d: day,
565
+ dd: addLeadingZero(day, 2),
566
+ m: month + 1,
567
+ mm: addLeadingZero(month + 1, 2),
568
+ yy: String(year).substring(2),
569
+ yyyy: addLeadingZero(year, 4)
570
+ };
571
+ formatted = format.source;
572
+ $.each(format.parts, function (i, part) {
573
+ formatted = formatted.replace(part, values[part]);
574
+ });
575
+ }
576
+
577
+ return formatted;
578
+ },
579
+ // Destroy the datepicker and remove the instance from the target element
580
+ destroy: function destroy() {
581
+ this.unbind();
582
+ this.unbuild();
583
+ this.$element.removeData(NAMESPACE);
584
+ }
585
+ };
586
+
587
+ var handlers = {
588
+ click: function click(e) {
589
+ var $target = $(e.target);
590
+ var options = this.options,
591
+ date = this.date,
592
+ viewDate = this.viewDate,
593
+ format = this.format;
594
+ e.stopPropagation();
595
+ e.preventDefault();
596
+
597
+ if ($target.hasClass('disabled')) {
598
+ return;
599
+ }
600
+
601
+ var view = $target.data('view');
602
+ var viewYear = viewDate.getFullYear();
603
+ var viewMonth = viewDate.getMonth();
604
+ var viewDay = viewDate.getDate();
605
+
606
+ switch (view) {
607
+ case 'years prev':
608
+ case 'years next':
609
+ {
610
+ viewYear = view === 'years prev' ? viewYear - 10 : viewYear + 10;
611
+ viewDate.setFullYear(viewYear);
612
+ viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
613
+ this.renderYears();
614
+ break;
615
+ }
616
+
617
+ case 'year prev':
618
+ case 'year next':
619
+ viewYear = view === 'year prev' ? viewYear - 1 : viewYear + 1;
620
+ viewDate.setFullYear(viewYear);
621
+ viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
622
+ this.renderMonths();
623
+ break;
624
+
625
+ case 'year current':
626
+ if (format.hasYear) {
627
+ this.showView(VIEWS.YEARS);
628
+ }
629
+
630
+ break;
631
+
632
+ case 'year picked':
633
+ if (format.hasMonth) {
634
+ this.showView(VIEWS.MONTHS);
635
+ } else {
636
+ $target.siblings(".".concat(options.pickedClass)).removeClass(options.pickedClass).data('view', 'year');
637
+ this.hideView();
638
+ }
639
+
640
+ this.pick('year');
641
+ break;
642
+
643
+ case 'year':
644
+ viewYear = parseInt($target.text(), 10); // Set date first to avoid month changing (#195)
645
+
646
+ date.setDate(getMinDay(viewYear, viewMonth, viewDay));
647
+ date.setFullYear(viewYear);
648
+ viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
649
+ viewDate.setFullYear(viewYear);
650
+
651
+ if (format.hasMonth) {
652
+ this.showView(VIEWS.MONTHS);
653
+ } else {
654
+ $target.addClass(options.pickedClass).data('view', 'year picked').siblings(".".concat(options.pickedClass)).removeClass(options.pickedClass).data('view', 'year');
655
+ this.hideView();
656
+ }
657
+
658
+ this.pick('year');
659
+ break;
660
+
661
+ case 'month prev':
662
+ case 'month next':
663
+ viewMonth = view === 'month prev' ? viewMonth - 1 : viewMonth + 1;
664
+
665
+ if (viewMonth < 0) {
666
+ viewYear -= 1;
667
+ viewMonth += 12;
668
+ } else if (viewMonth > 11) {
669
+ viewYear += 1;
670
+ viewMonth -= 12;
671
+ }
672
+
673
+ viewDate.setFullYear(viewYear);
674
+ viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
675
+ viewDate.setMonth(viewMonth);
676
+ this.renderDays();
677
+ break;
678
+
679
+ case 'month current':
680
+ if (format.hasMonth) {
681
+ this.showView(VIEWS.MONTHS);
682
+ }
683
+
684
+ break;
685
+
686
+ case 'month picked':
687
+ if (format.hasDay) {
688
+ this.showView(VIEWS.DAYS);
689
+ } else {
690
+ $target.siblings(".".concat(options.pickedClass)).removeClass(options.pickedClass).data('view', 'month');
691
+ this.hideView();
692
+ }
693
+
694
+ this.pick('month');
695
+ break;
696
+
697
+ case 'month':
698
+ viewMonth = $.inArray($target.text(), options.monthsShort);
699
+ date.setFullYear(viewYear); // Set date before month to avoid month changing (#195)
700
+
701
+ date.setDate(getMinDay(viewYear, viewMonth, viewDay));
702
+ date.setMonth(viewMonth);
703
+ viewDate.setFullYear(viewYear);
704
+ viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
705
+ viewDate.setMonth(viewMonth);
706
+
707
+ if (format.hasDay) {
708
+ this.showView(VIEWS.DAYS);
709
+ } else {
710
+ $target.addClass(options.pickedClass).data('view', 'month picked').siblings(".".concat(options.pickedClass)).removeClass(options.pickedClass).data('view', 'month');
711
+ this.hideView();
712
+ }
713
+
714
+ this.pick('month');
715
+ break;
716
+
717
+ case 'day prev':
718
+ case 'day next':
719
+ case 'day':
720
+ if (view === 'day prev') {
721
+ viewMonth -= 1;
722
+ } else if (view === 'day next') {
723
+ viewMonth += 1;
724
+ }
725
+
726
+ viewDay = parseInt($target.text(), 10); // Set date to 1 to avoid month changing (#195)
727
+
728
+ date.setDate(1);
729
+ date.setFullYear(viewYear);
730
+ date.setMonth(viewMonth);
731
+ date.setDate(viewDay);
732
+ viewDate.setDate(1);
733
+ viewDate.setFullYear(viewYear);
734
+ viewDate.setMonth(viewMonth);
735
+ viewDate.setDate(viewDay);
736
+ this.renderDays();
737
+
738
+ if (view === 'day') {
739
+ this.hideView();
740
+ }
741
+
742
+ this.pick('day');
743
+ break;
744
+
745
+ case 'day picked':
746
+ this.hideView();
747
+ this.pick('day');
748
+ break;
749
+ }
750
+ },
751
+ globalClick: function globalClick(_ref) {
752
+ var target = _ref.target;
753
+ var element = this.element,
754
+ $trigger = this.$trigger;
755
+ var trigger = $trigger[0];
756
+ var hidden = true;
757
+
758
+ while (target !== document) {
759
+ if (target === trigger || target === element) {
760
+ hidden = false;
761
+ break;
762
+ }
763
+
764
+ target = target.parentNode;
765
+ }
766
+
767
+ if (hidden) {
768
+ this.hide();
769
+ }
770
+ },
771
+ keyup: function keyup() {
772
+ this.update();
773
+ },
774
+ globalKeyup: function globalKeyup(_ref2) {
775
+ var target = _ref2.target,
776
+ key = _ref2.key,
777
+ keyCode = _ref2.keyCode;
778
+
779
+ if (this.isInput && target !== this.element && this.shown && (key === 'Tab' || keyCode === 9)) {
780
+ this.hide();
781
+ }
782
+ },
783
+ touchstart: function touchstart(_ref3) {
784
+ var target = _ref3.target;
785
+
786
+ // Emulate click in touch devices to support hiding the picker automatically (#197).
787
+ if (this.isInput && target !== this.element && !$.contains(this.$picker[0], target)) {
788
+ this.hide();
789
+ this.element.blur();
790
+ }
791
+ }
792
+ };
793
+
794
+ var render = {
795
+ render: function render() {
796
+ this.renderYears();
797
+ this.renderMonths();
798
+ this.renderDays();
799
+ },
800
+ renderWeek: function renderWeek() {
801
+ var _this = this;
802
+
803
+ var items = [];
804
+ var _this$options = this.options,
805
+ weekStart = _this$options.weekStart,
806
+ daysMin = _this$options.daysMin;
807
+ weekStart = parseInt(weekStart, 10) % 7;
808
+ daysMin = daysMin.slice(weekStart).concat(daysMin.slice(0, weekStart));
809
+ $.each(daysMin, function (i, day) {
810
+ items.push(_this.createItem({
811
+ text: day
812
+ }));
813
+ });
814
+ this.$week.html(items.join(''));
815
+ },
816
+ renderYears: function renderYears() {
817
+ var options = this.options,
818
+ startDate = this.startDate,
819
+ endDate = this.endDate;
820
+ var disabledClass = options.disabledClass,
821
+ filter = options.filter,
822
+ yearSuffix = options.yearSuffix;
823
+ var viewYear = this.viewDate.getFullYear();
824
+ var now = new Date();
825
+ var thisYear = now.getFullYear();
826
+ var year = this.date.getFullYear();
827
+ var start = -5;
828
+ var end = 6;
829
+ var items = [];
830
+ var prevDisabled = false;
831
+ var nextDisabled = false;
832
+ var i;
833
+
834
+ for (i = start; i <= end; i += 1) {
835
+ var date = new Date(viewYear + i, 1, 1);
836
+ var disabled = false;
837
+
838
+ if (startDate) {
839
+ disabled = date.getFullYear() < startDate.getFullYear();
840
+
841
+ if (i === start) {
842
+ prevDisabled = disabled;
843
+ }
844
+ }
845
+
846
+ if (!disabled && endDate) {
847
+ disabled = date.getFullYear() > endDate.getFullYear();
848
+
849
+ if (i === end) {
850
+ nextDisabled = disabled;
851
+ }
852
+ }
853
+
854
+ if (!disabled && filter) {
855
+ disabled = filter.call(this.$element, date, 'year') === false;
856
+ }
857
+
858
+ var picked = viewYear + i === year;
859
+ var view = picked ? 'year picked' : 'year';
860
+ items.push(this.createItem({
861
+ picked: picked,
862
+ disabled: disabled,
863
+ text: viewYear + i,
864
+ view: disabled ? 'year disabled' : view,
865
+ highlighted: date.getFullYear() === thisYear
866
+ }));
867
+ }
868
+
869
+ this.$yearsPrev.toggleClass(disabledClass, prevDisabled);
870
+ this.$yearsNext.toggleClass(disabledClass, nextDisabled);
871
+ this.$yearsCurrent.toggleClass(disabledClass, true).html("".concat(viewYear + start + yearSuffix, " - ").concat(viewYear + end).concat(yearSuffix));
872
+ this.$years.html(items.join(''));
873
+ },
874
+ renderMonths: function renderMonths() {
875
+ var options = this.options,
876
+ startDate = this.startDate,
877
+ endDate = this.endDate,
878
+ viewDate = this.viewDate;
879
+ var disabledClass = options.disabledClass || '';
880
+ var months = options.monthsShort;
881
+ var filter = $.isFunction(options.filter) && options.filter;
882
+ var viewYear = viewDate.getFullYear();
883
+ var now = new Date();
884
+ var thisYear = now.getFullYear();
885
+ var thisMonth = now.getMonth();
886
+ var year = this.date.getFullYear();
887
+ var month = this.date.getMonth();
888
+ var items = [];
889
+ var prevDisabled = false;
890
+ var nextDisabled = false;
891
+ var i;
892
+
893
+ for (i = 0; i <= 11; i += 1) {
894
+ var date = new Date(viewYear, i, 1);
895
+ var disabled = false;
896
+
897
+ if (startDate) {
898
+ prevDisabled = date.getFullYear() === startDate.getFullYear();
899
+ disabled = prevDisabled && date.getMonth() < startDate.getMonth();
900
+ }
901
+
902
+ if (!disabled && endDate) {
903
+ nextDisabled = date.getFullYear() === endDate.getFullYear();
904
+ disabled = nextDisabled && date.getMonth() > endDate.getMonth();
905
+ }
906
+
907
+ if (!disabled && filter) {
908
+ disabled = filter.call(this.$element, date, 'month') === false;
909
+ }
910
+
911
+ var picked = viewYear === year && i === month;
912
+ var view = picked ? 'month picked' : 'month';
913
+ items.push(this.createItem({
914
+ disabled: disabled,
915
+ picked: picked,
916
+ highlighted: viewYear === thisYear && date.getMonth() === thisMonth,
917
+ index: i,
918
+ text: months[i],
919
+ view: disabled ? 'month disabled' : view
920
+ }));
921
+ }
922
+
923
+ this.$yearPrev.toggleClass(disabledClass, prevDisabled);
924
+ this.$yearNext.toggleClass(disabledClass, nextDisabled);
925
+ this.$yearCurrent.toggleClass(disabledClass, prevDisabled && nextDisabled).html(viewYear + options.yearSuffix || '');
926
+ this.$months.html(items.join(''));
927
+ },
928
+ renderDays: function renderDays() {
929
+ var $element = this.$element,
930
+ options = this.options,
931
+ startDate = this.startDate,
932
+ endDate = this.endDate,
933
+ viewDate = this.viewDate,
934
+ currentDate = this.date;
935
+ var disabledClass = options.disabledClass,
936
+ filter = options.filter,
937
+ months = options.months,
938
+ weekStart = options.weekStart,
939
+ yearSuffix = options.yearSuffix;
940
+ var viewYear = viewDate.getFullYear();
941
+ var viewMonth = viewDate.getMonth();
942
+ var now = new Date();
943
+ var thisYear = now.getFullYear();
944
+ var thisMonth = now.getMonth();
945
+ var thisDay = now.getDate();
946
+ var year = currentDate.getFullYear();
947
+ var month = currentDate.getMonth();
948
+ var day = currentDate.getDate();
949
+ var length;
950
+ var i;
951
+ var n; // Days of prev month
952
+ // -----------------------------------------------------------------------
953
+
954
+ var prevItems = [];
955
+ var prevViewYear = viewYear;
956
+ var prevViewMonth = viewMonth;
957
+ var prevDisabled = false;
958
+
959
+ if (viewMonth === 0) {
960
+ prevViewYear -= 1;
961
+ prevViewMonth = 11;
962
+ } else {
963
+ prevViewMonth -= 1;
964
+ } // The length of the days of prev month
965
+
966
+
967
+ length = getDaysInMonth(prevViewYear, prevViewMonth); // The first day of current month
968
+
969
+ var firstDay = new Date(viewYear, viewMonth, 1); // The visible length of the days of prev month
970
+ // [0,1,2,3,4,5,6] - [0,1,2,3,4,5,6] => [-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6]
971
+
972
+ n = firstDay.getDay() - parseInt(weekStart, 10) % 7; // [-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6] => [1,2,3,4,5,6,7]
973
+
974
+ if (n <= 0) {
975
+ n += 7;
976
+ }
977
+
978
+ if (startDate) {
979
+ prevDisabled = firstDay.getTime() <= startDate.getTime();
980
+ }
981
+
982
+ for (i = length - (n - 1); i <= length; i += 1) {
983
+ var prevViewDate = new Date(prevViewYear, prevViewMonth, i);
984
+ var disabled = false;
985
+
986
+ if (startDate) {
987
+ disabled = prevViewDate.getTime() < startDate.getTime();
988
+ }
989
+
990
+ if (!disabled && filter) {
991
+ disabled = filter.call($element, prevViewDate, 'day') === false;
992
+ }
993
+
994
+ prevItems.push(this.createItem({
995
+ disabled: disabled,
996
+ highlighted: prevViewYear === thisYear && prevViewMonth === thisMonth && prevViewDate.getDate() === thisDay,
997
+ muted: true,
998
+ picked: prevViewYear === year && prevViewMonth === month && i === day,
999
+ text: i,
1000
+ view: 'day prev'
1001
+ }));
1002
+ } // Days of next month
1003
+ // -----------------------------------------------------------------------
1004
+
1005
+
1006
+ var nextItems = [];
1007
+ var nextViewYear = viewYear;
1008
+ var nextViewMonth = viewMonth;
1009
+ var nextDisabled = false;
1010
+
1011
+ if (viewMonth === 11) {
1012
+ nextViewYear += 1;
1013
+ nextViewMonth = 0;
1014
+ } else {
1015
+ nextViewMonth += 1;
1016
+ } // The length of the days of current month
1017
+
1018
+
1019
+ length = getDaysInMonth(viewYear, viewMonth); // The visible length of next month (42 means 6 rows and 7 columns)
1020
+
1021
+ n = 42 - (prevItems.length + length); // The last day of current month
1022
+
1023
+ var lastDate = new Date(viewYear, viewMonth, length);
1024
+
1025
+ if (endDate) {
1026
+ nextDisabled = lastDate.getTime() >= endDate.getTime();
1027
+ }
1028
+
1029
+ for (i = 1; i <= n; i += 1) {
1030
+ var date = new Date(nextViewYear, nextViewMonth, i);
1031
+ var picked = nextViewYear === year && nextViewMonth === month && i === day;
1032
+ var _disabled = false;
1033
+
1034
+ if (endDate) {
1035
+ _disabled = date.getTime() > endDate.getTime();
1036
+ }
1037
+
1038
+ if (!_disabled && filter) {
1039
+ _disabled = filter.call($element, date, 'day') === false;
1040
+ }
1041
+
1042
+ nextItems.push(this.createItem({
1043
+ disabled: _disabled,
1044
+ picked: picked,
1045
+ highlighted: nextViewYear === thisYear && nextViewMonth === thisMonth && date.getDate() === thisDay,
1046
+ muted: true,
1047
+ text: i,
1048
+ view: 'day next'
1049
+ }));
1050
+ } // Days of current month
1051
+ // -----------------------------------------------------------------------
1052
+
1053
+
1054
+ var items = [];
1055
+
1056
+ for (i = 1; i <= length; i += 1) {
1057
+ var _date = new Date(viewYear, viewMonth, i);
1058
+
1059
+ var _disabled2 = false;
1060
+
1061
+ if (startDate) {
1062
+ _disabled2 = _date.getTime() < startDate.getTime();
1063
+ }
1064
+
1065
+ if (!_disabled2 && endDate) {
1066
+ _disabled2 = _date.getTime() > endDate.getTime();
1067
+ }
1068
+
1069
+ if (!_disabled2 && filter) {
1070
+ _disabled2 = filter.call($element, _date, 'day') === false;
1071
+ }
1072
+
1073
+ var _picked = viewYear === year && viewMonth === month && i === day;
1074
+
1075
+ var view = _picked ? 'day picked' : 'day';
1076
+ items.push(this.createItem({
1077
+ disabled: _disabled2,
1078
+ picked: _picked,
1079
+ highlighted: viewYear === thisYear && viewMonth === thisMonth && _date.getDate() === thisDay,
1080
+ text: i,
1081
+ view: _disabled2 ? 'day disabled' : view
1082
+ }));
1083
+ } // Render days picker
1084
+ // -----------------------------------------------------------------------
1085
+
1086
+
1087
+ this.$monthPrev.toggleClass(disabledClass, prevDisabled);
1088
+ this.$monthNext.toggleClass(disabledClass, nextDisabled);
1089
+ this.$monthCurrent.toggleClass(disabledClass, prevDisabled && nextDisabled).html(options.yearFirst ? "".concat(viewYear + yearSuffix, " ").concat(months[viewMonth]) : "".concat(months[viewMonth], " ").concat(viewYear).concat(yearSuffix));
1090
+ this.$days.html(prevItems.join('') + items.join('') + nextItems.join(''));
1091
+ }
1092
+ };
1093
+
1094
+ var CLASS_TOP_LEFT = "".concat(NAMESPACE, "-top-left");
1095
+ var CLASS_TOP_RIGHT = "".concat(NAMESPACE, "-top-right");
1096
+ var CLASS_BOTTOM_LEFT = "".concat(NAMESPACE, "-bottom-left");
1097
+ var CLASS_BOTTOM_RIGHT = "".concat(NAMESPACE, "-bottom-right");
1098
+ var CLASS_PLACEMENTS = [CLASS_TOP_LEFT, CLASS_TOP_RIGHT, CLASS_BOTTOM_LEFT, CLASS_BOTTOM_RIGHT].join(' ');
1099
+
1100
+ var Datepicker = /*#__PURE__*/function () {
1101
+ function Datepicker(element) {
1102
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1103
+
1104
+ _classCallCheck(this, Datepicker);
1105
+
1106
+ this.$element = $(element);
1107
+ this.element = element;
1108
+ this.options = $.extend({}, DEFAULTS, LANGUAGES[options.language], $.isPlainObject(options) && options);
1109
+ this.$scrollParent = getScrollParent(element, true);
1110
+ this.built = false;
1111
+ this.shown = false;
1112
+ this.isInput = false;
1113
+ this.inline = false;
1114
+ this.initialValue = '';
1115
+ this.initialDate = null;
1116
+ this.startDate = null;
1117
+ this.endDate = null;
1118
+ this.init();
1119
+ }
1120
+
1121
+ _createClass(Datepicker, [{
1122
+ key: "init",
1123
+ value: function init() {
1124
+ var $this = this.$element,
1125
+ options = this.options;
1126
+ var startDate = options.startDate,
1127
+ endDate = options.endDate,
1128
+ date = options.date;
1129
+ this.$trigger = $(options.trigger);
1130
+ this.isInput = $this.is('input') || $this.is('textarea');
1131
+ this.inline = options.inline && (options.container || !this.isInput);
1132
+ this.format = parseFormat(options.format);
1133
+ var initialValue = this.getValue();
1134
+ this.initialValue = initialValue;
1135
+ this.oldValue = initialValue;
1136
+ date = this.parseDate(date || initialValue);
1137
+
1138
+ if (startDate) {
1139
+ startDate = this.parseDate(startDate);
1140
+
1141
+ if (date.getTime() < startDate.getTime()) {
1142
+ date = new Date(startDate);
1143
+ }
1144
+
1145
+ this.startDate = startDate;
1146
+ }
1147
+
1148
+ if (endDate) {
1149
+ endDate = this.parseDate(endDate);
1150
+
1151
+ if (startDate && endDate.getTime() < startDate.getTime()) {
1152
+ endDate = new Date(startDate);
1153
+ }
1154
+
1155
+ if (date.getTime() > endDate.getTime()) {
1156
+ date = new Date(endDate);
1157
+ }
1158
+
1159
+ this.endDate = endDate;
1160
+ }
1161
+
1162
+ this.date = date;
1163
+ this.viewDate = new Date(date);
1164
+ this.initialDate = new Date(this.date);
1165
+ this.bind();
1166
+
1167
+ if (options.autoShow || this.inline) {
1168
+ this.show();
1169
+ }
1170
+
1171
+ if (options.autoPick) {
1172
+ this.pick();
1173
+ }
1174
+ }
1175
+ }, {
1176
+ key: "build",
1177
+ value: function build() {
1178
+ if (this.built) {
1179
+ return;
1180
+ }
1181
+
1182
+ this.built = true;
1183
+ var $this = this.$element,
1184
+ options = this.options;
1185
+ var $picker = $(options.template);
1186
+ this.$picker = $picker;
1187
+ this.$week = $picker.find(selectorOf('week')); // Years view
1188
+
1189
+ this.$yearsPicker = $picker.find(selectorOf('years picker'));
1190
+ this.$yearsPrev = $picker.find(selectorOf('years prev'));
1191
+ this.$yearsNext = $picker.find(selectorOf('years next'));
1192
+ this.$yearsCurrent = $picker.find(selectorOf('years current'));
1193
+ this.$years = $picker.find(selectorOf('years')); // Months view
1194
+
1195
+ this.$monthsPicker = $picker.find(selectorOf('months picker'));
1196
+ this.$yearPrev = $picker.find(selectorOf('year prev'));
1197
+ this.$yearNext = $picker.find(selectorOf('year next'));
1198
+ this.$yearCurrent = $picker.find(selectorOf('year current'));
1199
+ this.$months = $picker.find(selectorOf('months')); // Days view
1200
+
1201
+ this.$daysPicker = $picker.find(selectorOf('days picker'));
1202
+ this.$monthPrev = $picker.find(selectorOf('month prev'));
1203
+ this.$monthNext = $picker.find(selectorOf('month next'));
1204
+ this.$monthCurrent = $picker.find(selectorOf('month current'));
1205
+ this.$days = $picker.find(selectorOf('days'));
1206
+
1207
+ if (this.inline) {
1208
+ $(options.container || $this).append($picker.addClass("".concat(NAMESPACE, "-inline")));
1209
+ } else {
1210
+ $(document.body).append($picker.addClass("".concat(NAMESPACE, "-dropdown")));
1211
+ $picker.addClass(CLASS_HIDE).css({
1212
+ zIndex: parseInt(options.zIndex, 10)
1213
+ });
1214
+ }
1215
+
1216
+ this.renderWeek();
1217
+ }
1218
+ }, {
1219
+ key: "unbuild",
1220
+ value: function unbuild() {
1221
+ if (!this.built) {
1222
+ return;
1223
+ }
1224
+
1225
+ this.built = false;
1226
+ this.$picker.remove();
1227
+ }
1228
+ }, {
1229
+ key: "bind",
1230
+ value: function bind() {
1231
+ var options = this.options,
1232
+ $this = this.$element;
1233
+
1234
+ if ($.isFunction(options.show)) {
1235
+ $this.on(EVENT_SHOW, options.show);
1236
+ }
1237
+
1238
+ if ($.isFunction(options.hide)) {
1239
+ $this.on(EVENT_HIDE, options.hide);
1240
+ }
1241
+
1242
+ if ($.isFunction(options.pick)) {
1243
+ $this.on(EVENT_PICK, options.pick);
1244
+ }
1245
+
1246
+ if (this.isInput) {
1247
+ $this.on(EVENT_KEYUP, $.proxy(this.keyup, this));
1248
+ }
1249
+
1250
+ if (!this.inline) {
1251
+ if (options.trigger) {
1252
+ this.$trigger.on(EVENT_CLICK, $.proxy(this.toggle, this));
1253
+ } else if (this.isInput) {
1254
+ $this.on(EVENT_FOCUS, $.proxy(this.show, this));
1255
+ } else {
1256
+ $this.on(EVENT_CLICK, $.proxy(this.show, this));
1257
+ }
1258
+ }
1259
+ }
1260
+ }, {
1261
+ key: "unbind",
1262
+ value: function unbind() {
1263
+ var $this = this.$element,
1264
+ options = this.options;
1265
+
1266
+ if ($.isFunction(options.show)) {
1267
+ $this.off(EVENT_SHOW, options.show);
1268
+ }
1269
+
1270
+ if ($.isFunction(options.hide)) {
1271
+ $this.off(EVENT_HIDE, options.hide);
1272
+ }
1273
+
1274
+ if ($.isFunction(options.pick)) {
1275
+ $this.off(EVENT_PICK, options.pick);
1276
+ }
1277
+
1278
+ if (this.isInput) {
1279
+ $this.off(EVENT_KEYUP, this.keyup);
1280
+ }
1281
+
1282
+ if (!this.inline) {
1283
+ if (options.trigger) {
1284
+ this.$trigger.off(EVENT_CLICK, this.toggle);
1285
+ } else if (this.isInput) {
1286
+ $this.off(EVENT_FOCUS, this.show);
1287
+ } else {
1288
+ $this.off(EVENT_CLICK, this.show);
1289
+ }
1290
+ }
1291
+ }
1292
+ }, {
1293
+ key: "showView",
1294
+ value: function showView(view) {
1295
+ var $yearsPicker = this.$yearsPicker,
1296
+ $monthsPicker = this.$monthsPicker,
1297
+ $daysPicker = this.$daysPicker,
1298
+ format = this.format;
1299
+
1300
+ if (format.hasYear || format.hasMonth || format.hasDay) {
1301
+ switch (Number(view)) {
1302
+ case VIEWS.YEARS:
1303
+ $monthsPicker.addClass(CLASS_HIDE);
1304
+ $daysPicker.addClass(CLASS_HIDE);
1305
+
1306
+ if (format.hasYear) {
1307
+ this.renderYears();
1308
+ $yearsPicker.removeClass(CLASS_HIDE);
1309
+ this.place();
1310
+ } else {
1311
+ this.showView(VIEWS.DAYS);
1312
+ }
1313
+
1314
+ break;
1315
+
1316
+ case VIEWS.MONTHS:
1317
+ $yearsPicker.addClass(CLASS_HIDE);
1318
+ $daysPicker.addClass(CLASS_HIDE);
1319
+
1320
+ if (format.hasMonth) {
1321
+ this.renderMonths();
1322
+ $monthsPicker.removeClass(CLASS_HIDE);
1323
+ this.place();
1324
+ } else {
1325
+ this.showView(VIEWS.YEARS);
1326
+ }
1327
+
1328
+ break;
1329
+ // case VIEWS.DAYS:
1330
+
1331
+ default:
1332
+ $yearsPicker.addClass(CLASS_HIDE);
1333
+ $monthsPicker.addClass(CLASS_HIDE);
1334
+
1335
+ if (format.hasDay) {
1336
+ this.renderDays();
1337
+ $daysPicker.removeClass(CLASS_HIDE);
1338
+ this.place();
1339
+ } else {
1340
+ this.showView(VIEWS.MONTHS);
1341
+ }
1342
+
1343
+ }
1344
+ }
1345
+ }
1346
+ }, {
1347
+ key: "hideView",
1348
+ value: function hideView() {
1349
+ if (!this.inline && this.options.autoHide) {
1350
+ this.hide();
1351
+ }
1352
+ }
1353
+ }, {
1354
+ key: "place",
1355
+ value: function place() {
1356
+ if (this.inline) {
1357
+ return;
1358
+ }
1359
+
1360
+ var $this = this.$element,
1361
+ options = this.options,
1362
+ $picker = this.$picker;
1363
+ var containerWidth = $(document).outerWidth();
1364
+ var containerHeight = $(document).outerHeight();
1365
+ var elementWidth = $this.outerWidth();
1366
+ var elementHeight = $this.outerHeight();
1367
+ var width = $picker.width();
1368
+ var height = $picker.height();
1369
+
1370
+ var _$this$offset = $this.offset(),
1371
+ left = _$this$offset.left,
1372
+ top = _$this$offset.top;
1373
+
1374
+ var offset = parseFloat(options.offset);
1375
+ var placement = CLASS_TOP_LEFT;
1376
+
1377
+ if (isNaN(offset)) {
1378
+ offset = 10;
1379
+ }
1380
+
1381
+ if (top > height && top + elementHeight + height > containerHeight) {
1382
+ top -= height + offset;
1383
+ placement = CLASS_BOTTOM_LEFT;
1384
+ } else {
1385
+ top += elementHeight + offset;
1386
+ }
1387
+
1388
+ if (left + width > containerWidth) {
1389
+ left += elementWidth - width;
1390
+ placement = placement.replace('left', 'right');
1391
+ }
1392
+
1393
+ $picker.removeClass(CLASS_PLACEMENTS).addClass(placement).css({
1394
+ top: top,
1395
+ left: left
1396
+ });
1397
+ } // A shortcut for triggering custom events
1398
+
1399
+ }, {
1400
+ key: "trigger",
1401
+ value: function trigger(type, data) {
1402
+ var e = $.Event(type, data);
1403
+ this.$element.trigger(e);
1404
+ return e;
1405
+ }
1406
+ }, {
1407
+ key: "createItem",
1408
+ value: function createItem(data) {
1409
+ var options = this.options;
1410
+ var itemTag = options.itemTag;
1411
+ var item = {
1412
+ text: '',
1413
+ view: '',
1414
+ muted: false,
1415
+ picked: false,
1416
+ disabled: false,
1417
+ highlighted: false
1418
+ };
1419
+ var classes = [];
1420
+ $.extend(item, data);
1421
+
1422
+ if (item.muted) {
1423
+ classes.push(options.mutedClass);
1424
+ }
1425
+
1426
+ if (item.highlighted) {
1427
+ classes.push(options.highlightedClass);
1428
+ }
1429
+
1430
+ if (item.picked) {
1431
+ classes.push(options.pickedClass);
1432
+ }
1433
+
1434
+ if (item.disabled) {
1435
+ classes.push(options.disabledClass);
1436
+ }
1437
+
1438
+ return "<".concat(itemTag, " class=\"").concat(classes.join(' '), "\" data-view=\"").concat(item.view, "\">").concat(item.text, "</").concat(itemTag, ">");
1439
+ }
1440
+ }, {
1441
+ key: "getValue",
1442
+ value: function getValue() {
1443
+ var $this = this.$element;
1444
+ return this.isInput ? $this.val() : $this.text();
1445
+ }
1446
+ }, {
1447
+ key: "setValue",
1448
+ value: function setValue() {
1449
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1450
+ var $this = this.$element;
1451
+
1452
+ if (this.isInput) {
1453
+ $this.val(value);
1454
+ } else if (!this.inline || this.options.container) {
1455
+ $this.text(value);
1456
+ }
1457
+ }
1458
+ }], [{
1459
+ key: "setDefaults",
1460
+ value: function setDefaults() {
1461
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1462
+ $.extend(DEFAULTS, LANGUAGES[options.language], $.isPlainObject(options) && options);
1463
+ }
1464
+ }]);
1465
+
1466
+ return Datepicker;
1467
+ }();
1468
+
1469
+ if ($.extend) {
1470
+ $.extend(Datepicker.prototype, render, handlers, methods);
1471
+ }
1472
+
1473
+ if ($.fn) {
1474
+ var AnotherDatepicker = $.fn.datepicker;
1475
+
1476
+ $.fn.datepicker = function jQueryDatepicker(option) {
1477
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1478
+ args[_key - 1] = arguments[_key];
1479
+ }
1480
+
1481
+ var result;
1482
+ this.each(function (i, element) {
1483
+ var $element = $(element);
1484
+ var isDestroy = option === 'destroy';
1485
+ var datepicker = $element.data(NAMESPACE);
1486
+
1487
+ if (!datepicker) {
1488
+ if (isDestroy) {
1489
+ return;
1490
+ }
1491
+
1492
+ var options = $.extend({}, $element.data(), $.isPlainObject(option) && option);
1493
+ datepicker = new Datepicker(element, options);
1494
+ $element.data(NAMESPACE, datepicker);
1495
+ }
1496
+
1497
+ if (isString(option)) {
1498
+ var fn = datepicker[option];
1499
+
1500
+ if ($.isFunction(fn)) {
1501
+ result = fn.apply(datepicker, args);
1502
+
1503
+ if (isDestroy) {
1504
+ $element.removeData(NAMESPACE);
1505
+ }
1506
+ }
1507
+ }
1508
+ });
1509
+ return !isUndefined(result) ? result : this;
1510
+ };
1511
+
1512
+ $.fn.datepicker.Constructor = Datepicker;
1513
+ $.fn.datepicker.languages = LANGUAGES;
1514
+ $.fn.datepicker.setDefaults = Datepicker.setDefaults;
1515
+
1516
+ $.fn.datepicker.noConflict = function noConflict() {
1517
+ $.fn.datepicker = AnotherDatepicker;
1518
+ return this;
1519
+ };
1520
+ }
1521
+
1522
+ })));