@ohos-ports/flowbite-datepicker 2.0.0-beta.0
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/.eslintignore +2 -0
- package/.eslintrc.js +73 -0
- package/.stylelintrc +12 -0
- package/CHANGELOG.md +72 -0
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/demo/index.html +582 -0
- package/demo/live-demo.js +471 -0
- package/dist/DateRangePicker.cjs.js +2996 -0
- package/dist/DateRangePicker.esm.js +2994 -0
- package/dist/DateRangePicker.umd.js +3002 -0
- package/dist/Datepicker.cjs.js +2778 -0
- package/dist/Datepicker.esm.js +2776 -0
- package/dist/Datepicker.umd.js +2784 -0
- package/dist/css/datepicker-bs4.css +276 -0
- package/dist/css/datepicker-bs4.min.css +1 -0
- package/dist/css/datepicker-bs5.css +276 -0
- package/dist/css/datepicker-bs5.min.css +1 -0
- package/dist/css/datepicker-bulma.css +258 -0
- package/dist/css/datepicker-bulma.min.css +1 -0
- package/dist/css/datepicker-foundation.css +262 -0
- package/dist/css/datepicker-foundation.min.css +1 -0
- package/dist/css/datepicker.css +306 -0
- package/dist/css/datepicker.min.css +1403 -0
- package/dist/js/datepicker-full.js +2777 -0
- package/dist/js/datepicker-full.min.js +1 -0
- package/dist/js/datepicker.js +2569 -0
- package/dist/js/datepicker.min.js +1 -0
- package/dist/js/locales/ar-tn.js +15 -0
- package/dist/js/locales/ar.js +15 -0
- package/dist/js/locales/az.js +14 -0
- package/dist/js/locales/bg.js +14 -0
- package/dist/js/locales/bm.js +18 -0
- package/dist/js/locales/bn.js +19 -0
- package/dist/js/locales/br.js +18 -0
- package/dist/js/locales/bs.js +15 -0
- package/dist/js/locales/ca.js +18 -0
- package/dist/js/locales/cs.js +19 -0
- package/dist/js/locales/cy.js +14 -0
- package/dist/js/locales/da.js +19 -0
- package/dist/js/locales/de.js +18 -0
- package/dist/js/locales/el.js +16 -0
- package/dist/js/locales/en-AU.js +18 -0
- package/dist/js/locales/en-CA.js +18 -0
- package/dist/js/locales/en-GB.js +18 -0
- package/dist/js/locales/en-IE.js +17 -0
- package/dist/js/locales/en-NZ.js +17 -0
- package/dist/js/locales/en-ZA.js +17 -0
- package/dist/js/locales/eo.js +17 -0
- package/dist/js/locales/es.js +18 -0
- package/dist/js/locales/et.js +18 -0
- package/dist/js/locales/eu.js +18 -0
- package/dist/js/locales/fa.js +17 -0
- package/dist/js/locales/fi.js +17 -0
- package/dist/js/locales/fo.js +15 -0
- package/dist/js/locales/fr-CH.js +21 -0
- package/dist/js/locales/fr.js +18 -0
- package/dist/js/locales/gl.js +16 -0
- package/dist/js/locales/he.js +15 -0
- package/dist/js/locales/hi.js +18 -0
- package/dist/js/locales/hr.js +13 -0
- package/dist/js/locales/hu.js +18 -0
- package/dist/js/locales/hy.js +18 -0
- package/dist/js/locales/id.js +15 -0
- package/dist/js/locales/is.js +14 -0
- package/dist/js/locales/it-CH.js +20 -0
- package/dist/js/locales/it.js +18 -0
- package/dist/js/locales/ja.js +17 -0
- package/dist/js/locales/ka.js +17 -0
- package/dist/js/locales/kk.js +15 -0
- package/dist/js/locales/km.js +15 -0
- package/dist/js/locales/ko.js +18 -0
- package/dist/js/locales/lt.js +19 -0
- package/dist/js/locales/lv.js +18 -0
- package/dist/js/locales/me.js +17 -0
- package/dist/js/locales/mk.js +15 -0
- package/dist/js/locales/mn.js +17 -0
- package/dist/js/locales/mr.js +18 -0
- package/dist/js/locales/ms.js +15 -0
- package/dist/js/locales/nl-BE.js +18 -0
- package/dist/js/locales/nl.js +18 -0
- package/dist/js/locales/no.js +18 -0
- package/dist/js/locales/oc.js +17 -0
- package/dist/js/locales/pl.js +17 -0
- package/dist/js/locales/pt-BR.js +17 -0
- package/dist/js/locales/pt.js +18 -0
- package/dist/js/locales/ro.js +17 -0
- package/dist/js/locales/ru.js +18 -0
- package/dist/js/locales/si.js +18 -0
- package/dist/js/locales/sk.js +18 -0
- package/dist/js/locales/sl.js +15 -0
- package/dist/js/locales/sq.js +18 -0
- package/dist/js/locales/sr-latn.js +16 -0
- package/dist/js/locales/sr.js +16 -0
- package/dist/js/locales/sv.js +17 -0
- package/dist/js/locales/sw.js +15 -0
- package/dist/js/locales/ta.js +18 -0
- package/dist/js/locales/tg.js +19 -0
- package/dist/js/locales/th.js +14 -0
- package/dist/js/locales/tk.js +18 -0
- package/dist/js/locales/tr.js +17 -0
- package/dist/js/locales/uk.js +17 -0
- package/dist/js/locales/uz-cyrl.js +18 -0
- package/dist/js/locales/uz-latn.js +18 -0
- package/dist/js/locales/vi.js +16 -0
- package/dist/js/locales/zh-CN.js +19 -0
- package/dist/js/locales/zh-TW.js +18 -0
- package/dist/locales/index.cjs.js +1028 -0
- package/dist/locales/index.esm.js +1028 -0
- package/dist/main.cjs.js +2999 -0
- package/dist/main.esm.js +2994 -0
- package/dist/main.umd.js +3005 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +266 -0
- package/docs/_sidebar.md +6 -0
- package/docs/api.md +284 -0
- package/docs/date-string+format.md +90 -0
- package/docs/i18n.md +99 -0
- package/docs/images/datepicker-inline.jpg +0 -0
- package/docs/images/datepicker.jpg +0 -0
- package/docs/images/multidate.jpg +0 -0
- package/docs/images/picker-structure.jpg +0 -0
- package/docs/images/rangepicker.jpg +0 -0
- package/docs/images/view-days.jpg +0 -0
- package/docs/images/view-decades.jpg +0 -0
- package/docs/images/view-months.jpg +0 -0
- package/docs/images/view-years.jpg +0 -0
- package/docs/index.html +26 -0
- package/docs/options.md +354 -0
- package/docs/overview.md +174 -0
- package/extras/twoDigitToFullYear/test/twoDigitToFullYear.js +58 -0
- package/extras/twoDigitToFullYear/twoDigitToFullYear.js +26 -0
- package/js/DateRangePicker.js +210 -0
- package/js/Datepicker.js +487 -0
- package/js/datepicker-full.js +5 -0
- package/js/events/functions.js +48 -0
- package/js/events/inputFieldListeners.js +206 -0
- package/js/events/otherListeners.js +15 -0
- package/js/events/pickerListeners.js +70 -0
- package/js/i18n/base-locales.js +13 -0
- package/js/i18n/locales/ar-tn.js +15 -0
- package/js/i18n/locales/ar.js +15 -0
- package/js/i18n/locales/az.js +14 -0
- package/js/i18n/locales/bg.js +14 -0
- package/js/i18n/locales/bm.js +18 -0
- package/js/i18n/locales/bn.js +19 -0
- package/js/i18n/locales/br.js +18 -0
- package/js/i18n/locales/bs.js +15 -0
- package/js/i18n/locales/ca.js +18 -0
- package/js/i18n/locales/cs.js +19 -0
- package/js/i18n/locales/cy.js +14 -0
- package/js/i18n/locales/da.js +19 -0
- package/js/i18n/locales/de.js +18 -0
- package/js/i18n/locales/el.js +16 -0
- package/js/i18n/locales/en-AU.js +18 -0
- package/js/i18n/locales/en-CA.js +18 -0
- package/js/i18n/locales/en-GB.js +18 -0
- package/js/i18n/locales/en-IE.js +17 -0
- package/js/i18n/locales/en-NZ.js +17 -0
- package/js/i18n/locales/en-ZA.js +17 -0
- package/js/i18n/locales/eo.js +17 -0
- package/js/i18n/locales/es.js +18 -0
- package/js/i18n/locales/et.js +18 -0
- package/js/i18n/locales/eu.js +18 -0
- package/js/i18n/locales/fa.js +17 -0
- package/js/i18n/locales/fi.js +17 -0
- package/js/i18n/locales/fo.js +15 -0
- package/js/i18n/locales/fr-CH.js +21 -0
- package/js/i18n/locales/fr.js +18 -0
- package/js/i18n/locales/gl.js +16 -0
- package/js/i18n/locales/he.js +15 -0
- package/js/i18n/locales/hi.js +18 -0
- package/js/i18n/locales/hr.js +13 -0
- package/js/i18n/locales/hu.js +18 -0
- package/js/i18n/locales/hy.js +18 -0
- package/js/i18n/locales/id.js +15 -0
- package/js/i18n/locales/is.js +14 -0
- package/js/i18n/locales/it-CH.js +20 -0
- package/js/i18n/locales/it.js +18 -0
- package/js/i18n/locales/ja.js +17 -0
- package/js/i18n/locales/ka.js +17 -0
- package/js/i18n/locales/kk.js +15 -0
- package/js/i18n/locales/km.js +15 -0
- package/js/i18n/locales/ko.js +18 -0
- package/js/i18n/locales/lt.js +19 -0
- package/js/i18n/locales/lv.js +18 -0
- package/js/i18n/locales/me.js +17 -0
- package/js/i18n/locales/mk.js +15 -0
- package/js/i18n/locales/mn.js +17 -0
- package/js/i18n/locales/mr.js +18 -0
- package/js/i18n/locales/ms.js +15 -0
- package/js/i18n/locales/nl-BE.js +18 -0
- package/js/i18n/locales/nl.js +18 -0
- package/js/i18n/locales/no.js +18 -0
- package/js/i18n/locales/oc.js +17 -0
- package/js/i18n/locales/pl.js +17 -0
- package/js/i18n/locales/pt-BR.js +17 -0
- package/js/i18n/locales/pt.js +18 -0
- package/js/i18n/locales/ro.js +17 -0
- package/js/i18n/locales/ru.js +18 -0
- package/js/i18n/locales/si.js +18 -0
- package/js/i18n/locales/sk.js +18 -0
- package/js/i18n/locales/sl.js +15 -0
- package/js/i18n/locales/sq.js +18 -0
- package/js/i18n/locales/sr-latn.js +16 -0
- package/js/i18n/locales/sr.js +16 -0
- package/js/i18n/locales/sv.js +17 -0
- package/js/i18n/locales/sw.js +15 -0
- package/js/i18n/locales/ta.js +18 -0
- package/js/i18n/locales/tg.js +19 -0
- package/js/i18n/locales/th.js +14 -0
- package/js/i18n/locales/tk.js +18 -0
- package/js/i18n/locales/tr.js +17 -0
- package/js/i18n/locales/uk.js +17 -0
- package/js/i18n/locales/uz-cyrl.js +18 -0
- package/js/i18n/locales/uz-latn.js +18 -0
- package/js/i18n/locales/vi.js +16 -0
- package/js/i18n/locales/zh-CN.js +19 -0
- package/js/i18n/locales/zh-TW.js +18 -0
- package/js/lib/date-format.js +185 -0
- package/js/lib/date.js +82 -0
- package/js/lib/dom.js +55 -0
- package/js/lib/event.js +68 -0
- package/js/lib/utils.js +61 -0
- package/js/main.js +4 -0
- package/js/options/defaultOptions.js +38 -0
- package/js/options/processOptions.js +263 -0
- package/js/picker/Picker.js +334 -0
- package/js/picker/templates/calendarWeeksTemplate.js +8 -0
- package/js/picker/templates/daysTemplate.js +8 -0
- package/js/picker/templates/pickerTemplate.js +23 -0
- package/js/picker/views/DaysView.js +250 -0
- package/js/picker/views/MonthsView.js +198 -0
- package/js/picker/views/View.js +55 -0
- package/js/picker/views/YearsView.js +170 -0
- package/package.json +81 -0
- package/postcss.config.js +5 -0
- package/rollup.config.js +75 -0
- package/sass/_mixins.scss +12 -0
- package/sass/datepicker-bs4.scss +91 -0
- package/sass/datepicker-bs5.scss +91 -0
- package/sass/datepicker-bulma.scss +69 -0
- package/sass/datepicker-foundation.scss +66 -0
- package/sass/datepicker.scss +436 -0
- package/sass/index-bs4.scss +5 -0
- package/sass/index-bs5.scss +5 -0
- package/sass/index-bulma.scss +6 -0
- package/sass/index-foundation.scss +3 -0
- package/scripts/build-css.js +39 -0
- package/scripts/build-locales.js +57 -0
- package/scripts/convert-bsdp-locales.js +65 -0
- package/scripts/minify-css.js +31 -0
- package/scripts/minify-js.js +17 -0
- package/style.css +10 -0
- package/tailwind.config.js +16 -0
- package/tailwind.css +1389 -0
- package/test/DateRangePicker/DateRangePicker.js +547 -0
- package/test/DateRangePicker/api-methods.js +415 -0
- package/test/DateRangePicker/date-selection.js +472 -0
- package/test/DateRangePicker/options.js +308 -0
- package/test/Datepicker/Datepicker-object.js +236 -0
- package/test/Datepicker/api-methods.js +328 -0
- package/test/_utils/date.js +102 -0
- package/test/_utils/dom.js +70 -0
- package/test/events.js +785 -0
- package/test/inline-mode.js +45 -0
- package/test/keyboard-operation/arrow-down.js +293 -0
- package/test/keyboard-operation/arrow-left.js +255 -0
- package/test/keyboard-operation/arrow-right.js +215 -0
- package/test/keyboard-operation/arrow-up.js +461 -0
- package/test/keyboard-operation/edit-mode.js +458 -0
- package/test/keyboard-operation/keyboard-operation.js +146 -0
- package/test/mouse-operation.js +580 -0
- package/test/options/before-show.js +635 -0
- package/test/options/bulma-datepicker.sublime-workspace +1280 -0
- package/test/options/buttons.js +383 -0
- package/test/options/date-restrictions.js +802 -0
- package/test/options/format.js +281 -0
- package/test/options/multidate.js +380 -0
- package/test/options/options.js +727 -0
- package/test/options/orientation.js +410 -0
- package/test/options/pick-levle+view.js +357 -0
- package/test/test.html +94 -0
- package/test/unit/DateRangePicker.js +192 -0
- package/test/unit/Datepicker.js +307 -0
- package/test/unit/_setup.js +28 -0
- package/test/unit/lib/date-format.js +310 -0
- package/test/unit/lib/date.js +211 -0
- package/test/unit/lib/dom.js +142 -0
- package/test/unit/lib/event.js +207 -0
- package/test/unit/lib/utils.js +135 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
describe('options - orientation', function () {
|
|
2
|
+
const getIntSize = px => Math.round(parseFloat(px));
|
|
3
|
+
const getTopPos = (el, wrap) => el.offsetTop + (wrap ? wrap.offsetTop : 0) + window.scrollY;
|
|
4
|
+
const getLeftPos = (el, wrap) => el.offsetLeft + (wrap ? wrap.offsetLeft : 0) + window.scrollX;
|
|
5
|
+
const getBottomPos = (el, wrap) => getTopPos(el, wrap) + el.offsetHeight;
|
|
6
|
+
const getRightPos = (el, wrap) => getLeftPos(el, wrap) + el.offsetWidth;
|
|
7
|
+
let wrapper;
|
|
8
|
+
let input;
|
|
9
|
+
|
|
10
|
+
beforeEach(function () {
|
|
11
|
+
wrapper = document.createElement('div');
|
|
12
|
+
Object.assign(wrapper.style, {
|
|
13
|
+
boxSizing: 'border-box',
|
|
14
|
+
position: 'fixed',
|
|
15
|
+
top: '50px',
|
|
16
|
+
left: '50px',
|
|
17
|
+
width: '300px',
|
|
18
|
+
paddingTop: '300px',
|
|
19
|
+
});
|
|
20
|
+
input = document.createElement('input');
|
|
21
|
+
wrapper.appendChild(input);
|
|
22
|
+
testContainer.appendChild(wrapper);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(function () {
|
|
26
|
+
domUtils.emptyChildNodes(testContainer);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('"auto" makes the picker show on top left of the input by default', function () {
|
|
30
|
+
const {dp, picker} = createDP(input);
|
|
31
|
+
dp.show();
|
|
32
|
+
|
|
33
|
+
expect(getIntSize(picker.style.top), 'to be close to', getTopPos(input, wrapper) - picker.offsetHeight, 1);
|
|
34
|
+
expect(getIntSize(picker.style.left), 'to be close to', getLeftPos(input, wrapper), 1);
|
|
35
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
36
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
37
|
+
|
|
38
|
+
dp.destroy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('"auto" makes the picker show on top right of the input if computed style of the input has direction: rrl', function () {
|
|
42
|
+
const {dp, picker} = createDP(input);
|
|
43
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
44
|
+
dp.show();
|
|
45
|
+
|
|
46
|
+
expect(getIntSize(picker.style.top), 'to be close to', getTopPos(input, wrapper) - picker.offsetHeight, 1);
|
|
47
|
+
expect(getIntSize(picker.style.left), 'to be close to', getRightPos(input, wrapper) - picker.offsetWidth, 1);
|
|
48
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
49
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
50
|
+
|
|
51
|
+
dp.destroy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('"auto" makes the picker show on bottom of the input if visible space above the input < picker height', function () {
|
|
55
|
+
const {dp, picker} = createDP(input);
|
|
56
|
+
wrapper.style.paddingTop = '0';
|
|
57
|
+
dp.show();
|
|
58
|
+
|
|
59
|
+
expect(getIntSize(picker.style.top), 'to be close to', getBottomPos(input, wrapper), 1);
|
|
60
|
+
expect(getIntSize(picker.style.left), 'to be close to', getLeftPos(input, wrapper), 1);
|
|
61
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
62
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
63
|
+
|
|
64
|
+
dp.hide();
|
|
65
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
66
|
+
dp.show();
|
|
67
|
+
|
|
68
|
+
expect(getIntSize(picker.style.top), 'to be close to', getBottomPos(input, wrapper), 1);
|
|
69
|
+
expect(getIntSize(picker.style.left), 'to be close to', getRightPos(input, wrapper) - picker.offsetWidth, 1);
|
|
70
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
71
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
72
|
+
|
|
73
|
+
dp.destroy();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('"auto" makes the picker move to 10px from document\'s left if picker\'s left < document\'s', function () {
|
|
77
|
+
const {dp, picker} = createDP(input);
|
|
78
|
+
wrapper.style.left = '-40px';
|
|
79
|
+
dp.show();
|
|
80
|
+
|
|
81
|
+
expect(getIntSize(picker.style.left), 'to be', 10);
|
|
82
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
83
|
+
|
|
84
|
+
dp.destroy();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('"auto" makes the picker show on right if picker\'s right edge > document\'s', function () {
|
|
88
|
+
const {dp, picker} = createDP(input);
|
|
89
|
+
Object.assign(wrapper.style, {left: 'auto', right: 0, width: '150px'});
|
|
90
|
+
dp.show();
|
|
91
|
+
|
|
92
|
+
expect(getIntSize(picker.style.left), 'to be close to', getRightPos(input, wrapper) - picker.offsetWidth, 1);
|
|
93
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
94
|
+
|
|
95
|
+
dp.destroy();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('"top" makes the picker show on top of the input regardless of the size of the space above', function () {
|
|
99
|
+
const {dp, picker} = createDP(input, {orientation: 'top'});
|
|
100
|
+
dp.show();
|
|
101
|
+
|
|
102
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
103
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
104
|
+
|
|
105
|
+
dp.hide();
|
|
106
|
+
wrapper.style.paddingTop = '0';
|
|
107
|
+
dp.show();
|
|
108
|
+
|
|
109
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
110
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
111
|
+
|
|
112
|
+
dp.hide();
|
|
113
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
114
|
+
dp.show();
|
|
115
|
+
|
|
116
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
117
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
118
|
+
|
|
119
|
+
dp.destroy();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('"bottom" makes the picker show on bottom of the input regardless of the size of the space below', function () {
|
|
123
|
+
wrapper.style.paddingTop = '0';
|
|
124
|
+
|
|
125
|
+
const {dp, picker} = createDP(input, {orientation: 'bottom'});
|
|
126
|
+
dp.show();
|
|
127
|
+
|
|
128
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
129
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
130
|
+
|
|
131
|
+
dp.hide();
|
|
132
|
+
Object.assign(wrapper.style, {top: 'auto', bottom: '0'});
|
|
133
|
+
dp.show();
|
|
134
|
+
|
|
135
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
136
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
137
|
+
|
|
138
|
+
dp.hide();
|
|
139
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
140
|
+
dp.show();
|
|
141
|
+
|
|
142
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
143
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
144
|
+
|
|
145
|
+
dp.destroy();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('"left" makes the picker show on left of the input regardless of the direction of the input', function () {
|
|
149
|
+
const {dp, picker} = createDP(input, {orientation: 'left'});
|
|
150
|
+
dp.show();
|
|
151
|
+
|
|
152
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
153
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
154
|
+
|
|
155
|
+
dp.hide();
|
|
156
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
157
|
+
dp.show();
|
|
158
|
+
|
|
159
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
160
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
161
|
+
|
|
162
|
+
dp.destroy();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('"right" makes the picker show on right of the input regardless of the direction of the input', function () {
|
|
166
|
+
const {dp, picker} = createDP(input, {orientation: 'right'});
|
|
167
|
+
dp.show();
|
|
168
|
+
|
|
169
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
170
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
171
|
+
|
|
172
|
+
dp.hide();
|
|
173
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
174
|
+
dp.show();
|
|
175
|
+
|
|
176
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
177
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
178
|
+
|
|
179
|
+
dp.destroy();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('"top left" makes the picker always show on top left of the input', function () {
|
|
183
|
+
wrapper.style.paddingTop = '0';
|
|
184
|
+
|
|
185
|
+
const {dp, picker} = createDP(input, {orientation: 'top left'});
|
|
186
|
+
dp.show();
|
|
187
|
+
|
|
188
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
189
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
190
|
+
|
|
191
|
+
dp.hide();
|
|
192
|
+
Object.assign(wrapper.style, {top: 'auto', bottom: '0'});
|
|
193
|
+
dp.show();
|
|
194
|
+
|
|
195
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
196
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
197
|
+
|
|
198
|
+
dp.hide();
|
|
199
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
200
|
+
dp.show();
|
|
201
|
+
|
|
202
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
203
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
204
|
+
|
|
205
|
+
dp.hide();
|
|
206
|
+
Object.assign(wrapper.style, {top: '0', bottom: ''});
|
|
207
|
+
dp.show();
|
|
208
|
+
|
|
209
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
210
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
211
|
+
|
|
212
|
+
dp.destroy();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('"top right" makes the picker always show on top right of the input', function () {
|
|
216
|
+
wrapper.style.paddingTop = '0';
|
|
217
|
+
|
|
218
|
+
const {dp, picker} = createDP(input, {orientation: 'top right'});
|
|
219
|
+
dp.show();
|
|
220
|
+
|
|
221
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
222
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
223
|
+
|
|
224
|
+
dp.hide();
|
|
225
|
+
Object.assign(wrapper.style, {top: 'auto', bottom: '0'});
|
|
226
|
+
dp.show();
|
|
227
|
+
|
|
228
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
229
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
230
|
+
|
|
231
|
+
dp.hide();
|
|
232
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
233
|
+
dp.show();
|
|
234
|
+
|
|
235
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
236
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
237
|
+
|
|
238
|
+
dp.hide();
|
|
239
|
+
Object.assign(wrapper.style, {top: '0', bottom: ''});
|
|
240
|
+
dp.show();
|
|
241
|
+
|
|
242
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
243
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
244
|
+
|
|
245
|
+
dp.destroy();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('"bottom left" makes the picker always show on bottom left of the input', function () {
|
|
249
|
+
wrapper.style.paddingTop = '0';
|
|
250
|
+
|
|
251
|
+
const {dp, picker} = createDP(input, {orientation: 'bottom left'});
|
|
252
|
+
dp.show();
|
|
253
|
+
|
|
254
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
255
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
256
|
+
|
|
257
|
+
dp.hide();
|
|
258
|
+
Object.assign(wrapper.style, {top: 'auto', bottom: '0'});
|
|
259
|
+
dp.show();
|
|
260
|
+
|
|
261
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
262
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
263
|
+
|
|
264
|
+
dp.hide();
|
|
265
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
266
|
+
dp.show();
|
|
267
|
+
|
|
268
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
269
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
270
|
+
|
|
271
|
+
dp.hide();
|
|
272
|
+
Object.assign(wrapper.style, {top: '0', bottom: ''});
|
|
273
|
+
dp.show();
|
|
274
|
+
|
|
275
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
276
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
277
|
+
|
|
278
|
+
dp.destroy();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('"bottom right" makes the picker always show on bottom right of the input', function () {
|
|
282
|
+
wrapper.style.paddingTop = '0';
|
|
283
|
+
|
|
284
|
+
const {dp, picker} = createDP(input, {orientation: 'bottom right'});
|
|
285
|
+
dp.show();
|
|
286
|
+
|
|
287
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
288
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
289
|
+
|
|
290
|
+
dp.hide();
|
|
291
|
+
Object.assign(wrapper.style, {top: 'auto', bottom: '0'});
|
|
292
|
+
dp.show();
|
|
293
|
+
|
|
294
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
295
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
296
|
+
|
|
297
|
+
dp.hide();
|
|
298
|
+
wrapper.setAttribute('dir', 'rtl');
|
|
299
|
+
dp.show();
|
|
300
|
+
|
|
301
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
302
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
303
|
+
|
|
304
|
+
dp.hide();
|
|
305
|
+
Object.assign(wrapper.style, {top: '0', bottom: ''});
|
|
306
|
+
dp.show();
|
|
307
|
+
|
|
308
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
309
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
310
|
+
|
|
311
|
+
dp.destroy();
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('can be updated with setOptions()', function () {
|
|
315
|
+
const {dp, picker} = createDP(input);
|
|
316
|
+
dp.setOptions({orientation: 'right bottom'});
|
|
317
|
+
dp.show();
|
|
318
|
+
|
|
319
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
320
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
321
|
+
|
|
322
|
+
dp.hide();
|
|
323
|
+
dp.setOptions({orientation: 'bottom auto'});
|
|
324
|
+
dp.show();
|
|
325
|
+
|
|
326
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
327
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
328
|
+
|
|
329
|
+
dp.hide();
|
|
330
|
+
dp.setOptions({orientation: 'auto right'});
|
|
331
|
+
dp.show();
|
|
332
|
+
|
|
333
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
334
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
335
|
+
|
|
336
|
+
dp.hide();
|
|
337
|
+
dp.setOptions({orientation: 'auto'});
|
|
338
|
+
dp.show();
|
|
339
|
+
|
|
340
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
341
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
342
|
+
|
|
343
|
+
dp.destroy();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe('with custom container', function () {
|
|
347
|
+
let foo;
|
|
348
|
+
|
|
349
|
+
beforeEach(function () {
|
|
350
|
+
foo = parseHTML('<div id="foo"></div>').firstChild;
|
|
351
|
+
Object.assign(foo.style, {
|
|
352
|
+
boxSizing: 'border-box',
|
|
353
|
+
position: 'fixed',
|
|
354
|
+
top: '20px',
|
|
355
|
+
left: '20px',
|
|
356
|
+
height: '360px',
|
|
357
|
+
overflow: 'auto',
|
|
358
|
+
});
|
|
359
|
+
Object.assign(wrapper.style, {position: '', top: '', left: ''});
|
|
360
|
+
testContainer.replaceChild(foo, wrapper);
|
|
361
|
+
foo.appendChild(wrapper);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('makes the picker\'s position relative to the container', function () {
|
|
365
|
+
const {dp, picker} = createDP(input, {container: '#foo'});
|
|
366
|
+
dp.show();
|
|
367
|
+
|
|
368
|
+
expect(getIntSize(picker.style.top), 'to be', input.offsetTop - picker.offsetHeight);
|
|
369
|
+
expect(getIntSize(picker.style.left), 'to be', input.offsetLeft);
|
|
370
|
+
expect(picker.classList.contains('datepicker-orient-top'), 'to be true');
|
|
371
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
372
|
+
|
|
373
|
+
dp.hide();
|
|
374
|
+
wrapper.style.paddingBottom = '200px';
|
|
375
|
+
foo.scrollTop = 100;
|
|
376
|
+
dp.show();
|
|
377
|
+
|
|
378
|
+
expect(getIntSize(picker.style.top), 'to be', input.offsetTop + input.offsetHeight);
|
|
379
|
+
expect(getIntSize(picker.style.left), 'to be', input.offsetLeft);
|
|
380
|
+
expect(picker.classList.contains('datepicker-orient-bottom'), 'to be true');
|
|
381
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
382
|
+
|
|
383
|
+
foo.scrollTop = 0;
|
|
384
|
+
wrapper.style.paddingBottom = '';
|
|
385
|
+
dp.destroy();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('"auto" makes the picker move to 10px from container\'s left if picker\'s left < container\'s', function () {
|
|
389
|
+
const {dp, picker} = createDP(input, {container: '#foo'});
|
|
390
|
+
wrapper.style.marginLeft = '-40px';
|
|
391
|
+
dp.show();
|
|
392
|
+
|
|
393
|
+
expect(getIntSize(picker.style.left), 'to be', 10);
|
|
394
|
+
expect(picker.classList.contains('datepicker-orient-left'), 'to be true');
|
|
395
|
+
|
|
396
|
+
dp.destroy();
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('"auto" makes the picker show on right if picker\'s right edge < container\'s', function () {
|
|
400
|
+
const {dp, picker} = createDP(input, {container: '#foo'});
|
|
401
|
+
wrapper.style.width = '150px';
|
|
402
|
+
dp.show();
|
|
403
|
+
|
|
404
|
+
expect(getIntSize(picker.style.left), 'to be', input.offsetLeft + input.offsetWidth - picker.offsetWidth);
|
|
405
|
+
expect(picker.classList.contains('datepicker-orient-right'), 'to be true');
|
|
406
|
+
|
|
407
|
+
dp.destroy();
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
});
|