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