fomantic-ui 2.10.0-beta.8 → 2.10.0-beta.81
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/.eslintrc.js +6 -23
- package/.github/workflows/ci.yml +9 -9
- package/.github/workflows/depsreview.yml +1 -1
- package/.github/workflows/nightly.yml +7 -5
- package/.github/workflows/release.yml +2 -2
- package/.stylelintrc.js +1 -15
- package/CHANGELOG.md +5289 -2325
- package/README.md +8 -4
- package/changelog-setup.js +32 -10
- package/changelog-template.hbs +256 -251
- package/dist/components/accordion.css +1 -1
- package/dist/components/accordion.js +62 -73
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +3 -3
- package/dist/components/ad.css +1 -1
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +101 -161
- package/dist/components/api.min.js +3 -3
- package/dist/components/breadcrumb.css +1 -1
- package/dist/components/breadcrumb.min.css +1 -1
- package/dist/components/button.css +5 -6
- package/dist/components/button.min.css +2 -2
- package/dist/components/calendar.css +3 -3
- package/dist/components/calendar.js +283 -332
- package/dist/components/calendar.min.css +2 -2
- package/dist/components/calendar.min.js +3 -3
- package/dist/components/card.css +1 -1
- package/dist/components/card.min.css +1 -1
- package/dist/components/checkbox.css +1 -1
- package/dist/components/checkbox.js +58 -79
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +3 -3
- package/dist/components/comment.css +1 -1
- package/dist/components/comment.min.css +1 -1
- package/dist/components/container.css +1 -1
- package/dist/components/container.min.css +1 -1
- package/dist/components/dimmer.css +2 -2
- package/dist/components/dimmer.js +39 -52
- package/dist/components/dimmer.min.css +2 -2
- package/dist/components/dimmer.min.js +3 -3
- package/dist/components/divider.css +1 -1
- package/dist/components/divider.min.css +1 -1
- package/dist/components/dropdown.css +21 -35
- package/dist/components/dropdown.js +435 -531
- package/dist/components/dropdown.min.css +2 -2
- package/dist/components/dropdown.min.js +3 -3
- package/dist/components/embed.css +1 -1
- package/dist/components/embed.js +55 -68
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +3 -3
- package/dist/components/emoji.css +3809 -7617
- package/dist/components/emoji.min.css +2 -2
- package/dist/components/feed.css +1 -1
- package/dist/components/feed.min.css +1 -1
- package/dist/components/flag.css +1 -1
- package/dist/components/flag.min.css +1 -1
- package/dist/components/flyout.css +1 -1
- package/dist/components/flyout.js +149 -168
- package/dist/components/flyout.min.css +1 -1
- package/dist/components/flyout.min.js +3 -3
- package/dist/components/form.css +3 -5
- package/dist/components/form.js +249 -269
- package/dist/components/form.min.css +2 -2
- package/dist/components/form.min.js +3 -3
- package/dist/components/grid.css +2 -2
- package/dist/components/grid.min.css +2 -2
- package/dist/components/header.css +6 -6
- package/dist/components/header.min.css +2 -2
- package/dist/components/icon.css +10 -37
- package/dist/components/icon.min.css +2 -2
- package/dist/components/image.css +1 -1
- package/dist/components/image.min.css +1 -1
- package/dist/components/input.css +284 -12
- package/dist/components/input.min.css +2 -2
- package/dist/components/item.css +1 -1
- package/dist/components/item.min.css +1 -1
- package/dist/components/label.css +6 -14
- package/dist/components/label.min.css +2 -2
- package/dist/components/list.css +3 -3
- package/dist/components/list.min.css +2 -2
- package/dist/components/loader.css +53 -53
- package/dist/components/loader.min.css +2 -2
- package/dist/components/menu.css +45 -60
- package/dist/components/menu.min.css +2 -2
- package/dist/components/message.css +2 -2
- package/dist/components/message.min.css +2 -2
- package/dist/components/modal.css +5 -5
- package/dist/components/modal.js +161 -170
- package/dist/components/modal.min.css +2 -2
- package/dist/components/modal.min.js +3 -3
- package/dist/components/nag.css +1 -1
- package/dist/components/nag.js +74 -88
- package/dist/components/nag.min.css +1 -1
- package/dist/components/nag.min.js +3 -3
- package/dist/components/placeholder.css +2 -2
- package/dist/components/placeholder.min.css +2 -2
- package/dist/components/popup.css +19 -73
- package/dist/components/popup.js +105 -138
- package/dist/components/popup.min.css +2 -2
- package/dist/components/popup.min.js +3 -3
- package/dist/components/progress.css +4 -13
- package/dist/components/progress.js +75 -97
- package/dist/components/progress.min.css +2 -2
- package/dist/components/progress.min.js +3 -3
- package/dist/components/rail.css +1 -1
- package/dist/components/rail.min.css +1 -1
- package/dist/components/rating.css +1 -1
- package/dist/components/rating.js +49 -61
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +3 -3
- package/dist/components/reset.css +48 -208
- package/dist/components/reset.min.css +2 -2
- package/dist/components/reveal.css +2 -5
- package/dist/components/reveal.min.css +2 -2
- package/dist/components/search.css +2 -3
- package/dist/components/search.js +178 -198
- package/dist/components/search.min.css +2 -2
- package/dist/components/search.min.js +3 -3
- package/dist/components/segment.css +6 -6
- package/dist/components/segment.min.css +2 -2
- package/dist/components/shape.css +1 -1
- package/dist/components/shape.js +59 -69
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +3 -3
- package/dist/components/sidebar.css +1 -1
- package/dist/components/sidebar.js +81 -101
- package/dist/components/sidebar.min.css +1 -1
- package/dist/components/sidebar.min.js +3 -3
- package/dist/components/site.css +1 -1
- package/dist/components/site.js +37 -58
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +3 -3
- package/dist/components/slider.css +1 -1
- package/dist/components/slider.js +169 -183
- package/dist/components/slider.min.css +1 -1
- package/dist/components/slider.min.js +3 -3
- package/dist/components/state.js +45 -59
- package/dist/components/state.min.js +3 -3
- package/dist/components/statistic.css +1 -1
- package/dist/components/statistic.min.css +1 -1
- package/dist/components/step.css +4 -4
- package/dist/components/step.min.css +2 -2
- package/dist/components/sticky.css +1 -1
- package/dist/components/sticky.js +95 -117
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +3 -3
- package/dist/components/tab.css +1 -1
- package/dist/components/tab.js +83 -115
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +3 -3
- package/dist/components/table.css +8 -8
- package/dist/components/table.min.css +2 -2
- package/dist/components/text.css +1 -1
- package/dist/components/text.min.css +1 -1
- package/dist/components/toast.css +1 -1
- package/dist/components/toast.js +64 -74
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +3 -3
- package/dist/components/transition.css +1 -1
- package/dist/components/transition.js +61 -85
- package/dist/components/transition.min.css +1 -1
- package/dist/components/transition.min.js +3 -3
- package/dist/components/visibility.js +120 -140
- package/dist/components/visibility.min.js +3 -3
- package/dist/semantic.css +4480 -8222
- package/dist/semantic.js +2886 -3485
- package/dist/semantic.min.css +3 -3
- package/dist/semantic.min.js +3 -3
- package/examples/attached.html +1 -1
- package/examples/components/menu.html +1 -1
- package/package.json +8 -5
- package/scripts/nightly-version.js +4 -4
- package/src/definitions/behaviors/api.js +100 -160
- package/src/definitions/behaviors/form.js +248 -268
- package/src/definitions/behaviors/state.js +44 -58
- package/src/definitions/behaviors/visibility.js +119 -139
- package/src/definitions/collections/breadcrumb.less +0 -1
- package/src/definitions/collections/form.less +3 -9
- package/src/definitions/collections/grid.less +1 -2
- package/src/definitions/collections/menu.less +106 -117
- package/src/definitions/collections/message.less +1 -2
- package/src/definitions/collections/table.less +7 -8
- package/src/definitions/elements/button.less +4 -6
- package/src/definitions/elements/container.less +0 -1
- package/src/definitions/elements/divider.less +1 -2
- package/src/definitions/elements/emoji.less +1 -1
- package/src/definitions/elements/flag.less +1 -1
- package/src/definitions/elements/header.less +4 -5
- package/src/definitions/elements/icon.less +10 -37
- package/src/definitions/elements/image.less +0 -1
- package/src/definitions/elements/input.less +4 -7
- package/src/definitions/elements/label.less +5 -14
- package/src/definitions/elements/list.less +2 -3
- package/src/definitions/elements/loader.less +10 -11
- package/src/definitions/elements/placeholder.less +1 -2
- package/src/definitions/elements/rail.less +0 -1
- package/src/definitions/elements/reveal.less +1 -5
- package/src/definitions/elements/segment.less +5 -6
- package/src/definitions/elements/step.less +3 -4
- package/src/definitions/elements/text.less +0 -1
- package/src/definitions/globals/reset.less +0 -1
- package/src/definitions/globals/site.js +36 -57
- package/src/definitions/globals/site.less +0 -1
- package/src/definitions/modules/accordion.js +61 -72
- package/src/definitions/modules/accordion.less +0 -1
- package/src/definitions/modules/calendar.js +282 -331
- package/src/definitions/modules/calendar.less +2 -3
- package/src/definitions/modules/checkbox.js +57 -78
- package/src/definitions/modules/checkbox.less +0 -1
- package/src/definitions/modules/dimmer.js +38 -51
- package/src/definitions/modules/dimmer.less +1 -2
- package/src/definitions/modules/dropdown.js +434 -530
- package/src/definitions/modules/dropdown.less +27 -38
- package/src/definitions/modules/embed.js +54 -67
- package/src/definitions/modules/embed.less +0 -1
- package/src/definitions/modules/flyout.js +148 -167
- package/src/definitions/modules/flyout.less +0 -1
- package/src/definitions/modules/modal.js +160 -169
- package/src/definitions/modules/modal.less +3 -4
- package/src/definitions/modules/nag.js +73 -87
- package/src/definitions/modules/nag.less +0 -1
- package/src/definitions/modules/popup.js +104 -137
- package/src/definitions/modules/popup.less +18 -73
- package/src/definitions/modules/progress.js +74 -96
- package/src/definitions/modules/progress.less +3 -13
- package/src/definitions/modules/rating.js +48 -60
- package/src/definitions/modules/rating.less +0 -1
- package/src/definitions/modules/search.js +177 -197
- package/src/definitions/modules/search.less +2 -4
- package/src/definitions/modules/shape.js +58 -68
- package/src/definitions/modules/shape.less +0 -1
- package/src/definitions/modules/sidebar.js +80 -100
- package/src/definitions/modules/sidebar.less +0 -1
- package/src/definitions/modules/slider.js +168 -182
- package/src/definitions/modules/slider.less +0 -1
- package/src/definitions/modules/sticky.js +94 -116
- package/src/definitions/modules/sticky.less +0 -1
- package/src/definitions/modules/tab.js +82 -114
- package/src/definitions/modules/tab.less +0 -1
- package/src/definitions/modules/toast.js +63 -73
- package/src/definitions/modules/toast.less +0 -1
- package/src/definitions/modules/transition.js +60 -84
- package/src/definitions/modules/transition.less +1 -2
- package/src/definitions/views/ad.less +0 -1
- package/src/definitions/views/card.less +0 -1
- package/src/definitions/views/comment.less +0 -1
- package/src/definitions/views/feed.less +0 -1
- package/src/definitions/views/item.less +0 -1
- package/src/definitions/views/statistic.less +0 -1
- package/src/semantic.less +1 -1
- package/src/themes/amazon/elements/button.overrides +1 -1
- package/src/themes/amazon/elements/button.variables +5 -6
- package/src/themes/amazon/globals/site.variables +2 -3
- package/src/themes/bookish/elements/header.variables +2 -2
- package/src/themes/bootstrap3/elements/button.variables +4 -5
- package/src/themes/chubby/collections/menu.variables +1 -1
- package/src/themes/chubby/elements/button.overrides +4 -4
- package/src/themes/chubby/modules/accordion.overrides +1 -1
- package/src/themes/chubby/views/comment.overrides +2 -2
- package/src/themes/chubby/views/comment.variables +2 -2
- package/src/themes/classic/collections/table.variables +2 -2
- package/src/themes/classic/elements/button.variables +11 -11
- package/src/themes/classic/modules/progress.variables +2 -2
- package/src/themes/classic/views/card.variables +2 -2
- package/src/themes/default/collections/form.variables +2 -3
- package/src/themes/default/collections/menu.variables +28 -28
- package/src/themes/default/collections/message.variables +1 -1
- package/src/themes/default/collections/table.variables +4 -4
- package/src/themes/default/elements/button.variables +9 -10
- package/src/themes/default/elements/divider.variables +1 -1
- package/src/themes/default/elements/icon.variables +2 -2
- package/src/themes/default/elements/image.variables +1 -1
- package/src/themes/default/elements/input.variables +2 -2
- package/src/themes/default/elements/label.variables +4 -4
- package/src/themes/default/elements/list.variables +1 -1
- package/src/themes/default/elements/placeholder.variables +6 -6
- package/src/themes/default/elements/segment.variables +8 -8
- package/src/themes/default/globals/reset.overrides +45 -201
- package/src/themes/default/globals/site.variables +50 -50
- package/src/themes/default/globals/variation.variables +3 -2
- package/src/themes/default/modules/accordion.variables +0 -1
- package/src/themes/default/modules/checkbox.variables +1 -1
- package/src/themes/default/modules/dimmer.variables +12 -12
- package/src/themes/default/modules/dropdown.variables +17 -16
- package/src/themes/default/modules/embed.variables +2 -2
- package/src/themes/default/modules/flyout.variables +3 -3
- package/src/themes/default/modules/modal.variables +14 -14
- package/src/themes/default/modules/nag.variables +1 -1
- package/src/themes/default/modules/rating.variables +1 -1
- package/src/themes/default/modules/search.variables +1 -1
- package/src/themes/default/modules/shape.variables +1 -1
- package/src/themes/default/modules/sidebar.variables +2 -2
- package/src/themes/default/modules/toast.variables +4 -4
- package/src/themes/default/views/card.variables +6 -7
- package/src/themes/default/views/feed.variables +4 -4
- package/src/themes/default/views/item.variables +2 -3
- package/src/themes/flat/collections/form.variables +1 -1
- package/src/themes/flat/globals/site.variables +9 -9
- package/src/themes/github/collections/form.overrides +3 -3
- package/src/themes/github/collections/form.variables +3 -3
- package/src/themes/github/collections/menu.overrides +1 -1
- package/src/themes/github/collections/menu.variables +10 -10
- package/src/themes/github/collections/message.variables +6 -6
- package/src/themes/github/elements/button.variables +17 -17
- package/src/themes/github/elements/input.variables +3 -3
- package/src/themes/github/elements/segment.variables +2 -2
- package/src/themes/github/elements/step.overrides +4 -4
- package/src/themes/github/elements/step.variables +3 -3
- package/src/themes/github/globals/site.variables +2 -2
- package/src/themes/github/modules/dropdown.variables +1 -3
- package/src/themes/gmail/collections/message.variables +2 -2
- package/src/themes/material/collections/menu.variables +1 -1
- package/src/themes/material/elements/button.overrides +4 -4
- package/src/themes/material/elements/button.variables +5 -5
- package/src/themes/material/modules/dropdown.variables +1 -1
- package/src/themes/material/modules/modal.variables +1 -1
- package/src/themes/raised/elements/button.variables +1 -1
- package/src/themes/round/elements/button.variables +12 -12
- package/src/themes/striped/modules/progress.overrides +3 -3
- package/src/themes/timeline/views/feed.variables +2 -2
- package/src/themes/twitter/elements/button.overrides +1 -1
- package/src/themes/twitter/elements/button.variables +4 -5
- package/tasks/admin/components/create.js +12 -15
- package/tasks/admin/components/init.js +11 -12
- package/tasks/admin/components/update.js +19 -20
- package/tasks/admin/distributions/create.js +30 -51
- package/tasks/admin/distributions/init.js +11 -12
- package/tasks/admin/distributions/update.js +18 -19
- package/tasks/admin/register.js +7 -7
- package/tasks/build/assets.js +1 -1
- package/tasks/build/css.js +5 -5
- package/tasks/build/javascript.js +1 -1
- package/tasks/config/admin/github.js +1 -1
- package/tasks/config/admin/templates/css-package.js +1 -1
- package/tasks/config/admin/templates/less-package.js +1 -1
- package/tasks/config/project/config.js +10 -10
- package/tasks/config/project/install.js +12 -12
- package/tasks/config/project/release.js +6 -12
- package/tasks/config/tasks.js +15 -11
- package/tasks/config/user.js +1 -4
- package/tasks/docs/metadata.js +18 -20
- package/tasks/install.js +14 -12
- package/test/meteor/assets.js +4 -4
- package/test/meteor/fonts.js +10 -11
- package/test/modules/module.spec.js +18 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* # Fomantic-UI 2.10.0-beta.
|
|
2
|
+
* # Fomantic-UI 2.10.0-beta.81+4f706c2 - Calendar
|
|
3
3
|
* https://github.com/fomantic/Fomantic-UI/
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -19,60 +19,59 @@
|
|
|
19
19
|
? window
|
|
20
20
|
: globalThis;
|
|
21
21
|
|
|
22
|
-
$.fn.calendar = function (
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
$.fn.calendar = function (...args) {
|
|
23
|
+
const $allModules = $(this);
|
|
24
|
+
const $document = $(document);
|
|
25
25
|
|
|
26
26
|
let time = Date.now();
|
|
27
27
|
let performance = [];
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const parameters = args[0];
|
|
30
|
+
const methodInvoked = typeof parameters === 'string';
|
|
31
|
+
const queryArguments = args.slice(1);
|
|
32
32
|
let returnedValue;
|
|
33
|
-
|
|
33
|
+
const timeGapTable = {
|
|
34
34
|
5: { row: 4, column: 3 },
|
|
35
35
|
10: { row: 3, column: 2 },
|
|
36
36
|
15: { row: 2, column: 2 },
|
|
37
37
|
20: { row: 3, column: 1 },
|
|
38
38
|
30: { row: 2, column: 1 },
|
|
39
39
|
};
|
|
40
|
-
|
|
40
|
+
const numberText = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'];
|
|
41
41
|
|
|
42
42
|
$allModules.each(function () {
|
|
43
|
-
|
|
43
|
+
const settings = $.isPlainObject(parameters)
|
|
44
44
|
? $.extend(true, {}, $.fn.calendar.settings, parameters)
|
|
45
45
|
: $.extend({}, $.fn.calendar.settings);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const className = settings.className;
|
|
48
|
+
const namespace = settings.namespace;
|
|
49
|
+
const selector = settings.selector;
|
|
50
|
+
const formatter = settings.formatter;
|
|
51
|
+
const parser = settings.parser;
|
|
52
|
+
const metadata = settings.metadata;
|
|
53
|
+
const timeGap = timeGapTable[settings.minTimeGap];
|
|
54
|
+
const error = settings.error;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const eventNamespace = '.' + namespace;
|
|
57
|
+
const moduleNamespace = 'module-' + namespace;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const $module = $(this);
|
|
60
|
+
const $input = $module.find(selector.input);
|
|
61
61
|
let $activator = $module.find(selector.activator);
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const element = this;
|
|
64
64
|
let instance = $module.data(moduleNamespace);
|
|
65
65
|
let $container = instance && instance.popupId ? $document.find('#' + instance.popupId) : $module.find(selector.popup);
|
|
66
66
|
|
|
67
67
|
let isTouch;
|
|
68
68
|
let isTouchDown = false;
|
|
69
|
-
|
|
69
|
+
const isInverted = $module.hasClass(className.inverted);
|
|
70
70
|
let focusDateUsedForRange = false;
|
|
71
71
|
let selectionComplete = false;
|
|
72
72
|
let classObserver;
|
|
73
|
-
let module;
|
|
74
73
|
|
|
75
|
-
module = {
|
|
74
|
+
const module = {
|
|
76
75
|
|
|
77
76
|
initialize: function () {
|
|
78
77
|
module.debug('Initializing calendar for', element, $module);
|
|
@@ -146,8 +145,8 @@
|
|
|
146
145
|
} else {
|
|
147
146
|
// prepend the popup element to the activator's parent so that it has less chance of messing with
|
|
148
147
|
// the styling (e.g., input action button needs to be the last child to have the correct border radius)
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
const $activatorParent = $activator.parent();
|
|
149
|
+
const domPositionFunction = $activatorParent.closest(selector.append).length > 0 ? 'appendTo' : 'prependTo';
|
|
151
150
|
$container = $('<div/>').addClass(className.popup)[domPositionFunction]($activatorParent);
|
|
152
151
|
}
|
|
153
152
|
}
|
|
@@ -155,35 +154,35 @@
|
|
|
155
154
|
if (isInverted) {
|
|
156
155
|
$container.addClass(className.inverted);
|
|
157
156
|
}
|
|
158
|
-
let onVisible = function () {
|
|
157
|
+
let onVisible = function (...args) {
|
|
159
158
|
module.refreshTooltips();
|
|
160
159
|
|
|
161
|
-
return settings.onVisible.apply($container,
|
|
160
|
+
return settings.onVisible.apply($container, args);
|
|
162
161
|
};
|
|
163
|
-
|
|
162
|
+
const onHidden = function (...args) {
|
|
164
163
|
module.blur();
|
|
165
164
|
|
|
166
|
-
return settings.onHidden.apply($container,
|
|
165
|
+
return settings.onHidden.apply($container, args);
|
|
167
166
|
};
|
|
168
167
|
if ($input.length === 0) {
|
|
169
168
|
// no input, $container has to handle focus/blur
|
|
170
169
|
$container.attr('tabindex', '0');
|
|
171
|
-
onVisible = function () {
|
|
170
|
+
onVisible = function (...args) {
|
|
172
171
|
module.refreshTooltips();
|
|
173
172
|
module.focus();
|
|
174
173
|
|
|
175
|
-
return settings.onVisible.apply($container,
|
|
174
|
+
return settings.onVisible.apply($container, args);
|
|
176
175
|
};
|
|
177
176
|
}
|
|
178
|
-
|
|
177
|
+
const onShow = function (...args) {
|
|
179
178
|
// reset the focus date onShow
|
|
180
179
|
module.set.focusDate(module.get.date());
|
|
181
180
|
module.set.mode(module.get.validatedMode(settings.startMode));
|
|
182
181
|
|
|
183
|
-
return settings.onShow.apply($container,
|
|
182
|
+
return settings.onShow.apply($container, args);
|
|
184
183
|
};
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const on = module.setting('on');
|
|
185
|
+
const options = $.extend({}, settings.popupOptions, {
|
|
187
186
|
popup: $container,
|
|
188
187
|
movePopup: !settings.context,
|
|
189
188
|
on: on,
|
|
@@ -228,12 +227,11 @@
|
|
|
228
227
|
|
|
229
228
|
trigger: {
|
|
230
229
|
change: function () {
|
|
231
|
-
|
|
230
|
+
const inputElement = $input[0];
|
|
232
231
|
if (inputElement) {
|
|
233
|
-
|
|
232
|
+
const event = new Event('change', { bubbles: true });
|
|
234
233
|
module.verbose('Triggering native change event');
|
|
235
|
-
|
|
236
|
-
inputElement.dispatchEvent(events);
|
|
234
|
+
inputElement.dispatchEvent(event);
|
|
237
235
|
}
|
|
238
236
|
},
|
|
239
237
|
},
|
|
@@ -248,41 +246,41 @@
|
|
|
248
246
|
let cell;
|
|
249
247
|
let pageGrid;
|
|
250
248
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
const mode = module.get.mode();
|
|
250
|
+
const today = new Date();
|
|
251
|
+
const date = module.get.date();
|
|
254
252
|
let focusDate = module.get.focusDate();
|
|
255
|
-
|
|
253
|
+
const display = module.helper.dateInRange(focusDate || date || parser.date(settings.initialDate, settings) || today);
|
|
256
254
|
|
|
257
255
|
if (!focusDate) {
|
|
258
256
|
focusDate = display;
|
|
259
257
|
module.set.focusDate(focusDate, false, false);
|
|
260
258
|
}
|
|
261
259
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
260
|
+
const isYear = mode === 'year';
|
|
261
|
+
const isMonth = mode === 'month';
|
|
262
|
+
const isDay = mode === 'day';
|
|
263
|
+
const isHour = mode === 'hour';
|
|
264
|
+
const isMinute = mode === 'minute';
|
|
265
|
+
const isTimeOnly = settings.type === 'time';
|
|
268
266
|
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
const multiMonth = Math.max(settings.multiMonth, 1);
|
|
268
|
+
const monthOffset = !isDay ? 0 : module.get.monthOffset();
|
|
271
269
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
const minute = display.getMinutes();
|
|
271
|
+
const hour = display.getHours();
|
|
272
|
+
const day = display.getDate();
|
|
273
|
+
const startMonth = display.getMonth() + monthOffset;
|
|
274
|
+
const year = display.getFullYear();
|
|
277
275
|
|
|
278
|
-
|
|
276
|
+
const columns = isDay
|
|
279
277
|
? (settings.showWeekNumbers ? 8 : 7)
|
|
280
278
|
: (isHour ? 4 : timeGap.column);
|
|
281
279
|
let rows = isDay || isHour ? 6 : timeGap.row;
|
|
282
|
-
|
|
280
|
+
const pages = isDay ? multiMonth : 1;
|
|
283
281
|
|
|
284
282
|
let container = $container;
|
|
285
|
-
|
|
283
|
+
const tooltipPosition = container.hasClass('left') ? 'right center' : 'left center';
|
|
286
284
|
container.empty();
|
|
287
285
|
if (pages > 1) {
|
|
288
286
|
pageGrid = $('<div/>').addClass(className.grid).appendTo(container);
|
|
@@ -290,31 +288,31 @@
|
|
|
290
288
|
|
|
291
289
|
for (p = 0; p < pages; p++) {
|
|
292
290
|
if (pages > 1) {
|
|
293
|
-
|
|
291
|
+
const pageColumn = $('<div/>').addClass(className.column).appendTo(pageGrid);
|
|
294
292
|
container = pageColumn;
|
|
295
293
|
}
|
|
296
294
|
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
const month = startMonth + p;
|
|
296
|
+
const firstMonthDayColumn = (new Date(year, month, 1).getDay() - (settings.firstDayOfWeek % 7) + 7) % 7;
|
|
299
297
|
if (!settings.constantHeight && isDay) {
|
|
300
|
-
|
|
298
|
+
const requiredCells = new Date(year, month + 1, 0).getDate() + firstMonthDayColumn;
|
|
301
299
|
rows = Math.ceil(requiredCells / 7);
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
302
|
+
const yearChange = isYear ? 10 : (isMonth ? 1 : 0);
|
|
303
|
+
const monthChange = isDay ? 1 : 0;
|
|
304
|
+
const dayChange = isHour || isMinute ? 1 : 0;
|
|
305
|
+
const prevNextDay = isHour || isMinute ? day : 1;
|
|
306
|
+
const prevDate = new Date(year - yearChange, month - monthChange, prevNextDay - dayChange, hour);
|
|
307
|
+
const nextDate = new Date(year + yearChange, month + monthChange, prevNextDay + dayChange, hour);
|
|
308
|
+
const prevLast = isYear
|
|
311
309
|
? new Date(Math.ceil(year / 10) * 10 - 9, 0, 0)
|
|
312
310
|
: (isMonth
|
|
313
311
|
? new Date(year, 0, 0)
|
|
314
312
|
: (isDay // eslint-disable-line unicorn/no-nested-ternary
|
|
315
313
|
? new Date(year, month, 0)
|
|
316
314
|
: new Date(year, month, day, -1)));
|
|
317
|
-
|
|
315
|
+
const nextFirst = isYear
|
|
318
316
|
? new Date(Math.ceil(year / 10) * 10 + 1, 0, 1)
|
|
319
317
|
: (isMonth
|
|
320
318
|
? new Date(year + 1, 0, 1)
|
|
@@ -326,7 +324,7 @@
|
|
|
326
324
|
if (isDay && settings.showWeekNumbers) {
|
|
327
325
|
tempMode += ' andweek';
|
|
328
326
|
}
|
|
329
|
-
|
|
327
|
+
const table = $('<table/>').addClass(className.table).addClass(tempMode).addClass(numberText[columns] + ' column')
|
|
330
328
|
.appendTo(container);
|
|
331
329
|
if (isInverted) {
|
|
332
330
|
table.addClass(className.inverted);
|
|
@@ -334,19 +332,19 @@
|
|
|
334
332
|
let textColumns = columns;
|
|
335
333
|
// no header for time-only mode
|
|
336
334
|
if (!isTimeOnly) {
|
|
337
|
-
|
|
335
|
+
const thead = $('<thead/>').appendTo(table);
|
|
338
336
|
|
|
339
337
|
row = $('<tr/>').appendTo(thead);
|
|
340
338
|
cell = $('<th/>').attr('colspan', '' + columns).appendTo(row);
|
|
341
339
|
|
|
342
|
-
|
|
340
|
+
const headerDate = isYear || isMonth
|
|
343
341
|
? new Date(year, 0, 1)
|
|
344
342
|
: (isDay
|
|
345
343
|
? new Date(year, month, 1)
|
|
346
344
|
: new Date(year, month, day, hour, minute));
|
|
347
|
-
|
|
345
|
+
const headerText = $('<span/>').addClass(className.link).appendTo(cell);
|
|
348
346
|
headerText.text(module.helper.dateFormat(formatter[mode + 'Header'], headerDate));
|
|
349
|
-
|
|
347
|
+
const newMode = isMonth
|
|
350
348
|
? (settings.disableYear ? 'day' : 'year')
|
|
351
349
|
: (isDay
|
|
352
350
|
? (settings.disableMonth ? 'year' : 'month') // eslint-disable-line unicorn/no-nested-ternary
|
|
@@ -354,14 +352,14 @@
|
|
|
354
352
|
headerText.data(metadata.mode, newMode);
|
|
355
353
|
|
|
356
354
|
if (p === 0) {
|
|
357
|
-
|
|
355
|
+
const prev = $('<span/>').addClass(className.prev).appendTo(cell);
|
|
358
356
|
prev.data(metadata.focusDate, prevDate);
|
|
359
357
|
prev.toggleClass(className.disabledCell, !module.helper.isDateInRange(prevLast, mode));
|
|
360
358
|
$('<i/>').addClass(className.prevIcon).appendTo(prev);
|
|
361
359
|
}
|
|
362
360
|
|
|
363
361
|
if (p === pages - 1) {
|
|
364
|
-
|
|
362
|
+
const next = $('<span/>').addClass(className.next).appendTo(cell);
|
|
365
363
|
next.data(metadata.focusDate, nextDate);
|
|
366
364
|
next.toggleClass(className.disabledCell, !module.helper.isDateInRange(nextFirst, mode));
|
|
367
365
|
$('<i/>').addClass(className.nextIcon).appendTo(next);
|
|
@@ -381,7 +379,7 @@
|
|
|
381
379
|
}
|
|
382
380
|
}
|
|
383
381
|
|
|
384
|
-
|
|
382
|
+
const tbody = $('<tbody/>').appendTo(table);
|
|
385
383
|
i = isYear
|
|
386
384
|
? Math.ceil(year / 10) * 10 - 9
|
|
387
385
|
: (isDay ? 1 - firstMonthDayColumn : 0);
|
|
@@ -393,7 +391,7 @@
|
|
|
393
391
|
cell.addClass(className.weekCell);
|
|
394
392
|
}
|
|
395
393
|
for (c = 0; c < textColumns; c++, i++) {
|
|
396
|
-
|
|
394
|
+
const cellDate = isYear
|
|
397
395
|
? new Date(i, month, 1, hour, minute)
|
|
398
396
|
: (isMonth
|
|
399
397
|
? new Date(year, i, 1, hour, minute)
|
|
@@ -402,7 +400,7 @@
|
|
|
402
400
|
: (isHour
|
|
403
401
|
? new Date(year, month, day, i)
|
|
404
402
|
: new Date(year, month, day, hour, i * settings.minTimeGap))));
|
|
405
|
-
|
|
403
|
+
const cellText = isYear
|
|
406
404
|
? i
|
|
407
405
|
: (isMonth
|
|
408
406
|
? settings.text.monthsShort[i]
|
|
@@ -412,11 +410,11 @@
|
|
|
412
410
|
cell = $('<td/>').addClass(className.cell).appendTo(row);
|
|
413
411
|
cell.text(cellText);
|
|
414
412
|
cell.data(metadata.date, cellDate);
|
|
415
|
-
|
|
416
|
-
|
|
413
|
+
const adjacent = isDay && cellDate.getMonth() !== ((month + 12) % 12);
|
|
414
|
+
const disabled = (!settings.selectAdjacentDays && adjacent) || !module.helper.isDateInRange(cellDate, mode) || settings.isDisabled(cellDate, mode) || module.helper.isDisabled(cellDate, mode) || !module.helper.isEnabled(cellDate, mode);
|
|
417
415
|
let eventDate;
|
|
418
416
|
if (disabled) {
|
|
419
|
-
|
|
417
|
+
const disabledDate = module.helper.findDayAsObject(cellDate, mode, settings.disabledDates);
|
|
420
418
|
if (disabledDate !== null && disabledDate[metadata.message]) {
|
|
421
419
|
cell.attr('data-tooltip', disabledDate[metadata.message]);
|
|
422
420
|
cell.attr('data-position', disabledDate[metadata.position] || tooltipPosition);
|
|
@@ -428,7 +426,7 @@
|
|
|
428
426
|
}
|
|
429
427
|
}
|
|
430
428
|
if (mode === 'hour') {
|
|
431
|
-
|
|
429
|
+
const disabledHour = module.helper.findHourAsObject(cellDate, mode, settings.disabledHours);
|
|
432
430
|
if (disabledHour !== null && disabledHour[metadata.message]) {
|
|
433
431
|
cell.attr('data-tooltip', disabledHour[metadata.message]);
|
|
434
432
|
cell.attr('data-position', disabledHour[metadata.position] || tooltipPosition);
|
|
@@ -456,8 +454,8 @@
|
|
|
456
454
|
}
|
|
457
455
|
}
|
|
458
456
|
}
|
|
459
|
-
|
|
460
|
-
|
|
457
|
+
const active = module.helper.dateEqual(cellDate, date, mode);
|
|
458
|
+
const isToday = module.helper.dateEqual(cellDate, today, mode);
|
|
461
459
|
cell.toggleClass(className.adjacentCell, adjacent && !eventDate);
|
|
462
460
|
cell.toggleClass(className.disabledCell, disabled);
|
|
463
461
|
cell.toggleClass(className.activeCell, active && !(adjacent && disabled));
|
|
@@ -466,7 +464,7 @@
|
|
|
466
464
|
}
|
|
467
465
|
|
|
468
466
|
// Allow for external modifications of each cell
|
|
469
|
-
|
|
467
|
+
const cellOptions = {
|
|
470
468
|
mode: mode,
|
|
471
469
|
adjacent: adjacent,
|
|
472
470
|
disabled: disabled,
|
|
@@ -484,8 +482,8 @@
|
|
|
484
482
|
}
|
|
485
483
|
|
|
486
484
|
if (settings.today) {
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
const todayRow = $('<tr/>').appendTo(tbody);
|
|
486
|
+
const todayButton = $('<td/>').attr('colspan', '' + columns).addClass(className.today).appendTo(todayRow);
|
|
489
487
|
todayButton.text(formatter.today(settings));
|
|
490
488
|
todayButton.data(metadata.date, today);
|
|
491
489
|
}
|
|
@@ -500,26 +498,25 @@
|
|
|
500
498
|
},
|
|
501
499
|
|
|
502
500
|
update: {
|
|
503
|
-
focus: function (updateRange, container) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
let rangeDate = (updateRange ? focusDate : null) || date || (!isTouch ? focusDate : null);
|
|
501
|
+
focus: function (updateRange, container = $container) {
|
|
502
|
+
const mode = module.get.mode();
|
|
503
|
+
const date = module.get.date();
|
|
504
|
+
const focusDate = module.get.focusDate();
|
|
505
|
+
const startDate = module.get.startDate();
|
|
506
|
+
const endDate = module.get.endDate();
|
|
507
|
+
const rangeDate = (updateRange ? focusDate : null) || date || (!isTouch ? focusDate : null);
|
|
511
508
|
|
|
512
509
|
container.find('td').each(function () {
|
|
513
|
-
|
|
514
|
-
|
|
510
|
+
const $cell = $(this);
|
|
511
|
+
const cellDate = $cell.data(metadata.date);
|
|
515
512
|
if (!cellDate) {
|
|
516
513
|
return;
|
|
517
514
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
515
|
+
const disabled = $cell.hasClass(className.disabledCell);
|
|
516
|
+
const active = $cell.hasClass(className.activeCell);
|
|
517
|
+
const adjacent = $cell.hasClass(className.adjacentCell);
|
|
518
|
+
const focused = module.helper.dateEqual(cellDate, focusDate, mode);
|
|
519
|
+
const inRange = !rangeDate
|
|
523
520
|
? false
|
|
524
521
|
: (!!startDate && module.helper.isDateInRange(cellDate, mode, startDate, rangeDate))
|
|
525
522
|
|| (!!endDate && module.helper.isDateInRange(cellDate, mode, rangeDate, endDate));
|
|
@@ -538,14 +535,14 @@
|
|
|
538
535
|
},
|
|
539
536
|
|
|
540
537
|
refreshTooltips: function () {
|
|
541
|
-
|
|
538
|
+
const winWidth = $(window).width();
|
|
542
539
|
$container.find('td[data-position]').each(function () {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
540
|
+
const $cell = $(this);
|
|
541
|
+
const tooltipWidth = window.getComputedStyle($cell[0], '::after').width.replace(/[^\d.]/g, '');
|
|
542
|
+
const tooltipPosition = $cell.attr('data-position');
|
|
546
543
|
// use a fallback width of 250 (calendar width) for IE/Edge (which return "auto")
|
|
547
|
-
|
|
548
|
-
if (tooltipPosition.
|
|
544
|
+
const calcPosition = (winWidth - $cell.width() - (Number.parseInt(tooltipWidth, 10) || 250)) > $cell.offset().left ? 'right' : 'left';
|
|
545
|
+
if (!tooltipPosition.includes(calcPosition)) {
|
|
549
546
|
$cell.attr('data-position', tooltipPosition.replace(/(left|right)/, calcPosition));
|
|
550
547
|
}
|
|
551
548
|
});
|
|
@@ -582,9 +579,9 @@
|
|
|
582
579
|
|
|
583
580
|
event: {
|
|
584
581
|
mouseover: function (event) {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
582
|
+
const target = $(event.target);
|
|
583
|
+
const date = target.data(metadata.date);
|
|
584
|
+
const mousedown = event.buttons === 1;
|
|
588
585
|
if (date) {
|
|
589
586
|
module.set.focusDate(date, false, true, mousedown);
|
|
590
587
|
}
|
|
@@ -594,9 +591,9 @@
|
|
|
594
591
|
// prevent the mousedown on the calendar causing the input to lose focus
|
|
595
592
|
event.preventDefault();
|
|
596
593
|
}
|
|
597
|
-
isTouchDown = event.type.
|
|
598
|
-
|
|
599
|
-
|
|
594
|
+
isTouchDown = event.type.includes('touch');
|
|
595
|
+
const target = $(event.target);
|
|
596
|
+
const date = target.data(metadata.date);
|
|
600
597
|
if (date) {
|
|
601
598
|
module.set.focusDate(date, false, true, true);
|
|
602
599
|
}
|
|
@@ -611,16 +608,16 @@
|
|
|
611
608
|
if (target.hasClass('disabled')) {
|
|
612
609
|
return;
|
|
613
610
|
}
|
|
614
|
-
|
|
611
|
+
const parent = target.parent();
|
|
615
612
|
if (parent.data(metadata.date) || parent.data(metadata.focusDate) || parent.data(metadata.mode)) {
|
|
616
613
|
// clicked on a child element, switch to parent (used when clicking directly on the prev/next <i> icon element)
|
|
617
614
|
target = parent;
|
|
618
615
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
616
|
+
const date = target.data(metadata.date);
|
|
617
|
+
const focusDate = target.data(metadata.focusDate);
|
|
618
|
+
const mode = target.data(metadata.mode);
|
|
622
619
|
if (date && settings.onSelect.call(element, date, module.get.mode()) !== false) {
|
|
623
|
-
|
|
620
|
+
const forceSet = target.hasClass(className.today);
|
|
624
621
|
module.selectDate(date, forceSet);
|
|
625
622
|
} else if (focusDate) {
|
|
626
623
|
module.set.focusDate(focusDate);
|
|
@@ -629,21 +626,21 @@
|
|
|
629
626
|
}
|
|
630
627
|
},
|
|
631
628
|
keydown: function (event) {
|
|
632
|
-
|
|
629
|
+
const keyCode = event.which;
|
|
633
630
|
if (keyCode === 9) {
|
|
634
631
|
// tab
|
|
635
632
|
module.popup('hide');
|
|
636
633
|
}
|
|
637
634
|
|
|
638
635
|
if (module.popup('is visible')) {
|
|
639
|
-
|
|
636
|
+
const mode = module.get.mode();
|
|
640
637
|
switch (keyCode) {
|
|
641
638
|
// arrow keys
|
|
642
639
|
case 37:
|
|
643
640
|
case 38:
|
|
644
641
|
case 39:
|
|
645
642
|
case 40: {
|
|
646
|
-
|
|
643
|
+
const bigIncrement = mode === 'day'
|
|
647
644
|
? 7
|
|
648
645
|
: (mode === 'hour'
|
|
649
646
|
? 4
|
|
@@ -654,12 +651,12 @@
|
|
|
654
651
|
? -bigIncrement
|
|
655
652
|
: (keyCode === 39 ? 1 : bigIncrement)); // eslint-disable-line unicorn/no-nested-ternary
|
|
656
653
|
increment *= mode === 'minute' ? settings.minTimeGap : 1;
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
654
|
+
const focusDate = module.get.focusDate() || module.get.date() || new Date();
|
|
655
|
+
const year = focusDate.getFullYear() + (mode === 'year' ? increment : 0);
|
|
656
|
+
const month = focusDate.getMonth() + (mode === 'month' ? increment : 0);
|
|
657
|
+
const day = focusDate.getDate() + (mode === 'day' ? increment : 0);
|
|
658
|
+
const hour = focusDate.getHours() + (mode === 'hour' ? increment : 0);
|
|
659
|
+
const minute = focusDate.getMinutes() + (mode === 'minute' ? increment : 0);
|
|
663
660
|
let newFocusDate = new Date(year, month, day, hour, minute);
|
|
664
661
|
if (settings.type === 'time') {
|
|
665
662
|
newFocusDate = module.helper.mergeDateTime(focusDate, newFocusDate);
|
|
@@ -672,11 +669,9 @@
|
|
|
672
669
|
}
|
|
673
670
|
// enter key
|
|
674
671
|
case 13: {
|
|
675
|
-
|
|
676
|
-
if (date && !settings.isDisabled(date, mode) && !module.helper.isDisabled(date, mode) && module.helper.isEnabled(date, mode)) {
|
|
677
|
-
|
|
678
|
-
module.selectDate(date);
|
|
679
|
-
}
|
|
672
|
+
const date = module.get.focusDate();
|
|
673
|
+
if (date && !settings.isDisabled(date, mode) && !module.helper.isDisabled(date, mode) && module.helper.isEnabled(date, mode) && settings.onSelect.call(element, date, module.get.mode()) !== false) {
|
|
674
|
+
module.selectDate(date);
|
|
680
675
|
}
|
|
681
676
|
// disable form submission:
|
|
682
677
|
event.preventDefault();
|
|
@@ -691,6 +686,7 @@
|
|
|
691
686
|
|
|
692
687
|
break;
|
|
693
688
|
}
|
|
689
|
+
// no default
|
|
694
690
|
}
|
|
695
691
|
}
|
|
696
692
|
|
|
@@ -701,8 +697,8 @@
|
|
|
701
697
|
}
|
|
702
698
|
},
|
|
703
699
|
inputChange: function () {
|
|
704
|
-
|
|
705
|
-
|
|
700
|
+
const val = $input.val();
|
|
701
|
+
const date = parser.date(val, settings);
|
|
706
702
|
module.set.date(date, false);
|
|
707
703
|
},
|
|
708
704
|
inputFocus: function () {
|
|
@@ -711,8 +707,8 @@
|
|
|
711
707
|
inputBlur: function () {
|
|
712
708
|
$container.removeClass(className.active);
|
|
713
709
|
if (settings.formatInput) {
|
|
714
|
-
|
|
715
|
-
|
|
710
|
+
const date = module.get.date();
|
|
711
|
+
const text = module.helper.dateFormat(formatter[settings.type], date);
|
|
716
712
|
$input.val(text);
|
|
717
713
|
}
|
|
718
714
|
if (selectionComplete) {
|
|
@@ -722,21 +718,19 @@
|
|
|
722
718
|
},
|
|
723
719
|
class: {
|
|
724
720
|
mutation: function (mutations) {
|
|
725
|
-
|
|
721
|
+
for (const mutation of mutations) {
|
|
726
722
|
if (mutation.attributeName === 'class') {
|
|
727
723
|
module.check.disabled();
|
|
728
724
|
}
|
|
729
|
-
}
|
|
725
|
+
}
|
|
730
726
|
},
|
|
731
727
|
},
|
|
732
728
|
},
|
|
733
729
|
|
|
734
730
|
observeChanges: function () {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
module.observe.class();
|
|
739
|
-
}
|
|
731
|
+
classObserver = new MutationObserver(module.event.class.mutation);
|
|
732
|
+
module.debug('Setting up mutation observer', classObserver);
|
|
733
|
+
module.observe.class();
|
|
740
734
|
},
|
|
741
735
|
|
|
742
736
|
disconnect: {
|
|
@@ -772,11 +766,11 @@
|
|
|
772
766
|
get: {
|
|
773
767
|
weekOfYear: function (weekYear, weekMonth, weekDay) {
|
|
774
768
|
// adapted from http://www.merlyn.demon.co.uk/weekcalc.htm
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
769
|
+
const ms1d = 24 * 3600 * 1000;
|
|
770
|
+
const ms7d = 7 * ms1d;
|
|
771
|
+
const DC3 = Date.UTC(weekYear, weekMonth, weekDay + 3) / ms1d; // an absolute day number
|
|
772
|
+
const AWN = Math.floor(DC3 / 7); // an absolute week number
|
|
773
|
+
const Wyr = new Date(AWN * ms7d).getUTCFullYear();
|
|
780
774
|
|
|
781
775
|
return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
|
|
782
776
|
},
|
|
@@ -793,7 +787,7 @@
|
|
|
793
787
|
return module.helper.dateObjectOrFormatted(format, $module.data(metadata.focusDate));
|
|
794
788
|
},
|
|
795
789
|
startDate: function (format) {
|
|
796
|
-
|
|
790
|
+
const startModule = module.get.calendarModule(settings.startCalendar);
|
|
797
791
|
|
|
798
792
|
if (startModule) {
|
|
799
793
|
return startModule.get.date(format);
|
|
@@ -802,7 +796,7 @@
|
|
|
802
796
|
return module.helper.dateObjectOrFormatted(format, $module.data(metadata.startDate));
|
|
803
797
|
},
|
|
804
798
|
endDate: function (format) {
|
|
805
|
-
|
|
799
|
+
const endModule = module.get.calendarModule(settings.endCalendar);
|
|
806
800
|
|
|
807
801
|
if (endModule) {
|
|
808
802
|
return endModule.get.date(format);
|
|
@@ -821,13 +815,12 @@
|
|
|
821
815
|
},
|
|
822
816
|
mode: function () {
|
|
823
817
|
// only returns valid modes for the current settings
|
|
824
|
-
|
|
818
|
+
const mode = $module.data(metadata.mode) || settings.startMode;
|
|
825
819
|
|
|
826
820
|
return module.get.validatedMode(mode);
|
|
827
821
|
},
|
|
828
822
|
validatedMode: function (mode) {
|
|
829
|
-
|
|
830
|
-
if ($.inArray(mode, validModes) >= 0) {
|
|
823
|
+
if (module.get.validModes().includes(mode)) {
|
|
831
824
|
return mode;
|
|
832
825
|
}
|
|
833
826
|
|
|
@@ -841,7 +834,7 @@
|
|
|
841
834
|
return $module.data(metadata.type) || settings.type;
|
|
842
835
|
},
|
|
843
836
|
validModes: function () {
|
|
844
|
-
|
|
837
|
+
const validModes = [];
|
|
845
838
|
if (settings.type !== 'time') {
|
|
846
839
|
if (!settings.disableYear || settings.type === 'year') {
|
|
847
840
|
validModes.push('year');
|
|
@@ -849,11 +842,11 @@
|
|
|
849
842
|
if (!(settings.disableMonth || settings.type === 'year') || settings.type === 'month') {
|
|
850
843
|
validModes.push('month');
|
|
851
844
|
}
|
|
852
|
-
if (settings.type.
|
|
845
|
+
if (settings.type.includes('date')) {
|
|
853
846
|
validModes.push('day');
|
|
854
847
|
}
|
|
855
848
|
}
|
|
856
|
-
if (settings.type.
|
|
849
|
+
if (settings.type.includes('time')) {
|
|
857
850
|
validModes.push('hour');
|
|
858
851
|
if (!settings.disableMinute) {
|
|
859
852
|
validModes.push('minute');
|
|
@@ -867,7 +860,7 @@
|
|
|
867
860
|
document.createEvent('TouchEvent');
|
|
868
861
|
|
|
869
862
|
return true;
|
|
870
|
-
} catch
|
|
863
|
+
} catch {
|
|
871
864
|
return false;
|
|
872
865
|
}
|
|
873
866
|
},
|
|
@@ -891,8 +884,8 @@
|
|
|
891
884
|
date = module.helper.sanitiseDate(date);
|
|
892
885
|
date = module.helper.dateInRange(date);
|
|
893
886
|
|
|
894
|
-
|
|
895
|
-
|
|
887
|
+
const mode = module.get.mode();
|
|
888
|
+
const text = module.helper.dateFormat(formatter[settings.type], date);
|
|
896
889
|
|
|
897
890
|
if (fireChange && settings.onBeforeChange.call(element, date, text, mode) === false) {
|
|
898
891
|
return false;
|
|
@@ -904,7 +897,7 @@
|
|
|
904
897
|
return false;
|
|
905
898
|
}
|
|
906
899
|
|
|
907
|
-
|
|
900
|
+
const endDate = module.get.endDate();
|
|
908
901
|
if (!!endDate && !!date && date > endDate) {
|
|
909
902
|
// selected date is greater than end date in range, so clear end date
|
|
910
903
|
module.set.endDate();
|
|
@@ -921,7 +914,7 @@
|
|
|
921
914
|
},
|
|
922
915
|
startDate: function (date, refreshCalendar) {
|
|
923
916
|
date = module.helper.sanitiseDate(date);
|
|
924
|
-
|
|
917
|
+
const startModule = module.get.calendarModule(settings.startCalendar);
|
|
925
918
|
if (startModule) {
|
|
926
919
|
startModule.set.date(date);
|
|
927
920
|
}
|
|
@@ -929,7 +922,7 @@
|
|
|
929
922
|
},
|
|
930
923
|
endDate: function (date, refreshCalendar) {
|
|
931
924
|
date = module.helper.sanitiseDate(date);
|
|
932
|
-
|
|
925
|
+
const endModule = module.get.calendarModule(settings.endCalendar);
|
|
933
926
|
if (endModule) {
|
|
934
927
|
endModule.set.date(date);
|
|
935
928
|
}
|
|
@@ -938,17 +931,17 @@
|
|
|
938
931
|
focusDate: function (date, refreshCalendar, updateFocus, updateRange) {
|
|
939
932
|
date = module.helper.sanitiseDate(date);
|
|
940
933
|
date = module.helper.dateInRange(date);
|
|
941
|
-
|
|
942
|
-
|
|
934
|
+
const isDay = module.get.mode() === 'day';
|
|
935
|
+
const oldFocusDate = module.get.focusDate();
|
|
943
936
|
if (isDay && date && oldFocusDate) {
|
|
944
|
-
|
|
945
|
-
|
|
937
|
+
const yearDelta = date.getFullYear() - oldFocusDate.getFullYear();
|
|
938
|
+
const monthDelta = yearDelta * 12 + date.getMonth() - oldFocusDate.getMonth();
|
|
946
939
|
if (monthDelta) {
|
|
947
|
-
|
|
940
|
+
const monthOffset = module.get.monthOffset() - monthDelta;
|
|
948
941
|
module.set.monthOffset(monthOffset, false);
|
|
949
942
|
}
|
|
950
943
|
}
|
|
951
|
-
|
|
944
|
+
const changed = module.set.dataKeyValue(metadata.focusDate, date, !!date && refreshCalendar);
|
|
952
945
|
updateFocus = (updateFocus !== false && changed && refreshCalendar === false) || focusDateUsedForRange != updateRange;
|
|
953
946
|
focusDateUsedForRange = updateRange;
|
|
954
947
|
if (updateFocus) {
|
|
@@ -974,7 +967,7 @@
|
|
|
974
967
|
}
|
|
975
968
|
},
|
|
976
969
|
monthOffset: function (monthOffset, refreshCalendar) {
|
|
977
|
-
|
|
970
|
+
const multiMonth = Math.max(settings.multiMonth, 1);
|
|
978
971
|
monthOffset = Math.max(1 - multiMonth, Math.min(0, monthOffset));
|
|
979
972
|
module.set.dataKeyValue(metadata.monthOffset, monthOffset, refreshCalendar);
|
|
980
973
|
},
|
|
@@ -982,8 +975,8 @@
|
|
|
982
975
|
module.set.dataKeyValue(metadata.mode, mode, refreshCalendar);
|
|
983
976
|
},
|
|
984
977
|
dataKeyValue: function (key, value, refreshCalendar) {
|
|
985
|
-
|
|
986
|
-
|
|
978
|
+
const oldValue = $module.data(key);
|
|
979
|
+
const equal = oldValue === value || (oldValue <= value && oldValue >= value); // equality test for dates and string objects
|
|
987
980
|
if (value) {
|
|
988
981
|
$module.data(key, value);
|
|
989
982
|
} else {
|
|
@@ -1000,20 +993,20 @@
|
|
|
1000
993
|
|
|
1001
994
|
selectDate: function (date, forceSet) {
|
|
1002
995
|
module.verbose('New date selection', date);
|
|
1003
|
-
|
|
1004
|
-
|
|
996
|
+
const mode = module.get.mode();
|
|
997
|
+
const complete = forceSet || mode === 'minute'
|
|
1005
998
|
|| (settings.disableMinute && mode === 'hour')
|
|
1006
999
|
|| (settings.type === 'date' && mode === 'day')
|
|
1007
1000
|
|| (settings.type === 'month' && mode === 'month')
|
|
1008
1001
|
|| (settings.type === 'year' && mode === 'year');
|
|
1009
1002
|
if (complete) {
|
|
1010
|
-
|
|
1003
|
+
const canceled = module.set.date(date) === false;
|
|
1011
1004
|
if (!canceled) {
|
|
1012
1005
|
selectionComplete = true;
|
|
1013
1006
|
if (settings.closable) {
|
|
1014
1007
|
module.popup('hide');
|
|
1015
1008
|
// if this is a range calendar, focus the container or input. This will open the popup from its event listeners.
|
|
1016
|
-
|
|
1009
|
+
const endModule = module.get.calendarModule(settings.endCalendar);
|
|
1017
1010
|
if (endModule) {
|
|
1018
1011
|
endModule.refresh();
|
|
1019
1012
|
if (endModule.setting('on') !== 'focus') {
|
|
@@ -1024,7 +1017,7 @@
|
|
|
1024
1017
|
}
|
|
1025
1018
|
}
|
|
1026
1019
|
} else {
|
|
1027
|
-
|
|
1020
|
+
const newMode = mode === 'year'
|
|
1028
1021
|
? (!settings.disableMonth ? 'month' : 'day')
|
|
1029
1022
|
: (mode === 'month'
|
|
1030
1023
|
? 'day'
|
|
@@ -1047,8 +1040,8 @@
|
|
|
1047
1040
|
module.set.date();
|
|
1048
1041
|
},
|
|
1049
1042
|
|
|
1050
|
-
popup: function () {
|
|
1051
|
-
return $activator.popup
|
|
1043
|
+
popup: function (...args) {
|
|
1044
|
+
return $activator.popup(...args);
|
|
1052
1045
|
},
|
|
1053
1046
|
|
|
1054
1047
|
focus: function () {
|
|
@@ -1075,17 +1068,17 @@
|
|
|
1075
1068
|
return format.call(module, date, settings);
|
|
1076
1069
|
}
|
|
1077
1070
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1071
|
+
const D = date.getDate();
|
|
1072
|
+
const M = date.getMonth();
|
|
1073
|
+
const Y = date.getFullYear();
|
|
1074
|
+
const d = date.getDay();
|
|
1075
|
+
const H = date.getHours();
|
|
1076
|
+
const m = date.getMinutes();
|
|
1077
|
+
const s = date.getSeconds();
|
|
1078
|
+
const w = module.get.weekOfYear(Y, M, D + 1 - settings.firstDayOfWeek);
|
|
1079
|
+
const h = H % 12 || 12;
|
|
1080
|
+
const a = H < 12 ? settings.text.am.toLowerCase() : settings.text.pm.toLowerCase();
|
|
1081
|
+
const tokens = {
|
|
1089
1082
|
D: D,
|
|
1090
1083
|
DD: ('0' + D).slice(-2),
|
|
1091
1084
|
M: M + 1,
|
|
@@ -1122,8 +1115,7 @@
|
|
|
1122
1115
|
return match.slice(1, -1);
|
|
1123
1116
|
});
|
|
1124
1117
|
},
|
|
1125
|
-
dateObjectOrFormatted: function (format, date) {
|
|
1126
|
-
format = format || '';
|
|
1118
|
+
dateObjectOrFormatted: function (format = '', date = null) {
|
|
1127
1119
|
date = module.helper.sanitiseDate(date) || null;
|
|
1128
1120
|
|
|
1129
1121
|
if (!date) {
|
|
@@ -1137,7 +1129,7 @@
|
|
|
1137
1129
|
return module.helper.dateFormat(format, date);
|
|
1138
1130
|
},
|
|
1139
1131
|
isDisabled: function (date, mode) {
|
|
1140
|
-
return (mode === 'day' || mode === 'month' || mode === 'year' || mode === 'hour') && (((mode === 'day' && settings.disabledDaysOfWeek.
|
|
1132
|
+
return (mode === 'day' || mode === 'month' || mode === 'year' || mode === 'hour') && (((mode === 'day' && settings.disabledDaysOfWeek.includes(date.getDay())) || settings.disabledDates.some(function (d) {
|
|
1141
1133
|
let blocked = false;
|
|
1142
1134
|
|
|
1143
1135
|
if (typeof d === 'string') {
|
|
@@ -1150,15 +1142,15 @@
|
|
|
1150
1142
|
if (typeof d[metadata.year] === 'number') {
|
|
1151
1143
|
blocked = date.getFullYear() === d[metadata.year];
|
|
1152
1144
|
} else if (Array.isArray(d[metadata.year])) {
|
|
1153
|
-
blocked = d[metadata.year].
|
|
1145
|
+
blocked = d[metadata.year].includes(date.getFullYear());
|
|
1154
1146
|
}
|
|
1155
1147
|
} else if (d[metadata.month]) {
|
|
1156
1148
|
if (typeof d[metadata.month] === 'number') {
|
|
1157
1149
|
blocked = date.getMonth() === d[metadata.month];
|
|
1158
1150
|
} else if (Array.isArray(d[metadata.month])) {
|
|
1159
|
-
blocked = d[metadata.month].
|
|
1151
|
+
blocked = d[metadata.month].includes(date.getMonth());
|
|
1160
1152
|
} else if (d[metadata.month] instanceof Date) {
|
|
1161
|
-
|
|
1153
|
+
const sdate = module.helper.sanitiseDate(d[metadata.month]);
|
|
1162
1154
|
|
|
1163
1155
|
blocked = (date.getMonth() === sdate.getMonth()) && (date.getFullYear() === sdate.getFullYear());
|
|
1164
1156
|
}
|
|
@@ -1199,7 +1191,7 @@
|
|
|
1199
1191
|
if (typeof d[metadata.days] === 'number') {
|
|
1200
1192
|
blocked = date.getDay() === d[metadata.days];
|
|
1201
1193
|
} else if (Array.isArray(d[metadata.days])) {
|
|
1202
|
-
blocked = d[metadata.days].
|
|
1194
|
+
blocked = d[metadata.days].includes(date.getDay());
|
|
1203
1195
|
}
|
|
1204
1196
|
}
|
|
1205
1197
|
|
|
@@ -1207,7 +1199,7 @@
|
|
|
1207
1199
|
if (typeof d[metadata.hours] === 'number') {
|
|
1208
1200
|
blocked = blocked && date.getHours() === d[metadata.hours];
|
|
1209
1201
|
} else if (Array.isArray(d[metadata.hours])) {
|
|
1210
|
-
blocked = blocked && d[metadata.hours].
|
|
1202
|
+
blocked = blocked && d[metadata.hours].includes(date.getHours());
|
|
1211
1203
|
}
|
|
1212
1204
|
}
|
|
1213
1205
|
}
|
|
@@ -1237,14 +1229,12 @@
|
|
|
1237
1229
|
},
|
|
1238
1230
|
findDayAsObject: function (date, mode, dates) {
|
|
1239
1231
|
if (mode === 'day' || mode === 'month' || mode === 'year') {
|
|
1240
|
-
let d
|
|
1241
|
-
for (let i = 0; i < dates.length; i++) {
|
|
1242
|
-
d = dates[i];
|
|
1232
|
+
for (let d of dates) {
|
|
1243
1233
|
if (typeof d === 'string') {
|
|
1244
1234
|
d = module.helper.sanitiseDate(d);
|
|
1245
1235
|
}
|
|
1246
1236
|
if (d instanceof Date && module.helper.dateEqual(date, d, mode)) {
|
|
1247
|
-
|
|
1237
|
+
const dateObject = {};
|
|
1248
1238
|
dateObject[metadata.date] = d;
|
|
1249
1239
|
|
|
1250
1240
|
return dateObject;
|
|
@@ -1254,21 +1244,19 @@
|
|
|
1254
1244
|
if (typeof d[metadata.year] === 'number' && date.getFullYear() === d[metadata.year]) {
|
|
1255
1245
|
return d;
|
|
1256
1246
|
}
|
|
1257
|
-
if (Array.isArray(d[metadata.year])) {
|
|
1258
|
-
|
|
1259
|
-
return d;
|
|
1260
|
-
}
|
|
1247
|
+
if (Array.isArray(d[metadata.year]) && d[metadata.year].includes(date.getFullYear())) {
|
|
1248
|
+
return d;
|
|
1261
1249
|
}
|
|
1262
1250
|
} else if (d[metadata.month]) {
|
|
1263
1251
|
if (typeof d[metadata.month] === 'number' && date.getMonth() === d[metadata.month]) {
|
|
1264
1252
|
return d;
|
|
1265
1253
|
}
|
|
1266
1254
|
if (Array.isArray(d[metadata.month])) {
|
|
1267
|
-
if (d[metadata.month].
|
|
1255
|
+
if (d[metadata.month].includes(date.getMonth())) {
|
|
1268
1256
|
return d;
|
|
1269
1257
|
}
|
|
1270
1258
|
} else if (d[metadata.month] instanceof Date) {
|
|
1271
|
-
|
|
1259
|
+
const sdate = module.helper.sanitiseDate(d[metadata.month]);
|
|
1272
1260
|
if ((date.getMonth() === sdate.getMonth()) && (date.getFullYear() === sdate.getFullYear())) {
|
|
1273
1261
|
return d;
|
|
1274
1262
|
}
|
|
@@ -1277,12 +1265,10 @@
|
|
|
1277
1265
|
if (d[metadata.date] instanceof Date && module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]), mode)) {
|
|
1278
1266
|
return d;
|
|
1279
1267
|
}
|
|
1280
|
-
if (Array.isArray(d[metadata.date])) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
return d;
|
|
1285
|
-
}
|
|
1268
|
+
if (Array.isArray(d[metadata.date]) && d[metadata.date].some(function (idate) {
|
|
1269
|
+
return module.helper.dateEqual(date, idate, mode);
|
|
1270
|
+
})) {
|
|
1271
|
+
return d;
|
|
1286
1272
|
}
|
|
1287
1273
|
}
|
|
1288
1274
|
}
|
|
@@ -1293,21 +1279,17 @@
|
|
|
1293
1279
|
},
|
|
1294
1280
|
findHourAsObject: function (date, mode, hours) {
|
|
1295
1281
|
if (mode === 'hour') {
|
|
1296
|
-
|
|
1297
|
-
let hourCheck = function (date, d) {
|
|
1282
|
+
const hourCheck = function (date, d) {
|
|
1298
1283
|
if (d[metadata.hours]) {
|
|
1299
1284
|
if (typeof d[metadata.hours] === 'number' && date.getHours() === d[metadata.hours]) {
|
|
1300
1285
|
return d;
|
|
1301
1286
|
}
|
|
1302
|
-
if (Array.isArray(d[metadata.hours])) {
|
|
1303
|
-
|
|
1304
|
-
return d;
|
|
1305
|
-
}
|
|
1287
|
+
if (Array.isArray(d[metadata.hours]) && d[metadata.hours].includes(date.getHours())) {
|
|
1288
|
+
return d;
|
|
1306
1289
|
}
|
|
1307
1290
|
}
|
|
1308
1291
|
};
|
|
1309
|
-
for (
|
|
1310
|
-
d = hours[i];
|
|
1292
|
+
for (const d of hours) {
|
|
1311
1293
|
if (typeof d === 'number' && date.getHours() === d) {
|
|
1312
1294
|
return null;
|
|
1313
1295
|
}
|
|
@@ -1316,21 +1298,17 @@
|
|
|
1316
1298
|
if (typeof d[metadata.days] === 'number' && date.getDay() === d[metadata.days]) {
|
|
1317
1299
|
return d;
|
|
1318
1300
|
}
|
|
1319
|
-
if (Array.isArray(d[metadata.days])) {
|
|
1320
|
-
|
|
1321
|
-
return d;
|
|
1322
|
-
}
|
|
1301
|
+
if (Array.isArray(d[metadata.days]) && d[metadata.days].includes(date.getDay())) {
|
|
1302
|
+
return d;
|
|
1323
1303
|
}
|
|
1324
1304
|
} else if (d[metadata.date] && hourCheck(date, d)) {
|
|
1325
1305
|
if (d[metadata.date] instanceof Date && module.helper.dateEqual(date, module.helper.sanitiseDate(d[metadata.date]))) {
|
|
1326
1306
|
return d;
|
|
1327
1307
|
}
|
|
1328
|
-
if (Array.isArray(d[metadata.date])) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
return d;
|
|
1333
|
-
}
|
|
1308
|
+
if (Array.isArray(d[metadata.date]) && d[metadata.date].some(function (idate) {
|
|
1309
|
+
return module.helper.dateEqual(date, idate, mode);
|
|
1310
|
+
})) {
|
|
1311
|
+
return d;
|
|
1334
1312
|
}
|
|
1335
1313
|
} else if (hourCheck(date, d)) {
|
|
1336
1314
|
return d;
|
|
@@ -1345,7 +1323,7 @@
|
|
|
1345
1323
|
if (!(date instanceof Date)) {
|
|
1346
1324
|
date = parser.date('' + date, settings);
|
|
1347
1325
|
}
|
|
1348
|
-
if (!date || isNaN(date.getTime())) {
|
|
1326
|
+
if (!date || Number.isNaN(date.getTime())) {
|
|
1349
1327
|
return null;
|
|
1350
1328
|
}
|
|
1351
1329
|
|
|
@@ -1356,11 +1334,11 @@
|
|
|
1356
1334
|
mode = 'day';
|
|
1357
1335
|
}
|
|
1358
1336
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1337
|
+
const isTimeOnly = settings.type === 'time';
|
|
1338
|
+
const isYear = mode === 'year';
|
|
1339
|
+
const isYearOrMonth = isYear || mode === 'month';
|
|
1340
|
+
const isMinute = mode === 'minute';
|
|
1341
|
+
const isHourOrMinute = isMinute || mode === 'hour';
|
|
1364
1342
|
// only care about a minute accuracy of settings.minTimeGap
|
|
1365
1343
|
date1 = new Date(
|
|
1366
1344
|
isTimeOnly ? 2000 : date1.getFullYear(),
|
|
@@ -1384,7 +1362,7 @@
|
|
|
1384
1362
|
},
|
|
1385
1363
|
isDateInRange: function (date, mode, minDate, maxDate) {
|
|
1386
1364
|
if (!minDate && !maxDate) {
|
|
1387
|
-
|
|
1365
|
+
const startDate = module.get.startDate();
|
|
1388
1366
|
minDate = startDate && settings.minDate ? new Date(Math.max(startDate, settings.minDate)) : startDate || settings.minDate;
|
|
1389
1367
|
maxDate = settings.maxDate;
|
|
1390
1368
|
}
|
|
@@ -1396,12 +1374,12 @@
|
|
|
1396
1374
|
},
|
|
1397
1375
|
dateInRange: function (date, minDate, maxDate) {
|
|
1398
1376
|
if (!minDate && !maxDate) {
|
|
1399
|
-
|
|
1377
|
+
const startDate = module.get.startDate();
|
|
1400
1378
|
minDate = startDate && settings.minDate ? new Date(Math.max(startDate, settings.minDate)) : startDate || settings.minDate;
|
|
1401
1379
|
maxDate = settings.maxDate;
|
|
1402
1380
|
}
|
|
1403
1381
|
minDate = minDate && new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate(), minDate.getHours(), settings.minTimeGap * Math.ceil(minDate.getMinutes() / settings.minTimeGap));
|
|
1404
|
-
|
|
1382
|
+
const isTimeOnly = settings.type === 'time';
|
|
1405
1383
|
|
|
1406
1384
|
return !date
|
|
1407
1385
|
? date
|
|
@@ -1444,30 +1422,30 @@
|
|
|
1444
1422
|
return module[name];
|
|
1445
1423
|
}
|
|
1446
1424
|
},
|
|
1447
|
-
debug: function () {
|
|
1425
|
+
debug: function (...args) {
|
|
1448
1426
|
if (!settings.silent && settings.debug) {
|
|
1449
1427
|
if (settings.performance) {
|
|
1450
|
-
module.performance.log(
|
|
1428
|
+
module.performance.log(args);
|
|
1451
1429
|
} else {
|
|
1452
1430
|
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
1453
|
-
module.debug.apply(console,
|
|
1431
|
+
module.debug.apply(console, args);
|
|
1454
1432
|
}
|
|
1455
1433
|
}
|
|
1456
1434
|
},
|
|
1457
|
-
verbose: function () {
|
|
1435
|
+
verbose: function (...args) {
|
|
1458
1436
|
if (!settings.silent && settings.verbose && settings.debug) {
|
|
1459
1437
|
if (settings.performance) {
|
|
1460
|
-
module.performance.log(
|
|
1438
|
+
module.performance.log(args);
|
|
1461
1439
|
} else {
|
|
1462
1440
|
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
1463
|
-
module.verbose.apply(console,
|
|
1441
|
+
module.verbose.apply(console, args);
|
|
1464
1442
|
}
|
|
1465
1443
|
}
|
|
1466
1444
|
},
|
|
1467
|
-
error: function () {
|
|
1445
|
+
error: function (...args) {
|
|
1468
1446
|
if (!settings.silent) {
|
|
1469
1447
|
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
|
1470
|
-
module.error.apply(console,
|
|
1448
|
+
module.error.apply(console, args);
|
|
1471
1449
|
}
|
|
1472
1450
|
},
|
|
1473
1451
|
performance: {
|
|
@@ -1482,7 +1460,7 @@
|
|
|
1482
1460
|
time = currentTime;
|
|
1483
1461
|
performance.push({
|
|
1484
1462
|
Name: message[0],
|
|
1485
|
-
Arguments:
|
|
1463
|
+
Arguments: message.slice(1),
|
|
1486
1464
|
Element: element,
|
|
1487
1465
|
'Execution Time': executionTime,
|
|
1488
1466
|
});
|
|
@@ -1503,30 +1481,22 @@
|
|
|
1503
1481
|
title += ' ' + totalTime + 'ms';
|
|
1504
1482
|
if (performance.length > 0) {
|
|
1505
1483
|
console.groupCollapsed(title);
|
|
1506
|
-
|
|
1507
|
-
console.table(performance);
|
|
1508
|
-
} else {
|
|
1509
|
-
$.each(performance, function (index, data) {
|
|
1510
|
-
console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
|
|
1511
|
-
});
|
|
1512
|
-
}
|
|
1484
|
+
console.table(performance);
|
|
1513
1485
|
console.groupEnd();
|
|
1514
1486
|
}
|
|
1515
1487
|
performance = [];
|
|
1516
1488
|
},
|
|
1517
1489
|
},
|
|
1518
|
-
invoke: function (query, passedArguments, context) {
|
|
1490
|
+
invoke: function (query, passedArguments = queryArguments, context = element) {
|
|
1519
1491
|
let object = instance;
|
|
1520
1492
|
let maxDepth;
|
|
1521
1493
|
let found;
|
|
1522
1494
|
let response;
|
|
1523
|
-
passedArguments = passedArguments || queryArguments;
|
|
1524
|
-
context = context || element;
|
|
1525
1495
|
if (typeof query === 'string' && object !== undefined) {
|
|
1526
1496
|
query = query.split(/[ .]/);
|
|
1527
1497
|
maxDepth = query.length - 1;
|
|
1528
1498
|
$.each(query, function (depth, value) {
|
|
1529
|
-
|
|
1499
|
+
const camelCaseValue = depth !== maxDepth
|
|
1530
1500
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
1531
1501
|
: query;
|
|
1532
1502
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
@@ -1569,7 +1539,7 @@
|
|
|
1569
1539
|
if (instance === undefined) {
|
|
1570
1540
|
module.initialize();
|
|
1571
1541
|
}
|
|
1572
|
-
module.invoke(
|
|
1542
|
+
module.invoke(parameters);
|
|
1573
1543
|
} else {
|
|
1574
1544
|
if (instance !== undefined) {
|
|
1575
1545
|
instance.invoke('destroy');
|
|
@@ -1650,7 +1620,7 @@
|
|
|
1650
1620
|
|
|
1651
1621
|
formatter: {
|
|
1652
1622
|
yearHeader: function (date, settings) {
|
|
1653
|
-
|
|
1623
|
+
const decadeYear = Math.ceil(date.getFullYear() / 10) * 10;
|
|
1654
1624
|
|
|
1655
1625
|
return (decadeYear - 9) + ' - ' + (decadeYear + 2);
|
|
1656
1626
|
},
|
|
@@ -1691,10 +1661,10 @@
|
|
|
1691
1661
|
}
|
|
1692
1662
|
// Reverse date and month in some cases
|
|
1693
1663
|
text = settings.monthFirst || !/^\d{1,2}[./-]/.test(text) ? text : text.replace(/[./-]/g, '/').replace(/(\d+)\/(\d+)/, '$2/$1');
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
if (!isShortYear && !numberOnly && !isNaN(textDate.getDate())) {
|
|
1664
|
+
const textDate = new Date(text);
|
|
1665
|
+
const numberOnly = text.match(/^\d+$/) !== null;
|
|
1666
|
+
const isShortYear = text.match(/^(?:\d{1,2}[./-]){2}\d{1,2}$/) !== null;
|
|
1667
|
+
if (!isShortYear && !numberOnly && !Number.isNaN(textDate.getDate())) {
|
|
1698
1668
|
return textDate;
|
|
1699
1669
|
}
|
|
1700
1670
|
text = text.toLowerCase();
|
|
@@ -1709,12 +1679,11 @@
|
|
|
1709
1679
|
let year = -1;
|
|
1710
1680
|
let isAm;
|
|
1711
1681
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1682
|
+
const isTimeOnly = settings.type === 'time';
|
|
1683
|
+
const isDateOnly = !settings.type.includes('time');
|
|
1714
1684
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
let numbers = text.split(settings.regExp.dateNumbers);
|
|
1685
|
+
const words = text.split(settings.regExp.dateWords);
|
|
1686
|
+
const numbers = text.split(settings.regExp.dateNumbers);
|
|
1718
1687
|
let number;
|
|
1719
1688
|
|
|
1720
1689
|
let parts;
|
|
@@ -1722,19 +1691,19 @@
|
|
|
1722
1691
|
|
|
1723
1692
|
if (!isDateOnly) {
|
|
1724
1693
|
// am/pm
|
|
1725
|
-
isAm =
|
|
1694
|
+
isAm = words.includes(settings.text.am.toLowerCase())
|
|
1726
1695
|
? true
|
|
1727
|
-
: (
|
|
1696
|
+
: (words.includes(settings.text.pm.toLowerCase()) ? false : undefined);
|
|
1728
1697
|
|
|
1729
1698
|
// time with ':'
|
|
1730
1699
|
for (i = 0; i < numbers.length; i++) {
|
|
1731
1700
|
number = numbers[i];
|
|
1732
|
-
if (number.
|
|
1701
|
+
if (number.includes(':')) {
|
|
1733
1702
|
if (hour < 0 || minute < 0) {
|
|
1734
1703
|
parts = number.split(':');
|
|
1735
1704
|
for (k = 0; k < Math.min(2, parts.length); k++) {
|
|
1736
|
-
j = parseInt(parts[k], 10);
|
|
1737
|
-
if (isNaN(j)) {
|
|
1705
|
+
j = Number.parseInt(parts[k], 10);
|
|
1706
|
+
if (Number.isNaN(j)) {
|
|
1738
1707
|
j = 0;
|
|
1739
1708
|
}
|
|
1740
1709
|
if (k === 0) {
|
|
@@ -1751,32 +1720,27 @@
|
|
|
1751
1720
|
|
|
1752
1721
|
if (!isTimeOnly) {
|
|
1753
1722
|
// textual month
|
|
1754
|
-
for (
|
|
1755
|
-
word
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
monthString = monthString.slice(0, word.length).toLowerCase();
|
|
1762
|
-
if (monthString === word) {
|
|
1763
|
-
month = j + 1;
|
|
1723
|
+
for (const word of words) {
|
|
1724
|
+
if (word.length > 0) {
|
|
1725
|
+
for (j = 0; j < settings.text.months.length; j++) {
|
|
1726
|
+
monthString = settings.text.months[j];
|
|
1727
|
+
monthString = monthString.slice(0, word.length).toLowerCase();
|
|
1728
|
+
if (monthString === word) {
|
|
1729
|
+
month = j + 1;
|
|
1764
1730
|
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (month >= 0) {
|
|
1765
1735
|
break;
|
|
1766
1736
|
}
|
|
1767
1737
|
}
|
|
1768
|
-
if (month >= 0) {
|
|
1769
|
-
break;
|
|
1770
|
-
}
|
|
1771
1738
|
}
|
|
1772
1739
|
|
|
1773
1740
|
// year > settings.centuryBreak
|
|
1774
1741
|
for (i = 0; i < numbers.length; i++) {
|
|
1775
|
-
j = parseInt(numbers[i], 10);
|
|
1776
|
-
if (isNaN(j)) {
|
|
1777
|
-
continue;
|
|
1778
|
-
}
|
|
1779
|
-
if (j >= settings.centuryBreak && i === numbers.length - 1) {
|
|
1742
|
+
j = Number.parseInt(numbers[i], 10);
|
|
1743
|
+
if (!Number.isNaN(j) && j >= settings.centuryBreak && i === numbers.length - 1) {
|
|
1780
1744
|
if (j <= 99) {
|
|
1781
1745
|
j += settings.currentCentury - 100;
|
|
1782
1746
|
}
|
|
@@ -1793,11 +1757,8 @@
|
|
|
1793
1757
|
k = i > 1 || settings.monthFirst
|
|
1794
1758
|
? i
|
|
1795
1759
|
: (i === 1 ? 0 : 1);
|
|
1796
|
-
j = parseInt(numbers[k], 10);
|
|
1797
|
-
if (isNaN(j)) {
|
|
1798
|
-
continue;
|
|
1799
|
-
}
|
|
1800
|
-
if (j >= 1 && j <= 12) {
|
|
1760
|
+
j = Number.parseInt(numbers[k], 10);
|
|
1761
|
+
if (!Number.isNaN(j) && j >= 1 && j <= 12) {
|
|
1801
1762
|
month = j;
|
|
1802
1763
|
numbers.splice(k, 1);
|
|
1803
1764
|
|
|
@@ -1808,11 +1769,8 @@
|
|
|
1808
1769
|
|
|
1809
1770
|
// day
|
|
1810
1771
|
for (i = 0; i < numbers.length; i++) {
|
|
1811
|
-
j = parseInt(numbers[i], 10);
|
|
1812
|
-
if (isNaN(j)) {
|
|
1813
|
-
continue;
|
|
1814
|
-
}
|
|
1815
|
-
if (j >= 1 && j <= 31) {
|
|
1772
|
+
j = Number.parseInt(numbers[i], 10);
|
|
1773
|
+
if (!Number.isNaN(j) && j >= 1 && j <= 31) {
|
|
1816
1774
|
day = j;
|
|
1817
1775
|
numbers.splice(i, 1);
|
|
1818
1776
|
|
|
@@ -1823,17 +1781,16 @@
|
|
|
1823
1781
|
// year <= settings.centuryBreak
|
|
1824
1782
|
if (year < 0) {
|
|
1825
1783
|
for (i = numbers.length - 1; i >= 0; i--) {
|
|
1826
|
-
j = parseInt(numbers[i], 10);
|
|
1827
|
-
if (isNaN(j)) {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
year = j;
|
|
1834
|
-
numbers.splice(i, 1);
|
|
1784
|
+
j = Number.parseInt(numbers[i], 10);
|
|
1785
|
+
if (!Number.isNaN(j)) {
|
|
1786
|
+
if (j <= 99) {
|
|
1787
|
+
j += settings.currentCentury;
|
|
1788
|
+
}
|
|
1789
|
+
year = j;
|
|
1790
|
+
numbers.splice(i, 1);
|
|
1835
1791
|
|
|
1836
|
-
|
|
1792
|
+
break;
|
|
1793
|
+
}
|
|
1837
1794
|
}
|
|
1838
1795
|
}
|
|
1839
1796
|
}
|
|
@@ -1842,11 +1799,8 @@
|
|
|
1842
1799
|
// hour
|
|
1843
1800
|
if (hour < 0) {
|
|
1844
1801
|
for (i = 0; i < numbers.length; i++) {
|
|
1845
|
-
j = parseInt(numbers[i], 10);
|
|
1846
|
-
if (isNaN(j)) {
|
|
1847
|
-
continue;
|
|
1848
|
-
}
|
|
1849
|
-
if (j >= 0 && j <= 23) {
|
|
1802
|
+
j = Number.parseInt(numbers[i], 10);
|
|
1803
|
+
if (!Number.isNaN(j) && j >= 0 && j <= 23) {
|
|
1850
1804
|
hour = j;
|
|
1851
1805
|
numbers.splice(i, 1);
|
|
1852
1806
|
|
|
@@ -1858,11 +1812,8 @@
|
|
|
1858
1812
|
// minute
|
|
1859
1813
|
if (minute < 0) {
|
|
1860
1814
|
for (i = 0; i < numbers.length; i++) {
|
|
1861
|
-
j = parseInt(numbers[i], 10);
|
|
1862
|
-
if (isNaN(j)) {
|
|
1863
|
-
continue;
|
|
1864
|
-
}
|
|
1865
|
-
if (j >= 0 && j <= 59) {
|
|
1815
|
+
j = Number.parseInt(numbers[i], 10);
|
|
1816
|
+
if (!Number.isNaN(j) && j >= 0 && j <= 59) {
|
|
1866
1817
|
minute = j;
|
|
1867
1818
|
numbers.splice(i, 1);
|
|
1868
1819
|
|
|
@@ -1908,7 +1859,7 @@
|
|
|
1908
1859
|
date = new Date(year, month, 0, hour, minute);
|
|
1909
1860
|
}
|
|
1910
1861
|
|
|
1911
|
-
return isNaN(date.getTime()) ? null : date;
|
|
1862
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
1912
1863
|
},
|
|
1913
1864
|
},
|
|
1914
1865
|
|