@xenknight/framework7 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +32 -0
- package/components/accordion/accordion-ios.less +2 -0
- package/components/accordion/accordion-md.less +2 -0
- package/components/accordion/accordion-rtl.css +1 -0
- package/components/accordion/accordion-vars.less +0 -0
- package/components/accordion/accordion.css +1 -0
- package/components/accordion/accordion.d.ts +55 -0
- package/components/accordion/accordion.js +118 -0
- package/components/accordion/accordion.less +215 -0
- package/components/actions/actions-class.js +325 -0
- package/components/actions/actions-ios.less +51 -0
- package/components/actions/actions-md.less +24 -0
- package/components/actions/actions-rtl.css +1 -0
- package/components/actions/actions-vars.less +72 -0
- package/components/actions/actions.css +1 -0
- package/components/actions/actions.d.ts +164 -0
- package/components/actions/actions.js +47 -0
- package/components/actions/actions.less +182 -0
- package/components/app/app-class.d.ts +189 -0
- package/components/app/app-class.js +349 -0
- package/components/app/app-ios.less +23 -0
- package/components/app/app-md.less +8 -0
- package/components/app/app-vars.less +122 -0
- package/components/app/app.less +121 -0
- package/components/app/load-module.js +125 -0
- package/components/area-chart/area-chart-class.js +467 -0
- package/components/area-chart/area-chart-ios.less +2 -0
- package/components/area-chart/area-chart-md.less +2 -0
- package/components/area-chart/area-chart-rtl.css +1 -0
- package/components/area-chart/area-chart-vars.less +35 -0
- package/components/area-chart/area-chart.css +1 -0
- package/components/area-chart/area-chart.d.ts +128 -0
- package/components/area-chart/area-chart.js +44 -0
- package/components/area-chart/area-chart.less +131 -0
- package/components/autocomplete/autocomplete-class.js +813 -0
- package/components/autocomplete/autocomplete-ios.less +9 -0
- package/components/autocomplete/autocomplete-md.less +30 -0
- package/components/autocomplete/autocomplete-rtl.css +1 -0
- package/components/autocomplete/autocomplete-vars.less +36 -0
- package/components/autocomplete/autocomplete.css +1 -0
- package/components/autocomplete/autocomplete.d.ts +193 -0
- package/components/autocomplete/autocomplete.js +81 -0
- package/components/autocomplete/autocomplete.less +102 -0
- package/components/badge/badge-ios.less +2 -0
- package/components/badge/badge-md.less +2 -0
- package/components/badge/badge-vars.less +18 -0
- package/components/badge/badge.d.ts +14 -0
- package/components/badge/badge.js +3 -0
- package/components/badge/badge.less +45 -0
- package/components/block/block-ios.less +2 -0
- package/components/block/block-md.less +2 -0
- package/components/block/block-vars.less +77 -0
- package/components/block/block.d.ts +14 -0
- package/components/block/block.js +3 -0
- package/components/block/block.less +209 -0
- package/components/breadcrumbs/breadcrumbs-ios.less +2 -0
- package/components/breadcrumbs/breadcrumbs-md.less +2 -0
- package/components/breadcrumbs/breadcrumbs-rtl.css +1 -0
- package/components/breadcrumbs/breadcrumbs-vars.less +52 -0
- package/components/breadcrumbs/breadcrumbs.css +1 -0
- package/components/breadcrumbs/breadcrumbs.d.ts +15 -0
- package/components/breadcrumbs/breadcrumbs.js +11 -0
- package/components/breadcrumbs/breadcrumbs.less +91 -0
- package/components/button/button-ios.less +21 -0
- package/components/button/button-md.less +11 -0
- package/components/button/button-vars.less +114 -0
- package/components/button/button.d.ts +14 -0
- package/components/button/button.js +3 -0
- package/components/button/button.less +421 -0
- package/components/calendar/calendar-class.js +1872 -0
- package/components/calendar/calendar-ios.less +2 -0
- package/components/calendar/calendar-md.less +2 -0
- package/components/calendar/calendar-rtl.css +1 -0
- package/components/calendar/calendar-vars.less +108 -0
- package/components/calendar/calendar.css +1 -0
- package/components/calendar/calendar.d.ts +312 -0
- package/components/calendar/calendar.js +118 -0
- package/components/calendar/calendar.less +448 -0
- package/components/card/card-ios.less +2 -0
- package/components/card/card-md.less +2 -0
- package/components/card/card-rtl.css +1 -0
- package/components/card/card-vars.less +80 -0
- package/components/card/card.css +1 -0
- package/components/card/card.d.ts +69 -0
- package/components/card/card.js +504 -0
- package/components/card/card.less +307 -0
- package/components/checkbox/checkbox-ios.less +23 -0
- package/components/checkbox/checkbox-md.less +17 -0
- package/components/checkbox/checkbox-rtl.css +1 -0
- package/components/checkbox/checkbox-vars.less +25 -0
- package/components/checkbox/checkbox.css +1 -0
- package/components/checkbox/checkbox.d.ts +14 -0
- package/components/checkbox/checkbox.js +3 -0
- package/components/checkbox/checkbox.less +155 -0
- package/components/chip/chip-ios.less +25 -0
- package/components/chip/chip-md.less +30 -0
- package/components/chip/chip-rtl.css +1 -0
- package/components/chip/chip-vars.less +42 -0
- package/components/chip/chip.css +1 -0
- package/components/chip/chip.d.ts +14 -0
- package/components/chip/chip.js +3 -0
- package/components/chip/chip.less +106 -0
- package/components/color-picker/color-picker-class.js +871 -0
- package/components/color-picker/color-picker-ios.less +2 -0
- package/components/color-picker/color-picker-md.less +2 -0
- package/components/color-picker/color-picker-rtl.css +1 -0
- package/components/color-picker/color-picker-vars.less +39 -0
- package/components/color-picker/color-picker.css +1 -0
- package/components/color-picker/color-picker.d.ts +233 -0
- package/components/color-picker/color-picker.js +92 -0
- package/components/color-picker/color-picker.less +557 -0
- package/components/color-picker/modules/alpha-slider.js +91 -0
- package/components/color-picker/modules/brightness-slider.js +80 -0
- package/components/color-picker/modules/current-color.js +14 -0
- package/components/color-picker/modules/hex.js +71 -0
- package/components/color-picker/modules/hs-spectrum.js +118 -0
- package/components/color-picker/modules/hsb-sliders.js +191 -0
- package/components/color-picker/modules/hue-slider.js +73 -0
- package/components/color-picker/modules/initial-current-colors.js +43 -0
- package/components/color-picker/modules/palette.js +46 -0
- package/components/color-picker/modules/rgb-bars.js +183 -0
- package/components/color-picker/modules/rgb-sliders.js +185 -0
- package/components/color-picker/modules/sb-spectrum.js +119 -0
- package/components/color-picker/modules/wheel.js +173 -0
- package/components/contacts-list/contacts-list-ios.less +2 -0
- package/components/contacts-list/contacts-list-md.less +21 -0
- package/components/contacts-list/contacts-list-rtl.css +1 -0
- package/components/contacts-list/contacts-list-vars.less +24 -0
- package/components/contacts-list/contacts-list.css +1 -0
- package/components/contacts-list/contacts-list.d.ts +14 -0
- package/components/contacts-list/contacts-list.js +3 -0
- package/components/contacts-list/contacts-list.less +26 -0
- package/components/data-table/data-table-class.js +141 -0
- package/components/data-table/data-table-ios.less +70 -0
- package/components/data-table/data-table-md.less +88 -0
- package/components/data-table/data-table-rtl.css +1 -0
- package/components/data-table/data-table-vars.less +77 -0
- package/components/data-table/data-table.css +1 -0
- package/components/data-table/data-table.d.ts +61 -0
- package/components/data-table/data-table.js +64 -0
- package/components/data-table/data-table.less +429 -0
- package/components/dialog/dialog-class.js +196 -0
- package/components/dialog/dialog-ios.less +94 -0
- package/components/dialog/dialog-md.less +86 -0
- package/components/dialog/dialog-rtl.css +1 -0
- package/components/dialog/dialog-vars.less +93 -0
- package/components/dialog/dialog.css +1 -0
- package/components/dialog/dialog.d.ts +245 -0
- package/components/dialog/dialog.js +242 -0
- package/components/dialog/dialog.less +142 -0
- package/components/fab/fab-ios.less +9 -0
- package/components/fab/fab-md.less +11 -0
- package/components/fab/fab-rtl.css +1 -0
- package/components/fab/fab-vars.less +46 -0
- package/components/fab/fab.css +1 -0
- package/components/fab/fab.d.ts +32 -0
- package/components/fab/fab.js +172 -0
- package/components/fab/fab.less +523 -0
- package/components/form/form-ios.less +0 -0
- package/components/form/form-md.less +0 -0
- package/components/form/form-rtl.css +0 -0
- package/components/form/form.css +0 -0
- package/components/form/form.d.ts +64 -0
- package/components/form/form.js +311 -0
- package/components/form/form.less +7 -0
- package/components/gauge/gauge-class.js +298 -0
- package/components/gauge/gauge-ios.less +2 -0
- package/components/gauge/gauge-md.less +2 -0
- package/components/gauge/gauge-rtl.css +1 -0
- package/components/gauge/gauge.css +1 -0
- package/components/gauge/gauge.d.ts +100 -0
- package/components/gauge/gauge.js +90 -0
- package/components/gauge/gauge.less +24 -0
- package/components/grid/grid-ios.less +2 -0
- package/components/grid/grid-md.less +2 -0
- package/components/grid/grid-rtl.css +1 -0
- package/components/grid/grid-vars.less +3 -0
- package/components/grid/grid.css +1 -0
- package/components/grid/grid.d.ts +15 -0
- package/components/grid/grid.js +3 -0
- package/components/grid/grid.less +78 -0
- package/components/icon/icon-ios.less +44 -0
- package/components/icon/icon-md.less +56 -0
- package/components/icon/icon.d.ts +14 -0
- package/components/icon/icon.js +3 -0
- package/components/icon/icon.less +33 -0
- package/components/infinite-scroll/infinite-scroll-ios.less +11 -0
- package/components/infinite-scroll/infinite-scroll-md.less +6 -0
- package/components/infinite-scroll/infinite-scroll-rtl.css +1 -0
- package/components/infinite-scroll/infinite-scroll.css +1 -0
- package/components/infinite-scroll/infinite-scroll.d.ts +27 -0
- package/components/infinite-scroll/infinite-scroll.js +94 -0
- package/components/infinite-scroll/infinite-scroll.less +15 -0
- package/components/input/input-ios.less +129 -0
- package/components/input/input-md.less +171 -0
- package/components/input/input-rtl.css +1 -0
- package/components/input/input-vars.less +94 -0
- package/components/input/input.css +1 -0
- package/components/input/input.d.ts +60 -0
- package/components/input/input.js +339 -0
- package/components/input/input.less +355 -0
- package/components/link/link-ios.less +9 -0
- package/components/link/link-md.less +2 -0
- package/components/link/link-vars.less +9 -0
- package/components/link/link.d.ts +14 -0
- package/components/link/link.js +3 -0
- package/components/link/link.less +37 -0
- package/components/list/list-ios.less +15 -0
- package/components/list/list-md.less +5 -0
- package/components/list/list-vars.less +184 -0
- package/components/list/list.d.ts +14 -0
- package/components/list/list.js +3 -0
- package/components/list/list.less +718 -0
- package/components/list-index/list-index-class.js +333 -0
- package/components/list-index/list-index-ios.less +21 -0
- package/components/list-index/list-index-md.less +7 -0
- package/components/list-index/list-index-rtl.css +1 -0
- package/components/list-index/list-index-vars.less +25 -0
- package/components/list-index/list-index.css +1 -0
- package/components/list-index/list-index.d.ts +101 -0
- package/components/list-index/list-index.js +65 -0
- package/components/list-index/list-index.less +130 -0
- package/components/login-screen/login-screen-class.js +38 -0
- package/components/login-screen/login-screen-ios.less +2 -0
- package/components/login-screen/login-screen-md.less +2 -0
- package/components/login-screen/login-screen-rtl.css +1 -0
- package/components/login-screen/login-screen-vars.less +33 -0
- package/components/login-screen/login-screen.css +1 -0
- package/components/login-screen/login-screen.d.ts +99 -0
- package/components/login-screen/login-screen.js +32 -0
- package/components/login-screen/login-screen.less +100 -0
- package/components/messagebar/messagebar-class.js +367 -0
- package/components/messagebar/messagebar-ios.less +88 -0
- package/components/messagebar/messagebar-md.less +114 -0
- package/components/messagebar/messagebar-rtl.css +1 -0
- package/components/messagebar/messagebar-vars.less +75 -0
- package/components/messagebar/messagebar.css +1 -0
- package/components/messagebar/messagebar.d.ts +165 -0
- package/components/messagebar/messagebar.js +66 -0
- package/components/messagebar/messagebar.less +162 -0
- package/components/messages/messages-class.js +487 -0
- package/components/messages/messages-ios.less +165 -0
- package/components/messages/messages-md.less +140 -0
- package/components/messages/messages-rtl.css +1 -0
- package/components/messages/messages-vars.less +82 -0
- package/components/messages/messages.css +1 -0
- package/components/messages/messages.d.ts +162 -0
- package/components/messages/messages.js +65 -0
- package/components/messages/messages.less +218 -0
- package/components/modal/custom-modal-class.js +66 -0
- package/components/modal/modal-class.js +224 -0
- package/components/modal/modal.d.ts +82 -0
- package/components/modal/modal.js +22 -0
- package/components/modal/modal.less +14 -0
- package/components/navbar/navbar-ios.less +755 -0
- package/components/navbar/navbar-md.less +65 -0
- package/components/navbar/navbar-vars.less +74 -0
- package/components/navbar/navbar.d.ts +77 -0
- package/components/navbar/navbar.js +712 -0
- package/components/navbar/navbar.less +311 -0
- package/components/notification/notification-class.js +212 -0
- package/components/notification/notification-ios.less +55 -0
- package/components/notification/notification-md.less +87 -0
- package/components/notification/notification-rtl.css +1 -0
- package/components/notification/notification-vars.less +75 -0
- package/components/notification/notification.css +1 -0
- package/components/notification/notification.d.ts +122 -0
- package/components/notification/notification.js +33 -0
- package/components/notification/notification.less +94 -0
- package/components/page/page-ios.less +154 -0
- package/components/page/page-md.less +83 -0
- package/components/page/page-transitions/circle.less +107 -0
- package/components/page/page-transitions/cover-v.less +61 -0
- package/components/page/page-transitions/cover.less +71 -0
- package/components/page/page-transitions/dive.less +77 -0
- package/components/page/page-transitions/fade.less +53 -0
- package/components/page/page-transitions/flip.less +91 -0
- package/components/page/page-transitions/parallax.less +75 -0
- package/components/page/page-transitions/push.less +75 -0
- package/components/page/page-vars.less +47 -0
- package/components/page/page.d.ts +14 -0
- package/components/page/page.js +3 -0
- package/components/page/page.less +204 -0
- package/components/panel/panel-class.js +556 -0
- package/components/panel/panel-ios.less +2 -0
- package/components/panel/panel-md.less +11 -0
- package/components/panel/panel-rtl.css +3 -0
- package/components/panel/panel-vars.less +24 -0
- package/components/panel/panel.css +3 -0
- package/components/panel/panel.d.ts +198 -0
- package/components/panel/panel.js +189 -0
- package/components/panel/panel.less +403 -0
- package/components/panel/resizable-panel.js +160 -0
- package/components/panel/swipe-panel.js +311 -0
- package/components/photo-browser/photo-browser-class.js +734 -0
- package/components/photo-browser/photo-browser-ios.less +2 -0
- package/components/photo-browser/photo-browser-md.less +2 -0
- package/components/photo-browser/photo-browser-rtl.css +1 -0
- package/components/photo-browser/photo-browser-vars.less +16 -0
- package/components/photo-browser/photo-browser.css +1 -0
- package/components/photo-browser/photo-browser.d.ts +204 -0
- package/components/photo-browser/photo-browser.js +73 -0
- package/components/photo-browser/photo-browser.less +358 -0
- package/components/picker/picker-class.js +588 -0
- package/components/picker/picker-column.js +121 -0
- package/components/picker/picker-ios.less +12 -0
- package/components/picker/picker-md.less +8 -0
- package/components/picker/picker-rtl.css +1 -0
- package/components/picker/picker-vars.less +35 -0
- package/components/picker/picker.css +1 -0
- package/components/picker/picker.d.ts +209 -0
- package/components/picker/picker.js +59 -0
- package/components/picker/picker.less +180 -0
- package/components/pie-chart/pie-chart-class.js +250 -0
- package/components/pie-chart/pie-chart-ios.less +2 -0
- package/components/pie-chart/pie-chart-md.less +2 -0
- package/components/pie-chart/pie-chart-rtl.css +1 -0
- package/components/pie-chart/pie-chart.css +1 -0
- package/components/pie-chart/pie-chart.d.ts +99 -0
- package/components/pie-chart/pie-chart.js +32 -0
- package/components/pie-chart/pie-chart.less +43 -0
- package/components/popover/popover-class.js +293 -0
- package/components/popover/popover-ios.less +6 -0
- package/components/popover/popover-md.less +41 -0
- package/components/popover/popover-rtl.css +1 -0
- package/components/popover/popover-vars.less +25 -0
- package/components/popover/popover.css +1 -0
- package/components/popover/popover.d.ts +137 -0
- package/components/popover/popover.js +75 -0
- package/components/popover/popover.less +168 -0
- package/components/popup/popup-class.js +329 -0
- package/components/popup/popup-ios.less +2 -0
- package/components/popup/popup-md.less +2 -0
- package/components/popup/popup-rtl.css +1 -0
- package/components/popup/popup-vars.less +21 -0
- package/components/popup/popup.css +1 -0
- package/components/popup/popup.d.ts +143 -0
- package/components/popup/popup.js +46 -0
- package/components/popup/popup.less +204 -0
- package/components/preloader/preloader-ios.less +57 -0
- package/components/preloader/preloader-md.less +114 -0
- package/components/preloader/preloader-rtl.css +1 -0
- package/components/preloader/preloader-vars.less +16 -0
- package/components/preloader/preloader.css +1 -0
- package/components/preloader/preloader.d.ts +26 -0
- package/components/preloader/preloader.js +106 -0
- package/components/preloader/preloader.less +60 -0
- package/components/progressbar/progressbar-ios.less +59 -0
- package/components/progressbar/progressbar-md.less +141 -0
- package/components/progressbar/progressbar-rtl.css +1 -0
- package/components/progressbar/progressbar-vars.less +22 -0
- package/components/progressbar/progressbar.css +1 -0
- package/components/progressbar/progressbar.d.ts +31 -0
- package/components/progressbar/progressbar.js +150 -0
- package/components/progressbar/progressbar.less +111 -0
- package/components/pull-to-refresh/pull-to-refresh-class.js +512 -0
- package/components/pull-to-refresh/pull-to-refresh-ios.less +88 -0
- package/components/pull-to-refresh/pull-to-refresh-md.less +129 -0
- package/components/pull-to-refresh/pull-to-refresh-rtl.css +1 -0
- package/components/pull-to-refresh/pull-to-refresh-vars.less +14 -0
- package/components/pull-to-refresh/pull-to-refresh.css +1 -0
- package/components/pull-to-refresh/pull-to-refresh.d.ts +103 -0
- package/components/pull-to-refresh/pull-to-refresh.js +62 -0
- package/components/pull-to-refresh/pull-to-refresh.less +38 -0
- package/components/radio/radio-ios.less +61 -0
- package/components/radio/radio-md.less +64 -0
- package/components/radio/radio-rtl.css +1 -0
- package/components/radio/radio-vars.less +24 -0
- package/components/radio/radio.css +1 -0
- package/components/radio/radio.d.ts +14 -0
- package/components/radio/radio.js +3 -0
- package/components/radio/radio.less +64 -0
- package/components/range/range-class.js +577 -0
- package/components/range/range-ios.less +9 -0
- package/components/range/range-md.less +41 -0
- package/components/range/range-rtl.css +1 -0
- package/components/range/range-vars.less +61 -0
- package/components/range/range.css +1 -0
- package/components/range/range.d.ts +143 -0
- package/components/range/range.js +75 -0
- package/components/range/range.less +235 -0
- package/components/searchbar/remove-diacritics.js +271 -0
- package/components/searchbar/searchbar-class.js +592 -0
- package/components/searchbar/searchbar-ios.less +107 -0
- package/components/searchbar/searchbar-md.less +147 -0
- package/components/searchbar/searchbar-rtl.css +1 -0
- package/components/searchbar/searchbar-vars.less +77 -0
- package/components/searchbar/searchbar.css +1 -0
- package/components/searchbar/searchbar.d.ts +161 -0
- package/components/searchbar/searchbar.js +122 -0
- package/components/searchbar/searchbar.less +322 -0
- package/components/sheet/sheet-class.js +673 -0
- package/components/sheet/sheet-ios.less +2 -0
- package/components/sheet/sheet-md.less +9 -0
- package/components/sheet/sheet-rtl.css +1 -0
- package/components/sheet/sheet-vars.less +27 -0
- package/components/sheet/sheet.css +1 -0
- package/components/sheet/sheet.d.ts +170 -0
- package/components/sheet/sheet.js +76 -0
- package/components/sheet/sheet.less +196 -0
- package/components/skeleton/skeleton-ios.less +2 -0
- package/components/skeleton/skeleton-md.less +2 -0
- package/components/skeleton/skeleton-rtl.css +1 -0
- package/components/skeleton/skeleton-vars.less +8 -0
- package/components/skeleton/skeleton.css +1 -0
- package/components/skeleton/skeleton.d.ts +14 -0
- package/components/skeleton/skeleton.js +3 -0
- package/components/skeleton/skeleton.less +11 -0
- package/components/smart-select/smart-select-class.js +874 -0
- package/components/smart-select/smart-select-ios.less +2 -0
- package/components/smart-select/smart-select-md.less +2 -0
- package/components/smart-select/smart-select-rtl.css +1 -0
- package/components/smart-select/smart-select-vars.less +6 -0
- package/components/smart-select/smart-select.css +1 -0
- package/components/smart-select/smart-select.d.ts +204 -0
- package/components/smart-select/smart-select.js +138 -0
- package/components/smart-select/smart-select.less +42 -0
- package/components/sortable/sortable-ios.less +7 -0
- package/components/sortable/sortable-md.less +7 -0
- package/components/sortable/sortable-rtl.css +1 -0
- package/components/sortable/sortable-vars.less +22 -0
- package/components/sortable/sortable.css +1 -0
- package/components/sortable/sortable.d.ts +50 -0
- package/components/sortable/sortable.js +286 -0
- package/components/sortable/sortable.less +133 -0
- package/components/statusbar/statusbar-ios.less +2 -0
- package/components/statusbar/statusbar-md.less +2 -0
- package/components/statusbar/statusbar.d.ts +54 -0
- package/components/statusbar/statusbar.js +190 -0
- package/components/statusbar/statusbar.less +7 -0
- package/components/stepper/stepper-class.js +403 -0
- package/components/stepper/stepper-ios.less +36 -0
- package/components/stepper/stepper-md.less +16 -0
- package/components/stepper/stepper-rtl.css +1 -0
- package/components/stepper/stepper-vars.less +40 -0
- package/components/stepper/stepper.css +1 -0
- package/components/stepper/stepper.d.ts +121 -0
- package/components/stepper/stepper.js +82 -0
- package/components/stepper/stepper.less +178 -0
- package/components/subnavbar/subnavbar-ios.less +51 -0
- package/components/subnavbar/subnavbar-md.less +47 -0
- package/components/subnavbar/subnavbar-vars.less +36 -0
- package/components/subnavbar/subnavbar.d.ts +11 -0
- package/components/subnavbar/subnavbar.js +17 -0
- package/components/subnavbar/subnavbar.less +128 -0
- package/components/swipeout/swipeout-ios.less +2 -0
- package/components/swipeout/swipeout-md.less +2 -0
- package/components/swipeout/swipeout-rtl.css +1 -0
- package/components/swipeout/swipeout-vars.less +24 -0
- package/components/swipeout/swipeout.css +1 -0
- package/components/swipeout/swipeout.d.ts +68 -0
- package/components/swipeout/swipeout.js +513 -0
- package/components/swipeout/swipeout.less +109 -0
- package/components/swiper/swiper-ios.less +2 -0
- package/components/swiper/swiper-md.less +2 -0
- package/components/swiper/swiper-rtl.css +1 -0
- package/components/swiper/swiper.css +1 -0
- package/components/swiper/swiper.d.ts +25 -0
- package/components/swiper/swiper.js +141 -0
- package/components/swiper/swiper.less +5 -0
- package/components/tabs/tabs-ios.less +2 -0
- package/components/tabs/tabs-md.less +2 -0
- package/components/tabs/tabs-rtl.css +1 -0
- package/components/tabs/tabs.css +1 -0
- package/components/tabs/tabs.d.ts +39 -0
- package/components/tabs/tabs.js +243 -0
- package/components/tabs/tabs.less +45 -0
- package/components/text-editor/text-editor-class.js +516 -0
- package/components/text-editor/text-editor-ios.less +9 -0
- package/components/text-editor/text-editor-md.less +11 -0
- package/components/text-editor/text-editor-rtl.css +1 -0
- package/components/text-editor/text-editor-vars.less +51 -0
- package/components/text-editor/text-editor.css +1 -0
- package/components/text-editor/text-editor.d.ts +166 -0
- package/components/text-editor/text-editor.js +81 -0
- package/components/text-editor/text-editor.less +153 -0
- package/components/timeline/timeline-ios.less +11 -0
- package/components/timeline/timeline-md.less +7 -0
- package/components/timeline/timeline-rtl.css +1 -0
- package/components/timeline/timeline-vars.less +64 -0
- package/components/timeline/timeline.css +1 -0
- package/components/timeline/timeline.d.ts +14 -0
- package/components/timeline/timeline.js +3 -0
- package/components/timeline/timeline.less +413 -0
- package/components/toast/toast-class.js +105 -0
- package/components/toast/toast-ios.less +81 -0
- package/components/toast/toast-md.less +72 -0
- package/components/toast/toast-rtl.css +1 -0
- package/components/toast/toast-vars.less +24 -0
- package/components/toast/toast.css +1 -0
- package/components/toast/toast.d.ts +121 -0
- package/components/toast/toast.js +40 -0
- package/components/toast/toast.less +62 -0
- package/components/toggle/toggle-class.js +165 -0
- package/components/toggle/toggle-ios.less +70 -0
- package/components/toggle/toggle-md.less +44 -0
- package/components/toggle/toggle-rtl.css +1 -0
- package/components/toggle/toggle-vars.less +30 -0
- package/components/toggle/toggle.css +1 -0
- package/components/toggle/toggle.d.ts +73 -0
- package/components/toggle/toggle.js +57 -0
- package/components/toggle/toggle.less +52 -0
- package/components/toolbar/toolbar-ios.less +47 -0
- package/components/toolbar/toolbar-md.less +77 -0
- package/components/toolbar/toolbar-vars.less +71 -0
- package/components/toolbar/toolbar.d.ts +43 -0
- package/components/toolbar/toolbar.js +198 -0
- package/components/toolbar/toolbar.less +306 -0
- package/components/tooltip/tooltip-class.js +336 -0
- package/components/tooltip/tooltip-ios.less +2 -0
- package/components/tooltip/tooltip-md.less +2 -0
- package/components/tooltip/tooltip-rtl.css +1 -0
- package/components/tooltip/tooltip-vars.less +19 -0
- package/components/tooltip/tooltip.css +1 -0
- package/components/tooltip/tooltip.d.ts +105 -0
- package/components/tooltip/tooltip.js +129 -0
- package/components/tooltip/tooltip.less +39 -0
- package/components/touch-ripple/touch-ripple-class.js +85 -0
- package/components/touch-ripple/touch-ripple-ios.less +2 -0
- package/components/touch-ripple/touch-ripple-md.less +2 -0
- package/components/touch-ripple/touch-ripple-vars.less +8 -0
- package/components/touch-ripple/touch-ripple.d.ts +25 -0
- package/components/touch-ripple/touch-ripple.js +18 -0
- package/components/touch-ripple/touch-ripple.less +114 -0
- package/components/treeview/treeview-ios.less +2 -0
- package/components/treeview/treeview-md.less +2 -0
- package/components/treeview/treeview-rtl.css +1 -0
- package/components/treeview/treeview-vars.less +38 -0
- package/components/treeview/treeview.css +1 -0
- package/components/treeview/treeview.d.ts +42 -0
- package/components/treeview/treeview.js +74 -0
- package/components/treeview/treeview.less +160 -0
- package/components/typography/typography-ios.less +2 -0
- package/components/typography/typography-md.less +2 -0
- package/components/typography/typography-rtl.css +1 -0
- package/components/typography/typography-vars.less +4 -0
- package/components/typography/typography.css +1 -0
- package/components/typography/typography.d.ts +14 -0
- package/components/typography/typography.js +3 -0
- package/components/typography/typography.less +220 -0
- package/components/view/resizable-view.js +125 -0
- package/components/view/view-class.js +206 -0
- package/components/view/view-ios.less +2 -0
- package/components/view/view-md.less +2 -0
- package/components/view/view.d.ts +199 -0
- package/components/view/view.js +173 -0
- package/components/view/view.less +35 -0
- package/components/virtual-list/virtual-list-class.js +583 -0
- package/components/virtual-list/virtual-list-ios.less +2 -0
- package/components/virtual-list/virtual-list-md.less +2 -0
- package/components/virtual-list/virtual-list-rtl.css +0 -0
- package/components/virtual-list/virtual-list.css +0 -0
- package/components/virtual-list/virtual-list.d.ts +142 -0
- package/components/virtual-list/virtual-list.js +17 -0
- package/components/virtual-list/virtual-list.less +7 -0
- package/framework7-bundle-rtl.css +19821 -0
- package/framework7-bundle-rtl.min.css +19 -0
- package/framework7-bundle.css +19802 -0
- package/framework7-bundle.esm.js +93 -0
- package/framework7-bundle.js +48416 -0
- package/framework7-bundle.js.map +1 -0
- package/framework7-bundle.less +92 -0
- package/framework7-bundle.min.css +19 -0
- package/framework7-bundle.min.js +14 -0
- package/framework7-bundle.min.js.map +1 -0
- package/framework7-lite-bundle.esm.js +86 -0
- package/framework7-lite.esm.js +37 -0
- package/framework7-lite.js +31 -0
- package/framework7-rtl.css +5252 -0
- package/framework7-rtl.min.css +17 -0
- package/framework7-types.d.ts +336 -0
- package/framework7.css +5245 -0
- package/framework7.d.ts +322 -0
- package/framework7.esm.js +41 -0
- package/framework7.js +42 -0
- package/framework7.less +41 -0
- package/framework7.min.css +17 -0
- package/less/mixins.less +281 -0
- package/less/plugin.js +15 -0
- package/less/vars.less +7 -0
- package/modules/clicks/clicks.d.ts +19 -0
- package/modules/clicks/clicks.js +94 -0
- package/modules/component/$h.js +15 -0
- package/modules/component/$jsx.js +17 -0
- package/modules/component/component-class.js +517 -0
- package/modules/component/component.d.ts +111 -0
- package/modules/component/component.js +44 -0
- package/modules/component/custom-components.js +1 -0
- package/modules/component/eventslisteners.js +74 -0
- package/modules/component/parse-component.js +79 -0
- package/modules/component/patch.js +8 -0
- package/modules/component/snabbdom/h.d.ts +10 -0
- package/modules/component/snabbdom/h.js +50 -0
- package/modules/component/snabbdom/helpers/attachto.d.ts +9 -0
- package/modules/component/snabbdom/helpers/attachto.js +49 -0
- package/modules/component/snabbdom/hooks.d.ts +23 -0
- package/modules/component/snabbdom/hooks.js +0 -0
- package/modules/component/snabbdom/htmldomapi.d.ts +19 -0
- package/modules/component/snabbdom/htmldomapi.js +67 -0
- package/modules/component/snabbdom/is.d.ts +2 -0
- package/modules/component/snabbdom/is.js +4 -0
- package/modules/component/snabbdom/modules/attributes.d.ts +4 -0
- package/modules/component/snabbdom/modules/attributes.js +51 -0
- package/modules/component/snabbdom/modules/class.d.ts +4 -0
- package/modules/component/snabbdom/modules/class.js +27 -0
- package/modules/component/snabbdom/modules/dataset.d.ts +4 -0
- package/modules/component/snabbdom/modules/dataset.js +37 -0
- package/modules/component/snabbdom/modules/eventlisteners.d.ts +8 -0
- package/modules/component/snabbdom/modules/eventlisteners.js +93 -0
- package/modules/component/snabbdom/modules/hero.d.ts +6 -0
- package/modules/component/snabbdom/modules/hero.js +147 -0
- package/modules/component/snabbdom/modules/module.d.ts +9 -0
- package/modules/component/snabbdom/modules/module.js +0 -0
- package/modules/component/snabbdom/modules/props.d.ts +4 -0
- package/modules/component/snabbdom/modules/props.js +29 -0
- package/modules/component/snabbdom/modules/style.d.ts +7 -0
- package/modules/component/snabbdom/modules/style.js +93 -0
- package/modules/component/snabbdom/snabbdom.bundle.d.ts +5 -0
- package/modules/component/snabbdom/snabbdom.bundle.js +13 -0
- package/modules/component/snabbdom/snabbdom.d.ts +6 -0
- package/modules/component/snabbdom/snabbdom.js +282 -0
- package/modules/component/snabbdom/thunk.d.ts +14 -0
- package/modules/component/snabbdom/thunk.js +50 -0
- package/modules/component/snabbdom/tovnode.d.ts +4 -0
- package/modules/component/snabbdom/tovnode.js +40 -0
- package/modules/component/snabbdom/vnode.d.ts +36 -0
- package/modules/component/snabbdom/vnode.js +12 -0
- package/modules/component/vdom.js +319 -0
- package/modules/demo-module.js +44 -0
- package/modules/device/device.d.ts +14 -0
- package/modules/device/device.js +44 -0
- package/modules/history/history.js +12 -0
- package/modules/resize/resize.d.ts +25 -0
- package/modules/resize/resize.js +62 -0
- package/modules/router/app-router-check.js +5 -0
- package/modules/router/async-component.js +27 -0
- package/modules/router/back.js +723 -0
- package/modules/router/clear-previous-history.js +31 -0
- package/modules/router/component-loader.js +200 -0
- package/modules/router/modal.js +223 -0
- package/modules/router/navigate.js +814 -0
- package/modules/router/process-route-queue.js +66 -0
- package/modules/router/redirect.js +38 -0
- package/modules/router/router-class.js +1268 -0
- package/modules/router/router.d.ts +354 -0
- package/modules/router/router.js +26 -0
- package/modules/router/swipe-back.js +589 -0
- package/modules/router/tab.js +230 -0
- package/modules/service-worker/service-worker.d.ts +38 -0
- package/modules/service-worker/service-worker.js +86 -0
- package/modules/store/create-store.js +138 -0
- package/modules/store/store.d.ts +40 -0
- package/modules/store/store.js +11 -0
- package/modules/support/support.d.ts +15 -0
- package/modules/support/support.js +7 -0
- package/modules/touch/touch.d.ts +60 -0
- package/modules/touch/touch.js +482 -0
- package/modules/utils/utils.d.ts +15 -0
- package/modules/utils/utils.js +10 -0
- package/package.json +458 -0
- package/shared/$jsx.js +21 -0
- package/shared/class.js +146 -0
- package/shared/constructor-methods.js +52 -0
- package/shared/dom7.js +7 -0
- package/shared/events-class.js +95 -0
- package/shared/get-device.d.ts +52 -0
- package/shared/get-device.js +147 -0
- package/shared/get-support.d.ts +12 -0
- package/shared/get-support.js +35 -0
- package/shared/history.js +171 -0
- package/shared/material-color-utils.js +1377 -0
- package/shared/material-colors.js +75 -0
- package/shared/modal-methods.js +80 -0
- package/shared/utils.d.ts +88 -0
- package/shared/utils.js +535 -0
|
@@ -0,0 +1,1872 @@
|
|
|
1
|
+
import { extend, nextTick, deleteProps } from '../../shared/utils.js';
|
|
2
|
+
import Framework7Class from '../../shared/class.js';
|
|
3
|
+
import $ from '../../shared/dom7.js';
|
|
4
|
+
import { getDevice } from '../../shared/get-device.js';
|
|
5
|
+
import { getSupport } from '../../shared/get-support.js';
|
|
6
|
+
/** @jsx $jsx */
|
|
7
|
+
import $jsx from '../../shared/$jsx.js';
|
|
8
|
+
class Calendar extends Framework7Class {
|
|
9
|
+
constructor(app, params) {
|
|
10
|
+
if (params === void 0) {
|
|
11
|
+
params = {};
|
|
12
|
+
}
|
|
13
|
+
super(params, [app]);
|
|
14
|
+
const calendar = this;
|
|
15
|
+
calendar.params = extend({}, app.params.calendar, params);
|
|
16
|
+
let $containerEl;
|
|
17
|
+
if (calendar.params.containerEl) {
|
|
18
|
+
$containerEl = $(calendar.params.containerEl);
|
|
19
|
+
if ($containerEl.length === 0) return calendar;
|
|
20
|
+
}
|
|
21
|
+
let $inputEl;
|
|
22
|
+
if (calendar.params.inputEl) {
|
|
23
|
+
$inputEl = $(calendar.params.inputEl);
|
|
24
|
+
}
|
|
25
|
+
const isHorizontal = calendar.params.direction === 'horizontal';
|
|
26
|
+
let inverter = 1;
|
|
27
|
+
if (isHorizontal) {
|
|
28
|
+
inverter = app.rtl ? -1 : 1;
|
|
29
|
+
}
|
|
30
|
+
extend(calendar, {
|
|
31
|
+
app,
|
|
32
|
+
$containerEl,
|
|
33
|
+
containerEl: $containerEl && $containerEl[0],
|
|
34
|
+
inline: $containerEl && $containerEl.length > 0,
|
|
35
|
+
$inputEl,
|
|
36
|
+
inputEl: $inputEl && $inputEl[0],
|
|
37
|
+
initialized: false,
|
|
38
|
+
opened: false,
|
|
39
|
+
url: calendar.params.url,
|
|
40
|
+
isHorizontal,
|
|
41
|
+
inverter,
|
|
42
|
+
animating: false,
|
|
43
|
+
allowTouchMove: true,
|
|
44
|
+
hasTimePicker: calendar.params.timePicker && !calendar.params.rangePicker && !calendar.params.multiple
|
|
45
|
+
});
|
|
46
|
+
calendar.dayFormatter = date => {
|
|
47
|
+
const formatter = new Intl.DateTimeFormat(calendar.params.locale, {
|
|
48
|
+
day: 'numeric'
|
|
49
|
+
});
|
|
50
|
+
return formatter.format(date).replace(/日/, '');
|
|
51
|
+
};
|
|
52
|
+
calendar.monthFormatter = date => {
|
|
53
|
+
const formatter = new Intl.DateTimeFormat(calendar.params.locale, {
|
|
54
|
+
month: 'long'
|
|
55
|
+
});
|
|
56
|
+
return formatter.format(date);
|
|
57
|
+
};
|
|
58
|
+
calendar.yearFormatter = date => {
|
|
59
|
+
const formatter = new Intl.DateTimeFormat(calendar.params.locale, {
|
|
60
|
+
year: 'numeric'
|
|
61
|
+
});
|
|
62
|
+
return formatter.format(date);
|
|
63
|
+
};
|
|
64
|
+
calendar.timeSelectorFormatter = date => {
|
|
65
|
+
const formatter = new Intl.DateTimeFormat(calendar.params.locale, calendar.params.timePickerFormat);
|
|
66
|
+
return formatter.format(date);
|
|
67
|
+
};
|
|
68
|
+
const timeFormatCheckDate = calendar.timeSelectorFormatter(new Date()).toLowerCase();
|
|
69
|
+
calendar.is12HoursFormat = timeFormatCheckDate.indexOf('pm') >= 0 || timeFormatCheckDate.indexOf('am') >= 0;
|
|
70
|
+
|
|
71
|
+
// Auto names
|
|
72
|
+
let {
|
|
73
|
+
monthNames,
|
|
74
|
+
monthNamesShort,
|
|
75
|
+
dayNames,
|
|
76
|
+
dayNamesShort
|
|
77
|
+
} = calendar.params;
|
|
78
|
+
const {
|
|
79
|
+
monthNamesIntl,
|
|
80
|
+
monthNamesShortIntl,
|
|
81
|
+
dayNamesIntl,
|
|
82
|
+
dayNamesShortIntl
|
|
83
|
+
} = calendar.getIntlNames();
|
|
84
|
+
if (monthNames === 'auto') monthNames = monthNamesIntl;
|
|
85
|
+
if (monthNamesShort === 'auto') monthNamesShort = monthNamesShortIntl;
|
|
86
|
+
if (dayNames === 'auto') dayNames = dayNamesIntl;
|
|
87
|
+
if (dayNamesShort === 'auto') dayNamesShort = dayNamesShortIntl;
|
|
88
|
+
extend(calendar, {
|
|
89
|
+
monthNames,
|
|
90
|
+
monthNamesShort,
|
|
91
|
+
dayNames,
|
|
92
|
+
dayNamesShort
|
|
93
|
+
});
|
|
94
|
+
function onInputClick() {
|
|
95
|
+
calendar.open();
|
|
96
|
+
}
|
|
97
|
+
function onInputFocus(e) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
}
|
|
100
|
+
function onInputClear() {
|
|
101
|
+
calendar.setValue([]);
|
|
102
|
+
if (calendar.opened) {
|
|
103
|
+
calendar.update();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function onHtmlClick(e) {
|
|
107
|
+
const $targetEl = $(e.target);
|
|
108
|
+
if (calendar.destroyed || !calendar.params) return;
|
|
109
|
+
if (calendar.isPopover()) return;
|
|
110
|
+
if (!calendar.opened || calendar.closing) return;
|
|
111
|
+
if ($targetEl.closest('[class*="backdrop"]').length) return;
|
|
112
|
+
if (calendar.monthPickerPopover || calendar.yearPickerPopover || calendar.timePickerPopover) return;
|
|
113
|
+
if ($inputEl && $inputEl.length > 0) {
|
|
114
|
+
if ($targetEl[0] !== $inputEl[0] && $targetEl.closest('.sheet-modal, .calendar-modal').length === 0) {
|
|
115
|
+
calendar.close();
|
|
116
|
+
}
|
|
117
|
+
} else if ($(e.target).closest('.sheet-modal, .calendar-modal').length === 0) {
|
|
118
|
+
calendar.close();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Events
|
|
123
|
+
extend(calendar, {
|
|
124
|
+
attachInputEvents() {
|
|
125
|
+
calendar.$inputEl.on('click', onInputClick);
|
|
126
|
+
calendar.$inputEl.on('input:clear', onInputClear);
|
|
127
|
+
if (calendar.params.inputReadOnly) {
|
|
128
|
+
calendar.$inputEl.on('focus mousedown', onInputFocus);
|
|
129
|
+
if (calendar.$inputEl[0]) {
|
|
130
|
+
calendar.$inputEl[0].f7ValidateReadonly = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
detachInputEvents() {
|
|
135
|
+
calendar.$inputEl.off('click', onInputClick);
|
|
136
|
+
calendar.$inputEl.off('input:clear', onInputClear);
|
|
137
|
+
if (calendar.params.inputReadOnly) {
|
|
138
|
+
calendar.$inputEl.off('focus mousedown', onInputFocus);
|
|
139
|
+
if (calendar.$inputEl[0]) {
|
|
140
|
+
delete calendar.$inputEl[0].f7ValidateReadonly;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
attachHtmlEvents() {
|
|
145
|
+
app.on('click', onHtmlClick);
|
|
146
|
+
},
|
|
147
|
+
detachHtmlEvents() {
|
|
148
|
+
app.off('click', onHtmlClick);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
calendar.attachCalendarEvents = function attachCalendarEvents() {
|
|
152
|
+
let allowItemClick = true;
|
|
153
|
+
let isTouched;
|
|
154
|
+
let isMoved;
|
|
155
|
+
let touchStartX;
|
|
156
|
+
let touchStartY;
|
|
157
|
+
let touchCurrentX;
|
|
158
|
+
let touchCurrentY;
|
|
159
|
+
let touchStartTime;
|
|
160
|
+
let touchEndTime;
|
|
161
|
+
let currentTranslate;
|
|
162
|
+
let wrapperWidth;
|
|
163
|
+
let wrapperHeight;
|
|
164
|
+
let percentage;
|
|
165
|
+
let touchesDiff;
|
|
166
|
+
let isScrolling;
|
|
167
|
+
const {
|
|
168
|
+
$el,
|
|
169
|
+
$wrapperEl
|
|
170
|
+
} = calendar;
|
|
171
|
+
function handleTouchStart(e) {
|
|
172
|
+
if (isMoved || isTouched || !e.isTrusted) return;
|
|
173
|
+
isTouched = true;
|
|
174
|
+
touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
|
175
|
+
touchCurrentX = touchStartX;
|
|
176
|
+
touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
|
177
|
+
touchCurrentY = touchStartY;
|
|
178
|
+
touchStartTime = new Date().getTime();
|
|
179
|
+
percentage = 0;
|
|
180
|
+
allowItemClick = true;
|
|
181
|
+
isScrolling = undefined;
|
|
182
|
+
currentTranslate = calendar.monthsTranslate;
|
|
183
|
+
}
|
|
184
|
+
function handleTouchMove(e) {
|
|
185
|
+
if (!isTouched || !e.isTrusted) return;
|
|
186
|
+
const {
|
|
187
|
+
isHorizontal: isH
|
|
188
|
+
} = calendar;
|
|
189
|
+
touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
|
|
190
|
+
touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
|
|
191
|
+
if (typeof isScrolling === 'undefined') {
|
|
192
|
+
isScrolling = !!(isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX));
|
|
193
|
+
}
|
|
194
|
+
if (isH && isScrolling || !calendar.allowTouchMove) {
|
|
195
|
+
isTouched = false;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
if (calendar.animating) {
|
|
200
|
+
isTouched = false;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
allowItemClick = false;
|
|
204
|
+
if (!isMoved) {
|
|
205
|
+
// First move
|
|
206
|
+
isMoved = true;
|
|
207
|
+
wrapperWidth = $wrapperEl[0].offsetWidth;
|
|
208
|
+
wrapperHeight = $wrapperEl[0].offsetHeight;
|
|
209
|
+
$wrapperEl.transition(0);
|
|
210
|
+
}
|
|
211
|
+
touchesDiff = isH ? touchCurrentX - touchStartX : touchCurrentY - touchStartY;
|
|
212
|
+
percentage = touchesDiff / (isH ? wrapperWidth : wrapperHeight);
|
|
213
|
+
currentTranslate = (calendar.monthsTranslate * calendar.inverter + percentage) * 100;
|
|
214
|
+
|
|
215
|
+
// Transform wrapper
|
|
216
|
+
$wrapperEl.transform(`translate3d(${isH ? currentTranslate : 0}%, ${isH ? 0 : currentTranslate}%, 0)`);
|
|
217
|
+
}
|
|
218
|
+
function handleTouchEnd(e) {
|
|
219
|
+
if (!isTouched || !isMoved || !e.isTrusted) {
|
|
220
|
+
isTouched = false;
|
|
221
|
+
isMoved = false;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
isTouched = false;
|
|
225
|
+
isMoved = false;
|
|
226
|
+
touchEndTime = new Date().getTime();
|
|
227
|
+
if (touchEndTime - touchStartTime < 300) {
|
|
228
|
+
if (Math.abs(touchesDiff) < 10) {
|
|
229
|
+
calendar.resetMonth();
|
|
230
|
+
} else if (touchesDiff >= 10) {
|
|
231
|
+
if (app.rtl) calendar.nextMonth();else calendar.prevMonth();
|
|
232
|
+
} else if (app.rtl) calendar.prevMonth();else calendar.nextMonth();
|
|
233
|
+
} else if (percentage <= -0.5) {
|
|
234
|
+
if (app.rtl) calendar.prevMonth();else calendar.nextMonth();
|
|
235
|
+
} else if (percentage >= 0.5) {
|
|
236
|
+
if (app.rtl) calendar.nextMonth();else calendar.prevMonth();
|
|
237
|
+
} else {
|
|
238
|
+
calendar.resetMonth();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Allow click
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
allowItemClick = true;
|
|
244
|
+
}, 100);
|
|
245
|
+
}
|
|
246
|
+
function handleDayClick(e) {
|
|
247
|
+
if (!allowItemClick) return;
|
|
248
|
+
let $dayEl = $(e.target).parents('.calendar-day');
|
|
249
|
+
if ($dayEl.length === 0 && $(e.target).hasClass('calendar-day')) {
|
|
250
|
+
$dayEl = $(e.target);
|
|
251
|
+
}
|
|
252
|
+
if ($dayEl.length === 0) return;
|
|
253
|
+
if ($dayEl.hasClass('calendar-day-disabled')) return;
|
|
254
|
+
if (!calendar.params.rangePicker) {
|
|
255
|
+
if ($dayEl.hasClass('calendar-day-next')) calendar.nextMonth();
|
|
256
|
+
if ($dayEl.hasClass('calendar-day-prev')) calendar.prevMonth();
|
|
257
|
+
}
|
|
258
|
+
const dateYear = parseInt($dayEl.attr('data-year'), 10);
|
|
259
|
+
const dateMonth = parseInt($dayEl.attr('data-month'), 10);
|
|
260
|
+
const dateDay = parseInt($dayEl.attr('data-day'), 10);
|
|
261
|
+
calendar.emit('local::dayClick calendarDayClick', calendar, $dayEl[0], dateYear, dateMonth, dateDay);
|
|
262
|
+
if (!$dayEl.hasClass('calendar-day-selected') || calendar.params.multiple || calendar.params.rangePicker) {
|
|
263
|
+
const valueToAdd = new Date(dateYear, dateMonth, dateDay, 0, 0, 0);
|
|
264
|
+
if (calendar.hasTimePicker) {
|
|
265
|
+
if (calendar.value && calendar.value[0]) {
|
|
266
|
+
valueToAdd.setHours(calendar.value[0].getHours(), calendar.value[0].getMinutes());
|
|
267
|
+
} else {
|
|
268
|
+
valueToAdd.setHours(new Date().getHours(), new Date().getMinutes());
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
calendar.addValue(valueToAdd);
|
|
272
|
+
}
|
|
273
|
+
if (calendar.params.closeOnSelect) {
|
|
274
|
+
if (calendar.params.rangePicker && calendar.value.length === 2 || !calendar.params.rangePicker) {
|
|
275
|
+
calendar.close();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function onNextMonthClick() {
|
|
280
|
+
calendar.nextMonth();
|
|
281
|
+
}
|
|
282
|
+
function onPrevMonthClick() {
|
|
283
|
+
calendar.prevMonth();
|
|
284
|
+
}
|
|
285
|
+
function onNextYearClick() {
|
|
286
|
+
calendar.nextYear();
|
|
287
|
+
}
|
|
288
|
+
function onPrevYearClick() {
|
|
289
|
+
calendar.prevYear();
|
|
290
|
+
}
|
|
291
|
+
function onMonthSelectorClick() {
|
|
292
|
+
calendar.openMonthPicker();
|
|
293
|
+
}
|
|
294
|
+
function onYearSelectorClick() {
|
|
295
|
+
calendar.openYearPicker();
|
|
296
|
+
}
|
|
297
|
+
function onTimeSelectorClick() {
|
|
298
|
+
calendar.openTimePicker();
|
|
299
|
+
}
|
|
300
|
+
const passiveListener = app.touchEvents.start === 'touchstart' && getSupport().passiveListener ? {
|
|
301
|
+
passive: true,
|
|
302
|
+
capture: false
|
|
303
|
+
} : false;
|
|
304
|
+
// Selectors clicks
|
|
305
|
+
$el.find('.calendar-prev-month-button').on('click', onPrevMonthClick);
|
|
306
|
+
$el.find('.calendar-next-month-button').on('click', onNextMonthClick);
|
|
307
|
+
$el.find('.calendar-prev-year-button').on('click', onPrevYearClick);
|
|
308
|
+
$el.find('.calendar-next-year-button').on('click', onNextYearClick);
|
|
309
|
+
if (calendar.params.monthPicker) {
|
|
310
|
+
$el.find('.current-month-value').on('click', onMonthSelectorClick);
|
|
311
|
+
}
|
|
312
|
+
if (calendar.params.yearPicker) {
|
|
313
|
+
$el.find('.current-year-value').on('click', onYearSelectorClick);
|
|
314
|
+
}
|
|
315
|
+
if (calendar.hasTimePicker) {
|
|
316
|
+
$el.find('.calendar-time-selector a').on('click', onTimeSelectorClick);
|
|
317
|
+
}
|
|
318
|
+
// Day clicks
|
|
319
|
+
$wrapperEl.on('click', handleDayClick);
|
|
320
|
+
// Touch events
|
|
321
|
+
if (calendar.params.touchMove) {
|
|
322
|
+
$wrapperEl.on(app.touchEvents.start, handleTouchStart, passiveListener);
|
|
323
|
+
app.on('touchmove:active', handleTouchMove);
|
|
324
|
+
app.on('touchend:passive', handleTouchEnd);
|
|
325
|
+
}
|
|
326
|
+
calendar.detachCalendarEvents = function detachCalendarEvents() {
|
|
327
|
+
$el.find('.calendar-prev-month-button').off('click', onPrevMonthClick);
|
|
328
|
+
$el.find('.calendar-next-month-button').off('click', onNextMonthClick);
|
|
329
|
+
$el.find('.calendar-prev-year-button').off('click', onPrevYearClick);
|
|
330
|
+
$el.find('.calendar-next-year-button').off('click', onNextYearClick);
|
|
331
|
+
if (calendar.params.monthPicker) {
|
|
332
|
+
$el.find('.current-month-value').off('click', onMonthSelectorClick);
|
|
333
|
+
}
|
|
334
|
+
if (calendar.params.yearPicker) {
|
|
335
|
+
$el.find('.current-year-value').off('click', onYearSelectorClick);
|
|
336
|
+
}
|
|
337
|
+
if (calendar.hasTimePicker) {
|
|
338
|
+
$el.find('.calendar-time-selector a').off('click', onTimeSelectorClick);
|
|
339
|
+
}
|
|
340
|
+
$wrapperEl.off('click', handleDayClick);
|
|
341
|
+
if (calendar.params.touchMove) {
|
|
342
|
+
$wrapperEl.off(app.touchEvents.start, handleTouchStart, passiveListener);
|
|
343
|
+
app.off('touchmove:active', handleTouchMove);
|
|
344
|
+
app.off('touchend:passive', handleTouchEnd);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
calendar.init();
|
|
349
|
+
return calendar;
|
|
350
|
+
}
|
|
351
|
+
get view() {
|
|
352
|
+
const {
|
|
353
|
+
$inputEl,
|
|
354
|
+
app,
|
|
355
|
+
params
|
|
356
|
+
} = this;
|
|
357
|
+
let view;
|
|
358
|
+
if (params.view) {
|
|
359
|
+
view = params.view;
|
|
360
|
+
} else if ($inputEl) {
|
|
361
|
+
view = $inputEl.parents('.view').length && $inputEl.parents('.view')[0].f7View;
|
|
362
|
+
}
|
|
363
|
+
if (!view) view = app.views.main;
|
|
364
|
+
return view;
|
|
365
|
+
}
|
|
366
|
+
getIntlNames() {
|
|
367
|
+
const calendar = this;
|
|
368
|
+
const locale = calendar.params.locale;
|
|
369
|
+
const monthNamesIntl = [];
|
|
370
|
+
const monthNamesShortIntl = [];
|
|
371
|
+
const dayNamesIntl = [];
|
|
372
|
+
const dayNamesShortIntl = [];
|
|
373
|
+
const formatterMonthNames = new Intl.DateTimeFormat(locale, {
|
|
374
|
+
month: 'long'
|
|
375
|
+
});
|
|
376
|
+
const formatterMonthNamesShort = new Intl.DateTimeFormat(locale, {
|
|
377
|
+
month: 'short'
|
|
378
|
+
});
|
|
379
|
+
const formatterDayNames = new Intl.DateTimeFormat(locale, {
|
|
380
|
+
weekday: 'long'
|
|
381
|
+
});
|
|
382
|
+
const formatterDayNamesShort = new Intl.DateTimeFormat(locale, {
|
|
383
|
+
weekday: 'short'
|
|
384
|
+
});
|
|
385
|
+
let year;
|
|
386
|
+
let yearStarted;
|
|
387
|
+
let yearEnded;
|
|
388
|
+
for (let i = 0; i < 24; i += 1) {
|
|
389
|
+
const date = new Date().setMonth(i, 1);
|
|
390
|
+
const currentYear = calendar.yearFormatter(date);
|
|
391
|
+
if (year && currentYear !== year) {
|
|
392
|
+
if (yearStarted) yearEnded = true;
|
|
393
|
+
yearStarted = true;
|
|
394
|
+
year = currentYear;
|
|
395
|
+
}
|
|
396
|
+
if (!year) {
|
|
397
|
+
year = currentYear;
|
|
398
|
+
}
|
|
399
|
+
if (yearStarted && year === currentYear && !yearEnded) {
|
|
400
|
+
monthNamesIntl.push(formatterMonthNames.format(date));
|
|
401
|
+
monthNamesShortIntl.push(formatterMonthNamesShort.format(date));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const weekDay = new Date().getDay();
|
|
405
|
+
for (let i = 0; i < 7; i += 1) {
|
|
406
|
+
const date = new Date().getTime() + (i - weekDay) * 24 * 60 * 60 * 1000;
|
|
407
|
+
dayNamesIntl.push(formatterDayNames.format(date));
|
|
408
|
+
dayNamesShortIntl.push(formatterDayNamesShort.format(date));
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
monthNamesIntl,
|
|
412
|
+
monthNamesShortIntl,
|
|
413
|
+
dayNamesIntl,
|
|
414
|
+
dayNamesShortIntl
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
normalizeDate(date) {
|
|
418
|
+
const calendar = this;
|
|
419
|
+
const d = new Date(date);
|
|
420
|
+
if (calendar.hasTimePicker) {
|
|
421
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
|
|
422
|
+
}
|
|
423
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
424
|
+
}
|
|
425
|
+
normalizeValues(values) {
|
|
426
|
+
const calendar = this;
|
|
427
|
+
let newValues = [];
|
|
428
|
+
if (values && Array.isArray(values)) {
|
|
429
|
+
newValues = values.map(val => calendar.normalizeDate(val));
|
|
430
|
+
}
|
|
431
|
+
return newValues;
|
|
432
|
+
}
|
|
433
|
+
initInput() {
|
|
434
|
+
const calendar = this;
|
|
435
|
+
if (!calendar.$inputEl) return;
|
|
436
|
+
if (calendar.params.inputReadOnly) calendar.$inputEl.prop('readOnly', true);
|
|
437
|
+
}
|
|
438
|
+
isPopover() {
|
|
439
|
+
const calendar = this;
|
|
440
|
+
const {
|
|
441
|
+
app,
|
|
442
|
+
modal,
|
|
443
|
+
params
|
|
444
|
+
} = calendar;
|
|
445
|
+
const device = getDevice();
|
|
446
|
+
if (params.openIn === 'sheet') return false;
|
|
447
|
+
if (modal && modal.type !== 'popover') return false;
|
|
448
|
+
if (!calendar.inline && calendar.inputEl) {
|
|
449
|
+
if (params.openIn === 'popover') return true;
|
|
450
|
+
if (device.ios) {
|
|
451
|
+
return !!device.ipad;
|
|
452
|
+
}
|
|
453
|
+
if (app.width >= 768) {
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
formatDate(d) {
|
|
460
|
+
const calendar = this;
|
|
461
|
+
const date = new Date(d);
|
|
462
|
+
const year = date.getFullYear();
|
|
463
|
+
const month = date.getMonth();
|
|
464
|
+
const month1 = month + 1;
|
|
465
|
+
const day = date.getDate();
|
|
466
|
+
const weekDay = date.getDay();
|
|
467
|
+
const {
|
|
468
|
+
monthNames,
|
|
469
|
+
monthNamesShort,
|
|
470
|
+
dayNames,
|
|
471
|
+
dayNamesShort
|
|
472
|
+
} = calendar;
|
|
473
|
+
const {
|
|
474
|
+
dateFormat,
|
|
475
|
+
locale
|
|
476
|
+
} = calendar.params;
|
|
477
|
+
function twoDigits(number) {
|
|
478
|
+
return number < 10 ? `0${number}` : number;
|
|
479
|
+
}
|
|
480
|
+
if (typeof dateFormat === 'string') {
|
|
481
|
+
const tokens = {
|
|
482
|
+
yyyy: year,
|
|
483
|
+
yy: String(year).substring(2),
|
|
484
|
+
mm: twoDigits(month1),
|
|
485
|
+
m: month1,
|
|
486
|
+
MM: monthNames[month],
|
|
487
|
+
M: monthNamesShort[month],
|
|
488
|
+
dd: twoDigits(day),
|
|
489
|
+
d: day,
|
|
490
|
+
DD: dayNames[weekDay],
|
|
491
|
+
D: dayNamesShort[weekDay]
|
|
492
|
+
};
|
|
493
|
+
if (calendar.params.timePicker) {
|
|
494
|
+
const hours = date.getHours();
|
|
495
|
+
const minutes = date.getMinutes();
|
|
496
|
+
const seconds = date.getSeconds();
|
|
497
|
+
let hours12 = hours;
|
|
498
|
+
if (hours > 12) hours12 = hours - 12;
|
|
499
|
+
if (hours === 0) hours12 = 12;
|
|
500
|
+
const a = hours >= 12 && hours !== 0 ? 'pm' : 'am';
|
|
501
|
+
Object.assign(tokens, {
|
|
502
|
+
HH: twoDigits(hours),
|
|
503
|
+
H: hours,
|
|
504
|
+
hh: twoDigits(hours12),
|
|
505
|
+
h: hours12,
|
|
506
|
+
ss: twoDigits(seconds),
|
|
507
|
+
s: seconds,
|
|
508
|
+
':mm': twoDigits(minutes),
|
|
509
|
+
':m': minutes,
|
|
510
|
+
a,
|
|
511
|
+
A: a.toUpperCase()
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
const regexp = new RegExp(Object.keys(tokens).map(t => `(${t})`).join('|'), 'g');
|
|
515
|
+
return dateFormat.replace(regexp, token => {
|
|
516
|
+
if (token in tokens) return tokens[token];
|
|
517
|
+
return token;
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
if (typeof dateFormat === 'function') {
|
|
521
|
+
return dateFormat(date);
|
|
522
|
+
}
|
|
523
|
+
// Intl Object
|
|
524
|
+
const formatter = new Intl.DateTimeFormat(locale, dateFormat);
|
|
525
|
+
return formatter.format(date);
|
|
526
|
+
}
|
|
527
|
+
formatValue() {
|
|
528
|
+
const calendar = this;
|
|
529
|
+
const {
|
|
530
|
+
value
|
|
531
|
+
} = calendar;
|
|
532
|
+
if (calendar.params.formatValue) {
|
|
533
|
+
return calendar.params.formatValue.call(calendar, value);
|
|
534
|
+
}
|
|
535
|
+
return value.map(v => calendar.formatDate(v)).join(calendar.params.rangePicker ? ' - ' : ', ');
|
|
536
|
+
}
|
|
537
|
+
addValue(newValue) {
|
|
538
|
+
const calendar = this;
|
|
539
|
+
const {
|
|
540
|
+
multiple,
|
|
541
|
+
rangePicker,
|
|
542
|
+
rangePickerMinDays,
|
|
543
|
+
rangePickerMaxDays
|
|
544
|
+
} = calendar.params;
|
|
545
|
+
if (multiple) {
|
|
546
|
+
if (!calendar.value) calendar.value = [];
|
|
547
|
+
let inValuesIndex;
|
|
548
|
+
for (let i = 0; i < calendar.value.length; i += 1) {
|
|
549
|
+
if (new Date(newValue).getTime() === new Date(calendar.value[i]).getTime()) {
|
|
550
|
+
inValuesIndex = i;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (typeof inValuesIndex === 'undefined') {
|
|
554
|
+
calendar.value.push(newValue);
|
|
555
|
+
} else {
|
|
556
|
+
calendar.value.splice(inValuesIndex, 1);
|
|
557
|
+
}
|
|
558
|
+
calendar.updateValue();
|
|
559
|
+
} else if (rangePicker) {
|
|
560
|
+
if (!calendar.value) calendar.value = [];
|
|
561
|
+
if (calendar.value.length === 2 || calendar.value.length === 0) {
|
|
562
|
+
calendar.value = [];
|
|
563
|
+
}
|
|
564
|
+
if (calendar.value.length === 0 || Math.abs(calendar.value[0].getTime() - newValue.getTime()) >= (rangePickerMinDays - 1) * 60 * 60 * 24 * 1000 && (rangePickerMaxDays === 0 || Math.abs(calendar.value[0].getTime() - newValue.getTime()) <= (rangePickerMaxDays - 1) * 60 * 60 * 24 * 1000)) calendar.value.push(newValue);else calendar.value = [];
|
|
565
|
+
calendar.value.sort((a, b) => a - b);
|
|
566
|
+
calendar.updateValue();
|
|
567
|
+
} else {
|
|
568
|
+
calendar.value = [newValue];
|
|
569
|
+
calendar.updateValue();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
setValue(values) {
|
|
573
|
+
const calendar = this;
|
|
574
|
+
const currentValue = calendar.value;
|
|
575
|
+
if (Array.isArray(currentValue) && Array.isArray(values) && currentValue.length === values.length) {
|
|
576
|
+
let equal = true;
|
|
577
|
+
currentValue.forEach((v, index) => {
|
|
578
|
+
if (v !== values[index]) equal = false;
|
|
579
|
+
});
|
|
580
|
+
if (equal) return;
|
|
581
|
+
}
|
|
582
|
+
calendar.value = values;
|
|
583
|
+
calendar.updateValue();
|
|
584
|
+
}
|
|
585
|
+
getValue() {
|
|
586
|
+
const calendar = this;
|
|
587
|
+
return calendar.value;
|
|
588
|
+
}
|
|
589
|
+
updateValue(onlyHeader) {
|
|
590
|
+
const calendar = this;
|
|
591
|
+
const {
|
|
592
|
+
$el,
|
|
593
|
+
$wrapperEl,
|
|
594
|
+
$inputEl,
|
|
595
|
+
value,
|
|
596
|
+
params
|
|
597
|
+
} = calendar;
|
|
598
|
+
let i;
|
|
599
|
+
if ($el && $el.length > 0) {
|
|
600
|
+
$wrapperEl.find('.calendar-day-selected').removeClass('calendar-day-selected calendar-day-selected-range calendar-day-selected-left calendar-day-selected-right');
|
|
601
|
+
let valueDate;
|
|
602
|
+
if (params.rangePicker && value.length === 2) {
|
|
603
|
+
const leftDate = new Date(value[0]).getTime();
|
|
604
|
+
const rightDate = new Date(value[1]).getTime();
|
|
605
|
+
for (i = leftDate; i <= rightDate; i += 24 * 60 * 60 * 1000) {
|
|
606
|
+
valueDate = new Date(i);
|
|
607
|
+
let addClass = 'calendar-day-selected';
|
|
608
|
+
if (leftDate !== rightDate) {
|
|
609
|
+
if (i !== leftDate && i !== rightDate) {
|
|
610
|
+
addClass += ' calendar-day-selected-range';
|
|
611
|
+
}
|
|
612
|
+
if (i === leftDate) {
|
|
613
|
+
addClass += ' calendar-day-selected-left';
|
|
614
|
+
}
|
|
615
|
+
if (i === rightDate) {
|
|
616
|
+
addClass += ' calendar-day-selected-right';
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
$wrapperEl.find(`.calendar-day[data-date="${valueDate.getFullYear()}-${valueDate.getMonth()}-${valueDate.getDate()}"]`).addClass(addClass);
|
|
620
|
+
}
|
|
621
|
+
valueDate = new Date(leftDate);
|
|
622
|
+
$wrapperEl.find(`.calendar-day[data-date="${valueDate.getFullYear()}-${valueDate.getMonth()}-${valueDate.getDate()}"]`).removeClass('calendar-day-selected-range').addClass('calendar-day-selected calendar-day-selected-left');
|
|
623
|
+
valueDate = new Date(rightDate);
|
|
624
|
+
$wrapperEl.find(`.calendar-day[data-date="${valueDate.getFullYear()}-${valueDate.getMonth()}-${valueDate.getDate()}"]`).removeClass('calendar-day-selected-range').addClass('calendar-day-selected calendar-day-selected-right');
|
|
625
|
+
} else {
|
|
626
|
+
for (i = 0; i < calendar.value.length; i += 1) {
|
|
627
|
+
valueDate = new Date(value[i]);
|
|
628
|
+
$wrapperEl.find(`.calendar-day[data-date="${valueDate.getFullYear()}-${valueDate.getMonth()}-${valueDate.getDate()}"]`).addClass('calendar-day-selected');
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
if (!onlyHeader) {
|
|
633
|
+
calendar.emit('local::change calendarChange', calendar, value);
|
|
634
|
+
}
|
|
635
|
+
if ($el && $el.length > 0 && calendar.hasTimePicker) {
|
|
636
|
+
$el.find('.calendar-time-selector a').text(value && value.length ? calendar.timeSelectorFormatter(value[0]) : calendar.params.timePickerPlaceholder);
|
|
637
|
+
}
|
|
638
|
+
if ($inputEl && $inputEl.length || params.header) {
|
|
639
|
+
const inputValue = calendar.formatValue(value);
|
|
640
|
+
if (params.header && $el && $el.length) {
|
|
641
|
+
$el.find('.calendar-selected-date').text(inputValue);
|
|
642
|
+
}
|
|
643
|
+
if ($inputEl && $inputEl.length && !onlyHeader) {
|
|
644
|
+
$inputEl.val(inputValue);
|
|
645
|
+
$inputEl.trigger('change');
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
updateCurrentMonthYear(dir) {
|
|
650
|
+
const calendar = this;
|
|
651
|
+
const {
|
|
652
|
+
$months,
|
|
653
|
+
$el,
|
|
654
|
+
monthNames
|
|
655
|
+
} = calendar;
|
|
656
|
+
let currentLocaleMonth;
|
|
657
|
+
let currentLocaleYear;
|
|
658
|
+
if (typeof dir === 'undefined') {
|
|
659
|
+
calendar.currentMonth = parseInt($months.eq(1).attr('data-month'), 10);
|
|
660
|
+
calendar.currentYear = parseInt($months.eq(1).attr('data-year'), 10);
|
|
661
|
+
currentLocaleMonth = $months.eq(1).attr('data-locale-month');
|
|
662
|
+
currentLocaleYear = $months.eq(1).attr('data-locale-year');
|
|
663
|
+
} else {
|
|
664
|
+
calendar.currentMonth = parseInt($months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-month'), 10);
|
|
665
|
+
calendar.currentYear = parseInt($months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-year'), 10);
|
|
666
|
+
currentLocaleMonth = $months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-locale-month');
|
|
667
|
+
currentLocaleYear = $months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-locale-year');
|
|
668
|
+
}
|
|
669
|
+
$el.find('.current-month-value').text(monthNames[currentLocaleMonth]);
|
|
670
|
+
$el.find('.current-year-value').text(currentLocaleYear);
|
|
671
|
+
}
|
|
672
|
+
update() {
|
|
673
|
+
const calendar = this;
|
|
674
|
+
const {
|
|
675
|
+
currentYear,
|
|
676
|
+
currentMonth,
|
|
677
|
+
$wrapperEl
|
|
678
|
+
} = calendar;
|
|
679
|
+
const currentDate = new Date(currentYear, currentMonth);
|
|
680
|
+
const prevMonthHtml = calendar.renderMonth(currentDate, 'prev');
|
|
681
|
+
const currentMonthHtml = calendar.renderMonth(currentDate);
|
|
682
|
+
const nextMonthHtml = calendar.renderMonth(currentDate, 'next');
|
|
683
|
+
$wrapperEl.transition(0).html(`${prevMonthHtml}${currentMonthHtml}${nextMonthHtml}`).transform('translate3d(0,0,0)');
|
|
684
|
+
calendar.$months = $wrapperEl.find('.calendar-month');
|
|
685
|
+
calendar.monthsTranslate = 0;
|
|
686
|
+
calendar.setMonthsTranslate();
|
|
687
|
+
calendar.$months.each(monthEl => {
|
|
688
|
+
calendar.emit('local::monthAdd calendarMonthAdd', monthEl);
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
onMonthChangeStart(dir) {
|
|
692
|
+
const calendar = this;
|
|
693
|
+
const {
|
|
694
|
+
$months,
|
|
695
|
+
currentYear,
|
|
696
|
+
currentMonth
|
|
697
|
+
} = calendar;
|
|
698
|
+
calendar.updateCurrentMonthYear(dir);
|
|
699
|
+
$months.removeClass('calendar-month-current calendar-month-prev calendar-month-next');
|
|
700
|
+
const currentIndex = dir === 'next' ? $months.length - 1 : 0;
|
|
701
|
+
$months.eq(currentIndex).addClass('calendar-month-current');
|
|
702
|
+
$months.eq(dir === 'next' ? currentIndex - 1 : currentIndex + 1).addClass(dir === 'next' ? 'calendar-month-prev' : 'calendar-month-next');
|
|
703
|
+
calendar.emit('local::monthYearChangeStart calendarMonthYearChangeStart', calendar, currentYear, currentMonth);
|
|
704
|
+
}
|
|
705
|
+
onMonthChangeEnd(dir, rebuildBoth) {
|
|
706
|
+
const calendar = this;
|
|
707
|
+
const {
|
|
708
|
+
currentYear,
|
|
709
|
+
currentMonth,
|
|
710
|
+
$wrapperEl,
|
|
711
|
+
monthsTranslate
|
|
712
|
+
} = calendar;
|
|
713
|
+
calendar.animating = false;
|
|
714
|
+
let nextMonthHtml;
|
|
715
|
+
let prevMonthHtml;
|
|
716
|
+
let currentMonthHtml;
|
|
717
|
+
$wrapperEl.find('.calendar-month:not(.calendar-month-prev):not(.calendar-month-current):not(.calendar-month-next)').remove();
|
|
718
|
+
if (typeof dir === 'undefined') {
|
|
719
|
+
dir = 'next'; // eslint-disable-line
|
|
720
|
+
rebuildBoth = true; // eslint-disable-line
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (!rebuildBoth) {
|
|
724
|
+
currentMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), dir);
|
|
725
|
+
} else {
|
|
726
|
+
$wrapperEl.find('.calendar-month-next, .calendar-month-prev').remove();
|
|
727
|
+
prevMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), 'prev');
|
|
728
|
+
nextMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), 'next');
|
|
729
|
+
}
|
|
730
|
+
if (dir === 'next' || rebuildBoth) {
|
|
731
|
+
$wrapperEl.append(currentMonthHtml || nextMonthHtml);
|
|
732
|
+
}
|
|
733
|
+
if (dir === 'prev' || rebuildBoth) {
|
|
734
|
+
$wrapperEl.prepend(currentMonthHtml || prevMonthHtml);
|
|
735
|
+
}
|
|
736
|
+
const $months = $wrapperEl.find('.calendar-month');
|
|
737
|
+
calendar.$months = $months;
|
|
738
|
+
calendar.setMonthsTranslate(monthsTranslate);
|
|
739
|
+
calendar.emit('local::monthAdd calendarMonthAdd', calendar, dir === 'next' ? $months.eq($months.length - 1)[0] : $months.eq(0)[0]);
|
|
740
|
+
calendar.emit('local::monthYearChangeEnd calendarMonthYearChangeEnd', calendar, currentYear, currentMonth);
|
|
741
|
+
}
|
|
742
|
+
setMonthsTranslate(translate) {
|
|
743
|
+
const calendar = this;
|
|
744
|
+
const {
|
|
745
|
+
$months,
|
|
746
|
+
isHorizontal: isH,
|
|
747
|
+
inverter
|
|
748
|
+
} = calendar;
|
|
749
|
+
// eslint-disable-next-line
|
|
750
|
+
translate = translate || calendar.monthsTranslate || 0;
|
|
751
|
+
if (typeof calendar.monthsTranslate === 'undefined') {
|
|
752
|
+
calendar.monthsTranslate = translate;
|
|
753
|
+
}
|
|
754
|
+
$months.removeClass('calendar-month-current calendar-month-prev calendar-month-next');
|
|
755
|
+
const prevMonthTranslate = -(translate + 1) * 100 * inverter;
|
|
756
|
+
const currentMonthTranslate = -translate * 100 * inverter;
|
|
757
|
+
const nextMonthTranslate = -(translate - 1) * 100 * inverter;
|
|
758
|
+
$months.eq(0).transform(`translate3d(${isH ? prevMonthTranslate : 0}%, ${isH ? 0 : prevMonthTranslate}%, 0)`).addClass('calendar-month-prev');
|
|
759
|
+
$months.eq(1).transform(`translate3d(${isH ? currentMonthTranslate : 0}%, ${isH ? 0 : currentMonthTranslate}%, 0)`).addClass('calendar-month-current');
|
|
760
|
+
$months.eq(2).transform(`translate3d(${isH ? nextMonthTranslate : 0}%, ${isH ? 0 : nextMonthTranslate}%, 0)`).addClass('calendar-month-next');
|
|
761
|
+
}
|
|
762
|
+
nextMonth(transition) {
|
|
763
|
+
const calendar = this;
|
|
764
|
+
const {
|
|
765
|
+
params,
|
|
766
|
+
$wrapperEl,
|
|
767
|
+
inverter,
|
|
768
|
+
isHorizontal: isH
|
|
769
|
+
} = calendar;
|
|
770
|
+
if (typeof transition === 'undefined' || typeof transition === 'object') {
|
|
771
|
+
transition = ''; // eslint-disable-line
|
|
772
|
+
if (!params.animate) transition = 0; // eslint-disable-line
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
const nextMonth = parseInt(calendar.$months.eq(calendar.$months.length - 1).attr('data-month'), 10);
|
|
776
|
+
const nextYear = parseInt(calendar.$months.eq(calendar.$months.length - 1).attr('data-year'), 10);
|
|
777
|
+
const nextDate = new Date(nextYear, nextMonth);
|
|
778
|
+
const nextDateTime = nextDate.getTime();
|
|
779
|
+
const transitionEndCallback = !calendar.animating;
|
|
780
|
+
if (params.maxDate) {
|
|
781
|
+
if (nextDateTime > new Date(params.maxDate).getTime()) {
|
|
782
|
+
calendar.resetMonth();
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
calendar.monthsTranslate -= 1;
|
|
787
|
+
if (nextMonth === calendar.currentMonth) {
|
|
788
|
+
const nextMonthTranslate = -calendar.monthsTranslate * 100 * inverter;
|
|
789
|
+
const nextMonthHtml = $(calendar.renderMonth(nextDateTime, 'next')).transform(`translate3d(${isH ? nextMonthTranslate : 0}%, ${isH ? 0 : nextMonthTranslate}%, 0)`).addClass('calendar-month-next');
|
|
790
|
+
$wrapperEl.append(nextMonthHtml[0]);
|
|
791
|
+
calendar.$months = $wrapperEl.find('.calendar-month');
|
|
792
|
+
calendar.emit('local::monthAdd calendarMonthAdd', calendar.$months.eq(calendar.$months.length - 1)[0]);
|
|
793
|
+
}
|
|
794
|
+
calendar.animating = true;
|
|
795
|
+
calendar.onMonthChangeStart('next');
|
|
796
|
+
const translate = calendar.monthsTranslate * 100 * inverter;
|
|
797
|
+
$wrapperEl.transition(transition).transform(`translate3d(${isH ? translate : 0}%, ${isH ? 0 : translate}%, 0)`);
|
|
798
|
+
if (transitionEndCallback) {
|
|
799
|
+
$wrapperEl.transitionEnd(() => {
|
|
800
|
+
calendar.onMonthChangeEnd('next');
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
if (!params.animate) {
|
|
804
|
+
calendar.onMonthChangeEnd('next');
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
prevMonth(transition) {
|
|
808
|
+
const calendar = this;
|
|
809
|
+
const {
|
|
810
|
+
params,
|
|
811
|
+
$wrapperEl,
|
|
812
|
+
inverter,
|
|
813
|
+
isHorizontal: isH
|
|
814
|
+
} = calendar;
|
|
815
|
+
if (typeof transition === 'undefined' || typeof transition === 'object') {
|
|
816
|
+
transition = ''; // eslint-disable-line
|
|
817
|
+
if (!params.animate) transition = 0; // eslint-disable-line
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
const prevMonth = parseInt(calendar.$months.eq(0).attr('data-month'), 10);
|
|
821
|
+
const prevYear = parseInt(calendar.$months.eq(0).attr('data-year'), 10);
|
|
822
|
+
const prevDate = new Date(prevYear, prevMonth + 1, -1);
|
|
823
|
+
const prevDateTime = prevDate.getTime();
|
|
824
|
+
const transitionEndCallback = !calendar.animating;
|
|
825
|
+
if (params.minDate) {
|
|
826
|
+
let minDate = new Date(params.minDate);
|
|
827
|
+
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), 1);
|
|
828
|
+
if (prevDateTime < minDate.getTime()) {
|
|
829
|
+
calendar.resetMonth();
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
calendar.monthsTranslate += 1;
|
|
834
|
+
if (prevMonth === calendar.currentMonth) {
|
|
835
|
+
const prevMonthTranslate = -calendar.monthsTranslate * 100 * inverter;
|
|
836
|
+
const prevMonthHtml = $(calendar.renderMonth(prevDateTime, 'prev')).transform(`translate3d(${isH ? prevMonthTranslate : 0}%, ${isH ? 0 : prevMonthTranslate}%, 0)`).addClass('calendar-month-prev');
|
|
837
|
+
$wrapperEl.prepend(prevMonthHtml[0]);
|
|
838
|
+
calendar.$months = $wrapperEl.find('.calendar-month');
|
|
839
|
+
calendar.emit('local::monthAdd calendarMonthAdd', calendar.$months.eq(0)[0]);
|
|
840
|
+
}
|
|
841
|
+
calendar.animating = true;
|
|
842
|
+
calendar.onMonthChangeStart('prev');
|
|
843
|
+
const translate = calendar.monthsTranslate * 100 * inverter;
|
|
844
|
+
$wrapperEl.transition(transition).transform(`translate3d(${isH ? translate : 0}%, ${isH ? 0 : translate}%, 0)`);
|
|
845
|
+
if (transitionEndCallback) {
|
|
846
|
+
$wrapperEl.transitionEnd(() => {
|
|
847
|
+
calendar.onMonthChangeEnd('prev');
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
if (!params.animate) {
|
|
851
|
+
calendar.onMonthChangeEnd('prev');
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
resetMonth(transition) {
|
|
855
|
+
if (transition === void 0) {
|
|
856
|
+
transition = '';
|
|
857
|
+
}
|
|
858
|
+
const calendar = this;
|
|
859
|
+
const {
|
|
860
|
+
$wrapperEl,
|
|
861
|
+
inverter,
|
|
862
|
+
isHorizontal: isH,
|
|
863
|
+
monthsTranslate
|
|
864
|
+
} = calendar;
|
|
865
|
+
const translate = monthsTranslate * 100 * inverter;
|
|
866
|
+
$wrapperEl.transition(transition).transform(`translate3d(${isH ? translate : 0}%, ${isH ? 0 : translate}%, 0)`);
|
|
867
|
+
}
|
|
868
|
+
// eslint-disable-next-line
|
|
869
|
+
setYearMonth(year, month, transition) {
|
|
870
|
+
const calendar = this;
|
|
871
|
+
const {
|
|
872
|
+
params,
|
|
873
|
+
isHorizontal: isH,
|
|
874
|
+
$wrapperEl,
|
|
875
|
+
inverter
|
|
876
|
+
} = calendar;
|
|
877
|
+
// eslint-disable-next-line
|
|
878
|
+
if (typeof year === 'undefined') year = calendar.currentYear;
|
|
879
|
+
// eslint-disable-next-line
|
|
880
|
+
if (typeof month === 'undefined') month = calendar.currentMonth;
|
|
881
|
+
if (typeof transition === 'undefined' || typeof transition === 'object') {
|
|
882
|
+
// eslint-disable-next-line
|
|
883
|
+
transition = '';
|
|
884
|
+
// eslint-disable-next-line
|
|
885
|
+
if (!params.animate) transition = 0;
|
|
886
|
+
}
|
|
887
|
+
let targetDate;
|
|
888
|
+
if (year < calendar.currentYear) {
|
|
889
|
+
targetDate = new Date(year, month + 1, -1).getTime();
|
|
890
|
+
} else {
|
|
891
|
+
targetDate = new Date(year, month).getTime();
|
|
892
|
+
}
|
|
893
|
+
if (params.maxDate && targetDate > new Date(params.maxDate).getTime()) {
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
if (params.minDate) {
|
|
897
|
+
let minDate = new Date(params.minDate);
|
|
898
|
+
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), 1);
|
|
899
|
+
if (targetDate < minDate.getTime()) {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const currentDate = new Date(calendar.currentYear, calendar.currentMonth).getTime();
|
|
904
|
+
const dir = targetDate > currentDate ? 'next' : 'prev';
|
|
905
|
+
const newMonthHTML = calendar.renderMonth(new Date(year, month));
|
|
906
|
+
calendar.monthsTranslate = calendar.monthsTranslate || 0;
|
|
907
|
+
const prevTranslate = calendar.monthsTranslate;
|
|
908
|
+
let monthTranslate;
|
|
909
|
+
const transitionEndCallback = !calendar.animating && transition !== 0;
|
|
910
|
+
if (targetDate > currentDate) {
|
|
911
|
+
// To next
|
|
912
|
+
calendar.monthsTranslate -= 1;
|
|
913
|
+
if (!calendar.animating) calendar.$months.eq(calendar.$months.length - 1).remove();
|
|
914
|
+
$wrapperEl.append(newMonthHTML);
|
|
915
|
+
calendar.$months = $wrapperEl.find('.calendar-month');
|
|
916
|
+
monthTranslate = -(prevTranslate - 1) * 100 * inverter;
|
|
917
|
+
calendar.$months.eq(calendar.$months.length - 1).transform(`translate3d(${isH ? monthTranslate : 0}%, ${isH ? 0 : monthTranslate}%, 0)`).addClass('calendar-month-next');
|
|
918
|
+
} else {
|
|
919
|
+
// To prev
|
|
920
|
+
calendar.monthsTranslate += 1;
|
|
921
|
+
if (!calendar.animating) calendar.$months.eq(0).remove();
|
|
922
|
+
$wrapperEl.prepend(newMonthHTML);
|
|
923
|
+
calendar.$months = $wrapperEl.find('.calendar-month');
|
|
924
|
+
monthTranslate = -(prevTranslate + 1) * 100 * inverter;
|
|
925
|
+
calendar.$months.eq(0).transform(`translate3d(${isH ? monthTranslate : 0}%, ${isH ? 0 : monthTranslate}%, 0)`).addClass('calendar-month-prev');
|
|
926
|
+
}
|
|
927
|
+
calendar.emit('local::monthAdd calendarMonthAdd', dir === 'next' ? calendar.$months.eq(calendar.$months.length - 1)[0] : calendar.$months.eq(0)[0]);
|
|
928
|
+
calendar.animating = true;
|
|
929
|
+
calendar.onMonthChangeStart(dir);
|
|
930
|
+
const wrapperTranslate = calendar.monthsTranslate * 100 * inverter;
|
|
931
|
+
$wrapperEl.transition(transition).transform(`translate3d(${isH ? wrapperTranslate : 0}%, ${isH ? 0 : wrapperTranslate}%, 0)`);
|
|
932
|
+
if (transitionEndCallback) {
|
|
933
|
+
$wrapperEl.transitionEnd(() => {
|
|
934
|
+
calendar.onMonthChangeEnd(dir, true);
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
if (!params.animate || transition === 0) {
|
|
938
|
+
calendar.onMonthChangeEnd(dir, true);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
nextYear() {
|
|
942
|
+
const calendar = this;
|
|
943
|
+
calendar.setYearMonth(calendar.currentYear + 1);
|
|
944
|
+
}
|
|
945
|
+
prevYear() {
|
|
946
|
+
const calendar = this;
|
|
947
|
+
calendar.setYearMonth(calendar.currentYear - 1);
|
|
948
|
+
}
|
|
949
|
+
// eslint-disable-next-line
|
|
950
|
+
dateInRange(dayDate, range) {
|
|
951
|
+
let match = false;
|
|
952
|
+
let i;
|
|
953
|
+
if (!range) return false;
|
|
954
|
+
if (Array.isArray(range)) {
|
|
955
|
+
for (i = 0; i < range.length; i += 1) {
|
|
956
|
+
if (range[i].from || range[i].to) {
|
|
957
|
+
if (range[i].from && range[i].to) {
|
|
958
|
+
if (dayDate <= new Date(range[i].to).getTime() && dayDate >= new Date(range[i].from).getTime()) {
|
|
959
|
+
match = true;
|
|
960
|
+
}
|
|
961
|
+
} else if (range[i].from) {
|
|
962
|
+
if (dayDate >= new Date(range[i].from).getTime()) {
|
|
963
|
+
match = true;
|
|
964
|
+
}
|
|
965
|
+
} else if (range[i].to) {
|
|
966
|
+
if (dayDate <= new Date(range[i].to).getTime()) {
|
|
967
|
+
match = true;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
} else if (range[i].date) {
|
|
971
|
+
if (dayDate === new Date(range[i].date).getTime()) {
|
|
972
|
+
match = true;
|
|
973
|
+
}
|
|
974
|
+
} else if (dayDate === new Date(range[i]).getTime()) {
|
|
975
|
+
match = true;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
} else if (range.from || range.to) {
|
|
979
|
+
if (range.from && range.to) {
|
|
980
|
+
if (dayDate <= new Date(range.to).getTime() && dayDate >= new Date(range.from).getTime()) {
|
|
981
|
+
match = true;
|
|
982
|
+
}
|
|
983
|
+
} else if (range.from) {
|
|
984
|
+
if (dayDate >= new Date(range.from).getTime()) {
|
|
985
|
+
match = true;
|
|
986
|
+
}
|
|
987
|
+
} else if (range.to) {
|
|
988
|
+
if (dayDate <= new Date(range.to).getTime()) {
|
|
989
|
+
match = true;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
} else if (range.date) {
|
|
993
|
+
match = dayDate === new Date(range.date).getTime();
|
|
994
|
+
} else if (typeof range === 'function') {
|
|
995
|
+
match = range(new Date(dayDate));
|
|
996
|
+
}
|
|
997
|
+
return match;
|
|
998
|
+
}
|
|
999
|
+
// eslint-disable-next-line
|
|
1000
|
+
daysInMonth(date) {
|
|
1001
|
+
const d = new Date(date);
|
|
1002
|
+
return new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
|
|
1003
|
+
}
|
|
1004
|
+
renderMonths(date) {
|
|
1005
|
+
const calendar = this;
|
|
1006
|
+
if (calendar.params.renderMonths) {
|
|
1007
|
+
return calendar.params.renderMonths.call(calendar, date);
|
|
1008
|
+
}
|
|
1009
|
+
return $jsx("div", {
|
|
1010
|
+
class: "calendar-months-wrapper"
|
|
1011
|
+
}, calendar.renderMonth(date, 'prev'), calendar.renderMonth(date), calendar.renderMonth(date, 'next'));
|
|
1012
|
+
}
|
|
1013
|
+
renderMonth(d, offset) {
|
|
1014
|
+
const calendar = this;
|
|
1015
|
+
const {
|
|
1016
|
+
params,
|
|
1017
|
+
value
|
|
1018
|
+
} = calendar;
|
|
1019
|
+
if (params.renderMonth) {
|
|
1020
|
+
return params.renderMonth.call(calendar, d, offset);
|
|
1021
|
+
}
|
|
1022
|
+
let date = new Date(d);
|
|
1023
|
+
let year = date.getFullYear();
|
|
1024
|
+
let month = date.getMonth();
|
|
1025
|
+
let localeMonth = calendar.monthNames.indexOf(calendar.monthFormatter(date));
|
|
1026
|
+
if (localeMonth < 0) localeMonth = month;
|
|
1027
|
+
let localeYear = calendar.yearFormatter(date);
|
|
1028
|
+
if (offset === 'next') {
|
|
1029
|
+
if (month === 11) date = new Date(year + 1, 0);else date = new Date(year, month + 1, 1);
|
|
1030
|
+
}
|
|
1031
|
+
if (offset === 'prev') {
|
|
1032
|
+
if (month === 0) date = new Date(year - 1, 11);else date = new Date(year, month - 1, 1);
|
|
1033
|
+
}
|
|
1034
|
+
if (offset === 'next' || offset === 'prev') {
|
|
1035
|
+
month = date.getMonth();
|
|
1036
|
+
year = date.getFullYear();
|
|
1037
|
+
localeMonth = calendar.monthNames.indexOf(calendar.monthFormatter(date));
|
|
1038
|
+
if (localeMonth < 0) localeMonth = month;
|
|
1039
|
+
localeYear = calendar.yearFormatter(date);
|
|
1040
|
+
}
|
|
1041
|
+
const currentValues = [];
|
|
1042
|
+
const today = new Date().setHours(0, 0, 0, 0);
|
|
1043
|
+
const minDate = params.minDate ? new Date(params.minDate).getTime() : null;
|
|
1044
|
+
const maxDate = params.maxDate ? new Date(params.maxDate).getTime() : null;
|
|
1045
|
+
const rows = 6;
|
|
1046
|
+
const cols = 7;
|
|
1047
|
+
const daysInPrevMonth = calendar.daysInMonth(new Date(date.getFullYear(), date.getMonth()).getTime() - 10 * 24 * 60 * 60 * 1000);
|
|
1048
|
+
const daysInMonth = calendar.daysInMonth(date);
|
|
1049
|
+
const minDayNumber = params.firstDay === 6 ? 0 : 1;
|
|
1050
|
+
let monthHtml = '';
|
|
1051
|
+
let dayIndex = 0 + (params.firstDay - 1);
|
|
1052
|
+
let disabled;
|
|
1053
|
+
let hasEvents;
|
|
1054
|
+
let firstDayOfMonthIndex = new Date(date.getFullYear(), date.getMonth()).getDay();
|
|
1055
|
+
if (firstDayOfMonthIndex === 0) firstDayOfMonthIndex = 7;
|
|
1056
|
+
if (value && value.length) {
|
|
1057
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
1058
|
+
currentValues.push(new Date(value[i]).setHours(0, 0, 0, 0));
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
for (let row = 1; row <= rows; row += 1) {
|
|
1062
|
+
let rowHtml = '';
|
|
1063
|
+
for (let col = 1; col <= cols; col += 1) {
|
|
1064
|
+
dayIndex += 1;
|
|
1065
|
+
let dayDate;
|
|
1066
|
+
let dayNumber = dayIndex - firstDayOfMonthIndex;
|
|
1067
|
+
let addClass = '';
|
|
1068
|
+
if (row === 1 && col === 1 && dayNumber > minDayNumber && params.firstDay !== 1) {
|
|
1069
|
+
dayIndex -= 7;
|
|
1070
|
+
dayNumber = dayIndex - firstDayOfMonthIndex;
|
|
1071
|
+
}
|
|
1072
|
+
const weekDayIndex = col - 1 + params.firstDay > 6 ? col - 1 - 7 + params.firstDay : col - 1 + params.firstDay;
|
|
1073
|
+
if (dayNumber < 0) {
|
|
1074
|
+
dayNumber = daysInPrevMonth + dayNumber + 1;
|
|
1075
|
+
addClass += ' calendar-day-prev';
|
|
1076
|
+
dayDate = new Date(month - 1 < 0 ? year - 1 : year, month - 1 < 0 ? 11 : month - 1, dayNumber).getTime();
|
|
1077
|
+
} else {
|
|
1078
|
+
dayNumber += 1;
|
|
1079
|
+
if (dayNumber > daysInMonth) {
|
|
1080
|
+
dayNumber -= daysInMonth;
|
|
1081
|
+
addClass += ' calendar-day-next';
|
|
1082
|
+
dayDate = new Date(month + 1 > 11 ? year + 1 : year, month + 1 > 11 ? 0 : month + 1, dayNumber).getTime();
|
|
1083
|
+
} else {
|
|
1084
|
+
dayDate = new Date(year, month, dayNumber).getTime();
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
// Today
|
|
1088
|
+
if (dayDate === today) addClass += ' calendar-day-today';
|
|
1089
|
+
|
|
1090
|
+
// Selected
|
|
1091
|
+
if (params.rangePicker && currentValues.length === 2) {
|
|
1092
|
+
if (dayDate >= currentValues[0] && dayDate <= currentValues[1]) {
|
|
1093
|
+
addClass += ' calendar-day-selected';
|
|
1094
|
+
}
|
|
1095
|
+
if (currentValues[0] !== currentValues[1]) {
|
|
1096
|
+
if (dayDate > currentValues[0] && dayDate < currentValues[1]) {
|
|
1097
|
+
addClass += ' calendar-day-selected-range';
|
|
1098
|
+
}
|
|
1099
|
+
if (dayDate === currentValues[0]) {
|
|
1100
|
+
addClass += ' calendar-day-selected-left';
|
|
1101
|
+
}
|
|
1102
|
+
if (dayDate === currentValues[1]) {
|
|
1103
|
+
addClass += ' calendar-day-selected-right';
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
} else if (currentValues.indexOf(dayDate) >= 0) addClass += ' calendar-day-selected';
|
|
1107
|
+
// Weekend
|
|
1108
|
+
if (params.weekendDays.indexOf(weekDayIndex) >= 0) {
|
|
1109
|
+
addClass += ' calendar-day-weekend';
|
|
1110
|
+
}
|
|
1111
|
+
// Events
|
|
1112
|
+
let eventsHtml = '';
|
|
1113
|
+
hasEvents = false;
|
|
1114
|
+
if (params.events) {
|
|
1115
|
+
if (calendar.dateInRange(dayDate, params.events)) {
|
|
1116
|
+
hasEvents = true;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
if (hasEvents) {
|
|
1120
|
+
addClass += ' calendar-day-has-events';
|
|
1121
|
+
// prettier-ignore
|
|
1122
|
+
eventsHtml = `
|
|
1123
|
+
<span class="calendar-day-events">
|
|
1124
|
+
<span class="calendar-day-event"></span>
|
|
1125
|
+
</span>
|
|
1126
|
+
`;
|
|
1127
|
+
if (Array.isArray(params.events)) {
|
|
1128
|
+
const eventDots = [];
|
|
1129
|
+
params.events.forEach(ev => {
|
|
1130
|
+
const color = ev.color || '';
|
|
1131
|
+
if (eventDots.indexOf(color) < 0 && calendar.dateInRange(dayDate, ev)) {
|
|
1132
|
+
eventDots.push(color);
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
// prettier-ignore
|
|
1136
|
+
eventsHtml = `
|
|
1137
|
+
<span class="calendar-day-events">
|
|
1138
|
+
${eventDots.map(color => `
|
|
1139
|
+
<span class="calendar-day-event" style="${color ? `background-color: ${color}` : ''}"></span>
|
|
1140
|
+
`.trim()).join('')}
|
|
1141
|
+
</span>
|
|
1142
|
+
`;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
// Custom Ranges
|
|
1146
|
+
if (params.rangesClasses) {
|
|
1147
|
+
for (let k = 0; k < params.rangesClasses.length; k += 1) {
|
|
1148
|
+
if (calendar.dateInRange(dayDate, params.rangesClasses[k].range)) {
|
|
1149
|
+
addClass += ` ${params.rangesClasses[k].cssClass}`;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
// Disabled
|
|
1154
|
+
disabled = false;
|
|
1155
|
+
if (minDate && dayDate < minDate || maxDate && dayDate > maxDate) {
|
|
1156
|
+
disabled = true;
|
|
1157
|
+
}
|
|
1158
|
+
if (params.disabled) {
|
|
1159
|
+
if (calendar.dateInRange(dayDate, params.disabled)) {
|
|
1160
|
+
disabled = true;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
if (disabled) {
|
|
1164
|
+
addClass += ' calendar-day-disabled';
|
|
1165
|
+
}
|
|
1166
|
+
dayDate = new Date(dayDate);
|
|
1167
|
+
const dayYear = dayDate.getFullYear();
|
|
1168
|
+
const dayMonth = dayDate.getMonth();
|
|
1169
|
+
const dayNumberDisplay = calendar.dayFormatter(dayDate);
|
|
1170
|
+
// prettier-ignore
|
|
1171
|
+
rowHtml += `
|
|
1172
|
+
<div data-year="${dayYear}" data-month="${dayMonth}" data-day="${dayNumber}" class="calendar-day${addClass}" data-date="${dayYear}-${dayMonth}-${dayNumber}">
|
|
1173
|
+
<span class="calendar-day-number">${dayNumberDisplay}${eventsHtml}</span>
|
|
1174
|
+
</div>`.trim();
|
|
1175
|
+
}
|
|
1176
|
+
monthHtml += `<div class="calendar-row">${rowHtml}</div>`;
|
|
1177
|
+
}
|
|
1178
|
+
monthHtml = `<div class="calendar-month" data-year="${year}" data-month="${month}" data-locale-year="${localeYear}" data-locale-month="${localeMonth}">${monthHtml}</div>`;
|
|
1179
|
+
return monthHtml;
|
|
1180
|
+
}
|
|
1181
|
+
renderWeekHeader() {
|
|
1182
|
+
const calendar = this;
|
|
1183
|
+
if (calendar.params.renderWeekHeader) {
|
|
1184
|
+
return calendar.params.renderWeekHeader.call(calendar);
|
|
1185
|
+
}
|
|
1186
|
+
const {
|
|
1187
|
+
params
|
|
1188
|
+
} = calendar;
|
|
1189
|
+
let weekDaysHtml = '';
|
|
1190
|
+
for (let i = 0; i < 7; i += 1) {
|
|
1191
|
+
const dayIndex = i + params.firstDay > 6 ? i - 7 + params.firstDay : i + params.firstDay;
|
|
1192
|
+
const dayName = calendar.dayNamesShort[dayIndex];
|
|
1193
|
+
weekDaysHtml += `<div class="calendar-week-day">${dayName}</div>`;
|
|
1194
|
+
}
|
|
1195
|
+
return $jsx("div", {
|
|
1196
|
+
class: "calendar-week-header"
|
|
1197
|
+
}, weekDaysHtml);
|
|
1198
|
+
}
|
|
1199
|
+
renderMonthSelector() {
|
|
1200
|
+
const calendar = this;
|
|
1201
|
+
if (calendar.params.renderMonthSelector) {
|
|
1202
|
+
return calendar.params.renderMonthSelector.call(calendar);
|
|
1203
|
+
}
|
|
1204
|
+
return $jsx("div", {
|
|
1205
|
+
class: "calendar-month-selector"
|
|
1206
|
+
}, $jsx("a", {
|
|
1207
|
+
class: "link icon-only calendar-prev-month-button"
|
|
1208
|
+
}, $jsx("i", {
|
|
1209
|
+
class: "icon icon-prev"
|
|
1210
|
+
})), calendar.params.monthPicker ? $jsx("a", {
|
|
1211
|
+
class: "current-month-value link"
|
|
1212
|
+
}) : $jsx("span", {
|
|
1213
|
+
class: "current-month-value"
|
|
1214
|
+
}), $jsx("a", {
|
|
1215
|
+
class: "link icon-only calendar-next-month-button"
|
|
1216
|
+
}, $jsx("i", {
|
|
1217
|
+
class: "icon icon-next"
|
|
1218
|
+
})));
|
|
1219
|
+
}
|
|
1220
|
+
renderYearSelector() {
|
|
1221
|
+
const calendar = this;
|
|
1222
|
+
if (calendar.params.renderYearSelector) {
|
|
1223
|
+
return calendar.params.renderYearSelector.call(calendar);
|
|
1224
|
+
}
|
|
1225
|
+
return $jsx("div", {
|
|
1226
|
+
class: "calendar-year-selector"
|
|
1227
|
+
}, $jsx("a", {
|
|
1228
|
+
class: "link icon-only calendar-prev-year-button"
|
|
1229
|
+
}, $jsx("i", {
|
|
1230
|
+
class: "icon icon-prev"
|
|
1231
|
+
})), calendar.params.yearPicker ? $jsx("a", {
|
|
1232
|
+
class: "current-year-value link"
|
|
1233
|
+
}) : $jsx("span", {
|
|
1234
|
+
class: "current-year-value"
|
|
1235
|
+
}), $jsx("a", {
|
|
1236
|
+
class: "link icon-only calendar-next-year-button"
|
|
1237
|
+
}, $jsx("i", {
|
|
1238
|
+
class: "icon icon-next"
|
|
1239
|
+
})));
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// eslint-disable-next-line
|
|
1243
|
+
renderTimeSelector() {
|
|
1244
|
+
const calendar = this;
|
|
1245
|
+
const value = calendar.value && calendar.value[0];
|
|
1246
|
+
let timeString;
|
|
1247
|
+
if (value) timeString = calendar.timeSelectorFormatter(value);
|
|
1248
|
+
return $jsx("div", {
|
|
1249
|
+
class: "calendar-time-selector"
|
|
1250
|
+
}, $jsx("span", null, calendar.params.timePickerLabel), $jsx("a", {
|
|
1251
|
+
class: "link"
|
|
1252
|
+
}, timeString || calendar.params.timePickerPlaceholder));
|
|
1253
|
+
}
|
|
1254
|
+
renderHeader() {
|
|
1255
|
+
const calendar = this;
|
|
1256
|
+
if (calendar.params.renderHeader) {
|
|
1257
|
+
return calendar.params.renderHeader.call(calendar);
|
|
1258
|
+
}
|
|
1259
|
+
return $jsx("div", {
|
|
1260
|
+
class: "calendar-header"
|
|
1261
|
+
}, $jsx("div", {
|
|
1262
|
+
class: "calendar-selected-date"
|
|
1263
|
+
}, calendar.params.headerPlaceholder));
|
|
1264
|
+
}
|
|
1265
|
+
renderFooter() {
|
|
1266
|
+
const calendar = this;
|
|
1267
|
+
const app = calendar.app;
|
|
1268
|
+
if (calendar.params.renderFooter) {
|
|
1269
|
+
return calendar.params.renderFooter.call(calendar);
|
|
1270
|
+
}
|
|
1271
|
+
return $jsx("div", {
|
|
1272
|
+
class: "calendar-footer"
|
|
1273
|
+
}, $jsx("a", {
|
|
1274
|
+
class: `${app.theme === 'md' ? 'button button-round' : 'link'} calendar-close sheet-close popover-close`
|
|
1275
|
+
}, calendar.params.toolbarCloseText));
|
|
1276
|
+
}
|
|
1277
|
+
renderToolbar() {
|
|
1278
|
+
const calendar = this;
|
|
1279
|
+
if (calendar.params.renderToolbar) {
|
|
1280
|
+
return calendar.params.renderToolbar.call(calendar, calendar);
|
|
1281
|
+
}
|
|
1282
|
+
// prettier-ignore
|
|
1283
|
+
return $jsx("div", {
|
|
1284
|
+
class: "toolbar toolbar-top"
|
|
1285
|
+
}, $jsx("div", {
|
|
1286
|
+
class: "toolbar-inner"
|
|
1287
|
+
}, calendar.params.monthSelector ? calendar.renderMonthSelector() : '', calendar.params.yearSelector ? calendar.renderYearSelector() : ''));
|
|
1288
|
+
}
|
|
1289
|
+
// eslint-disable-next-line
|
|
1290
|
+
renderInline() {
|
|
1291
|
+
const calendar = this;
|
|
1292
|
+
const {
|
|
1293
|
+
cssClass,
|
|
1294
|
+
toolbar,
|
|
1295
|
+
header,
|
|
1296
|
+
footer,
|
|
1297
|
+
rangePicker,
|
|
1298
|
+
weekHeader
|
|
1299
|
+
} = calendar.params;
|
|
1300
|
+
const {
|
|
1301
|
+
value,
|
|
1302
|
+
hasTimePicker
|
|
1303
|
+
} = calendar;
|
|
1304
|
+
const date = value && value.length ? value[0] : new Date().setHours(0, 0, 0);
|
|
1305
|
+
return $jsx("div", {
|
|
1306
|
+
class: `calendar calendar-inline ${rangePicker ? 'calendar-range' : ''} ${cssClass || ''}`
|
|
1307
|
+
}, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), $jsx("div", {
|
|
1308
|
+
class: "calendar-months"
|
|
1309
|
+
}, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter());
|
|
1310
|
+
}
|
|
1311
|
+
renderCustomModal() {
|
|
1312
|
+
const calendar = this;
|
|
1313
|
+
const {
|
|
1314
|
+
cssClass,
|
|
1315
|
+
toolbar,
|
|
1316
|
+
header,
|
|
1317
|
+
footer,
|
|
1318
|
+
rangePicker,
|
|
1319
|
+
weekHeader
|
|
1320
|
+
} = calendar.params;
|
|
1321
|
+
const {
|
|
1322
|
+
value,
|
|
1323
|
+
hasTimePicker
|
|
1324
|
+
} = calendar;
|
|
1325
|
+
const date = value && value.length ? value[0] : new Date().setHours(0, 0, 0);
|
|
1326
|
+
return $jsx("div", {
|
|
1327
|
+
class: `calendar calendar-modal ${rangePicker ? 'calendar-range' : ''} ${cssClass || ''}`
|
|
1328
|
+
}, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), $jsx("div", {
|
|
1329
|
+
class: "calendar-months"
|
|
1330
|
+
}, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter());
|
|
1331
|
+
}
|
|
1332
|
+
renderSheet() {
|
|
1333
|
+
const calendar = this;
|
|
1334
|
+
const {
|
|
1335
|
+
cssClass,
|
|
1336
|
+
toolbar,
|
|
1337
|
+
header,
|
|
1338
|
+
footer,
|
|
1339
|
+
rangePicker,
|
|
1340
|
+
weekHeader
|
|
1341
|
+
} = calendar.params;
|
|
1342
|
+
const {
|
|
1343
|
+
value,
|
|
1344
|
+
hasTimePicker
|
|
1345
|
+
} = calendar;
|
|
1346
|
+
const date = value && value.length ? value[0] : new Date().setHours(0, 0, 0);
|
|
1347
|
+
return $jsx("div", {
|
|
1348
|
+
class: `sheet-modal calendar calendar-sheet ${rangePicker ? 'calendar-range' : ''} ${cssClass || ''}`
|
|
1349
|
+
}, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), $jsx("div", {
|
|
1350
|
+
class: "sheet-modal-inner calendar-months"
|
|
1351
|
+
}, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter());
|
|
1352
|
+
}
|
|
1353
|
+
renderPopover() {
|
|
1354
|
+
const calendar = this;
|
|
1355
|
+
const {
|
|
1356
|
+
cssClass,
|
|
1357
|
+
toolbar,
|
|
1358
|
+
header,
|
|
1359
|
+
footer,
|
|
1360
|
+
rangePicker,
|
|
1361
|
+
weekHeader
|
|
1362
|
+
} = calendar.params;
|
|
1363
|
+
const {
|
|
1364
|
+
value,
|
|
1365
|
+
hasTimePicker
|
|
1366
|
+
} = calendar;
|
|
1367
|
+
const date = value && value.length ? value[0] : new Date().setHours(0, 0, 0);
|
|
1368
|
+
return $jsx("div", {
|
|
1369
|
+
class: "popover calendar-popover"
|
|
1370
|
+
}, $jsx("div", {
|
|
1371
|
+
class: "popover-inner"
|
|
1372
|
+
}, $jsx("div", {
|
|
1373
|
+
class: `calendar ${rangePicker ? 'calendar-range' : ''} ${cssClass || ''}`
|
|
1374
|
+
}, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), $jsx("div", {
|
|
1375
|
+
class: "calendar-months"
|
|
1376
|
+
}, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter())));
|
|
1377
|
+
}
|
|
1378
|
+
render() {
|
|
1379
|
+
const calendar = this;
|
|
1380
|
+
const {
|
|
1381
|
+
params
|
|
1382
|
+
} = calendar;
|
|
1383
|
+
if (params.render) return params.render.call(calendar);
|
|
1384
|
+
if (!calendar.inline) {
|
|
1385
|
+
let modalType = params.openIn;
|
|
1386
|
+
if (modalType === 'auto') modalType = calendar.isPopover() ? 'popover' : 'sheet';
|
|
1387
|
+
if (modalType === 'popover') return calendar.renderPopover();
|
|
1388
|
+
if (modalType === 'sheet') return calendar.renderSheet();
|
|
1389
|
+
return calendar.renderCustomModal();
|
|
1390
|
+
}
|
|
1391
|
+
return calendar.renderInline();
|
|
1392
|
+
}
|
|
1393
|
+
openMonthPicker() {
|
|
1394
|
+
const calendar = this;
|
|
1395
|
+
const {
|
|
1396
|
+
$el,
|
|
1397
|
+
app
|
|
1398
|
+
} = calendar;
|
|
1399
|
+
if (!$el || !$el.length) return;
|
|
1400
|
+
$el.append('<div class="popover calendar-popover calendar-month-picker-popover"><div class="popover-inner"><div class="calendar-month-picker"></div></div></div>');
|
|
1401
|
+
calendar.monthPickerPopover = app.popover.create({
|
|
1402
|
+
el: $el.find('.calendar-month-picker-popover'),
|
|
1403
|
+
targetEl: $el.find('.calendar-month-selector'),
|
|
1404
|
+
backdrop: true,
|
|
1405
|
+
backdropUnique: true,
|
|
1406
|
+
on: {
|
|
1407
|
+
close() {
|
|
1408
|
+
calendar.closeMonthPicker();
|
|
1409
|
+
},
|
|
1410
|
+
closed() {
|
|
1411
|
+
if (calendar.monthPickerPopover.$el) calendar.monthPickerPopover.$el.remove();
|
|
1412
|
+
calendar.monthPickerPopover.destroy();
|
|
1413
|
+
if (calendar.monthPickerInstance) {
|
|
1414
|
+
calendar.monthPickerInstance.close();
|
|
1415
|
+
calendar.monthPickerInstance.destroy();
|
|
1416
|
+
}
|
|
1417
|
+
delete calendar.monthPickerInstance;
|
|
1418
|
+
delete calendar.monthPickerPopover;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
calendar.monthPickerPopover.open();
|
|
1423
|
+
const localeMonth = parseInt(calendar.$el.find('.calendar-month-current').attr('data-locale-month'), 10);
|
|
1424
|
+
const values = [];
|
|
1425
|
+
const displayValues = [];
|
|
1426
|
+
calendar.monthNames.forEach((m, index) => {
|
|
1427
|
+
values.push(index);
|
|
1428
|
+
displayValues.push(m);
|
|
1429
|
+
});
|
|
1430
|
+
calendar.monthPickerInstance = app.picker.create({
|
|
1431
|
+
containerEl: calendar.monthPickerPopover.$el.find('.calendar-month-picker'),
|
|
1432
|
+
value: [localeMonth],
|
|
1433
|
+
toolbar: calendar.params.monthPickerToolbar,
|
|
1434
|
+
rotateEffect: false,
|
|
1435
|
+
toolbarCloseText: calendar.params.monthPickerCloseText,
|
|
1436
|
+
cols: [{
|
|
1437
|
+
values,
|
|
1438
|
+
displayValues
|
|
1439
|
+
}]
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
closeMonthPicker() {
|
|
1443
|
+
const calendar = this;
|
|
1444
|
+
if (calendar.monthPickerPopover && calendar.monthPickerPopover.opened) calendar.monthPickerPopover.close();
|
|
1445
|
+
const index = calendar.monthPickerInstance.value[0];
|
|
1446
|
+
const localeMonthIndex = parseInt(calendar.$el.find('.calendar-month-current').attr('data-locale-month'), 10);
|
|
1447
|
+
const monthIndex = calendar.currentMonth;
|
|
1448
|
+
const diff = localeMonthIndex - monthIndex;
|
|
1449
|
+
const diffIndex = index - diff;
|
|
1450
|
+
calendar.setYearMonth(calendar.currentYear, diffIndex, 0);
|
|
1451
|
+
}
|
|
1452
|
+
openYearPicker() {
|
|
1453
|
+
const calendar = this;
|
|
1454
|
+
const {
|
|
1455
|
+
$el,
|
|
1456
|
+
app
|
|
1457
|
+
} = calendar;
|
|
1458
|
+
if (!$el || !$el.length) return;
|
|
1459
|
+
$el.append('<div class="popover calendar-popover calendar-year-picker-popover"><div class="popover-inner"><div class="calendar-year-picker"></div></div></div>');
|
|
1460
|
+
calendar.yearPickerPopover = app.popover.create({
|
|
1461
|
+
el: $el.find('.calendar-year-picker-popover'),
|
|
1462
|
+
targetEl: $el.find('.calendar-year-selector'),
|
|
1463
|
+
backdrop: true,
|
|
1464
|
+
backdropUnique: true,
|
|
1465
|
+
on: {
|
|
1466
|
+
close() {
|
|
1467
|
+
calendar.closeYearPicker();
|
|
1468
|
+
},
|
|
1469
|
+
closed() {
|
|
1470
|
+
if (calendar.yearPickerPopover.$el) calendar.yearPickerPopover.$el.remove();
|
|
1471
|
+
calendar.yearPickerPopover.destroy();
|
|
1472
|
+
if (calendar.yearPickerInstance) {
|
|
1473
|
+
calendar.yearPickerInstance.close();
|
|
1474
|
+
calendar.yearPickerInstance.destroy();
|
|
1475
|
+
}
|
|
1476
|
+
delete calendar.yearPickerInstance;
|
|
1477
|
+
delete calendar.yearPickerPopover;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
calendar.yearPickerPopover.open();
|
|
1482
|
+
const currentYear = calendar.currentYear;
|
|
1483
|
+
let yearMin = calendar.params.yearPickerMin || new Date().getFullYear() - 100;
|
|
1484
|
+
if (calendar.params.minDate) {
|
|
1485
|
+
yearMin = Math.max(yearMin, new Date(calendar.params.minDate).getFullYear());
|
|
1486
|
+
}
|
|
1487
|
+
let yearMax = calendar.params.yearPickerMax || new Date().getFullYear() + 100;
|
|
1488
|
+
if (calendar.params.maxDate) {
|
|
1489
|
+
yearMax = Math.min(yearMax, new Date(calendar.params.maxDate).getFullYear());
|
|
1490
|
+
}
|
|
1491
|
+
const years = [];
|
|
1492
|
+
for (let i = yearMin; i <= yearMax; i += 1) {
|
|
1493
|
+
years.push(i);
|
|
1494
|
+
}
|
|
1495
|
+
calendar.yearPickerInstance = app.picker.create({
|
|
1496
|
+
containerEl: calendar.yearPickerPopover.$el.find('.calendar-year-picker'),
|
|
1497
|
+
value: [currentYear],
|
|
1498
|
+
toolbar: calendar.params.yearPickerToolbar,
|
|
1499
|
+
rotateEffect: false,
|
|
1500
|
+
toolbarCloseText: calendar.params.yearPickerCloseText,
|
|
1501
|
+
cols: [{
|
|
1502
|
+
values: years
|
|
1503
|
+
}]
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
closeYearPicker() {
|
|
1507
|
+
const calendar = this;
|
|
1508
|
+
if (calendar.yearPickerPopover && calendar.yearPickerPopover.opened) calendar.yearPickerPopover.close();
|
|
1509
|
+
calendar.setYearMonth(calendar.yearPickerInstance.value[0], undefined, 0);
|
|
1510
|
+
}
|
|
1511
|
+
openTimePicker() {
|
|
1512
|
+
const calendar = this;
|
|
1513
|
+
const {
|
|
1514
|
+
$el,
|
|
1515
|
+
app,
|
|
1516
|
+
is12HoursFormat
|
|
1517
|
+
} = calendar;
|
|
1518
|
+
if (!$el || !$el.length) return;
|
|
1519
|
+
$el.append('<div class="popover calendar-popover calendar-time-picker-popover"><div class="popover-inner"><div class="calendar-time-picker"></div></div></div>');
|
|
1520
|
+
const hoursArr = [];
|
|
1521
|
+
const minutesArr = [];
|
|
1522
|
+
const hoursMin = is12HoursFormat ? 1 : 0;
|
|
1523
|
+
const hoursMax = is12HoursFormat ? 12 : 23;
|
|
1524
|
+
for (let i = hoursMin; i <= hoursMax; i += 1) {
|
|
1525
|
+
hoursArr.push(i);
|
|
1526
|
+
}
|
|
1527
|
+
for (let i = 0; i <= 59; i += 1) {
|
|
1528
|
+
minutesArr.push(i);
|
|
1529
|
+
}
|
|
1530
|
+
let value;
|
|
1531
|
+
if (calendar.value && calendar.value.length) {
|
|
1532
|
+
value = [calendar.value[0].getHours(), calendar.value[0].getMinutes()];
|
|
1533
|
+
} else {
|
|
1534
|
+
value = [new Date().getHours(), new Date().getMinutes()];
|
|
1535
|
+
}
|
|
1536
|
+
if (is12HoursFormat) {
|
|
1537
|
+
value.push(value[0] < 12 ? 'AM' : 'PM');
|
|
1538
|
+
if (value[0] > 12) value[0] -= 12;
|
|
1539
|
+
if (value[0] === 0) value[0] = 12;
|
|
1540
|
+
}
|
|
1541
|
+
calendar.timePickerPopover = app.popover.create({
|
|
1542
|
+
el: $el.find('.calendar-time-picker-popover'),
|
|
1543
|
+
targetEl: $el.find('.calendar-time-selector .link'),
|
|
1544
|
+
backdrop: true,
|
|
1545
|
+
backdropUnique: true,
|
|
1546
|
+
on: {
|
|
1547
|
+
close() {
|
|
1548
|
+
calendar.closeTimePicker();
|
|
1549
|
+
},
|
|
1550
|
+
closed() {
|
|
1551
|
+
if (calendar.timePickerPopover.$el) calendar.timePickerPopover.$el.remove();
|
|
1552
|
+
calendar.timePickerPopover.destroy();
|
|
1553
|
+
if (calendar.timePickerInstance) {
|
|
1554
|
+
calendar.timePickerInstance.close();
|
|
1555
|
+
calendar.timePickerInstance.destroy();
|
|
1556
|
+
}
|
|
1557
|
+
delete calendar.timePickerInstance;
|
|
1558
|
+
delete calendar.timePickerPopover;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
calendar.timePickerPopover.open();
|
|
1563
|
+
calendar.timePickerInstance = app.picker.create({
|
|
1564
|
+
containerEl: calendar.timePickerPopover.$el.find('.calendar-time-picker'),
|
|
1565
|
+
value,
|
|
1566
|
+
toolbar: calendar.params.timePickerToolbar,
|
|
1567
|
+
rotateEffect: false,
|
|
1568
|
+
toolbarCloseText: calendar.params.timePickerCloseText,
|
|
1569
|
+
cols: [{
|
|
1570
|
+
values: hoursArr
|
|
1571
|
+
}, {
|
|
1572
|
+
divider: true,
|
|
1573
|
+
content: ':'
|
|
1574
|
+
}, {
|
|
1575
|
+
values: minutesArr,
|
|
1576
|
+
displayValues: minutesArr.map(m => m < 10 ? `0${m}` : m)
|
|
1577
|
+
}, ...(is12HoursFormat ? [{
|
|
1578
|
+
values: ['AM', 'PM']
|
|
1579
|
+
}] : [])]
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
closeTimePicker() {
|
|
1583
|
+
const calendar = this;
|
|
1584
|
+
const {
|
|
1585
|
+
is12HoursFormat
|
|
1586
|
+
} = calendar;
|
|
1587
|
+
if (calendar.timePickerInstance) {
|
|
1588
|
+
const timePickerValue = calendar.timePickerInstance.value;
|
|
1589
|
+
let hours = parseInt(timePickerValue[0], 10);
|
|
1590
|
+
const minutes = parseInt(timePickerValue[1], 10);
|
|
1591
|
+
const period = calendar.timePickerInstance.value[2];
|
|
1592
|
+
if (is12HoursFormat) {
|
|
1593
|
+
if (period === 'AM' && hours === 12) {
|
|
1594
|
+
hours = 0;
|
|
1595
|
+
} else if (period === 'PM' && hours !== 12) {
|
|
1596
|
+
hours += 12;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
let value = calendar.value && calendar.value.length && calendar.value[0];
|
|
1600
|
+
if (!value) {
|
|
1601
|
+
value = new Date();
|
|
1602
|
+
value.setHours(hours, minutes, 0, 0);
|
|
1603
|
+
} else {
|
|
1604
|
+
value = new Date(value);
|
|
1605
|
+
value.setHours(hours, minutes);
|
|
1606
|
+
}
|
|
1607
|
+
calendar.setValue([value]);
|
|
1608
|
+
if (calendar.timePickerPopover && calendar.timePickerPopover.opened) calendar.timePickerPopover.close();
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
onOpen() {
|
|
1612
|
+
const calendar = this;
|
|
1613
|
+
const {
|
|
1614
|
+
initialized,
|
|
1615
|
+
$el,
|
|
1616
|
+
app,
|
|
1617
|
+
$inputEl,
|
|
1618
|
+
inline,
|
|
1619
|
+
value,
|
|
1620
|
+
params
|
|
1621
|
+
} = calendar;
|
|
1622
|
+
calendar.closing = false;
|
|
1623
|
+
calendar.opened = true;
|
|
1624
|
+
calendar.opening = true;
|
|
1625
|
+
|
|
1626
|
+
// Init main events
|
|
1627
|
+
calendar.attachCalendarEvents();
|
|
1628
|
+
const updateValue = !value && params.value;
|
|
1629
|
+
|
|
1630
|
+
// Set value
|
|
1631
|
+
if (!initialized) {
|
|
1632
|
+
if (value) calendar.setValue(value, 0);else if (params.value) {
|
|
1633
|
+
calendar.setValue(calendar.normalizeValues(params.value), 0);
|
|
1634
|
+
}
|
|
1635
|
+
} else if (value) {
|
|
1636
|
+
calendar.setValue(value, 0);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// Update current month and year
|
|
1640
|
+
calendar.updateCurrentMonthYear();
|
|
1641
|
+
|
|
1642
|
+
// Set initial translate
|
|
1643
|
+
calendar.monthsTranslate = 0;
|
|
1644
|
+
calendar.setMonthsTranslate();
|
|
1645
|
+
|
|
1646
|
+
// Update input value
|
|
1647
|
+
if (updateValue) calendar.updateValue();else if (params.header && value) {
|
|
1648
|
+
calendar.updateValue(true);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// Extra focus
|
|
1652
|
+
if (!inline && $inputEl && $inputEl.length && app.theme === 'md') {
|
|
1653
|
+
$inputEl.trigger('focus');
|
|
1654
|
+
}
|
|
1655
|
+
calendar.initialized = true;
|
|
1656
|
+
calendar.$months.each(monthEl => {
|
|
1657
|
+
calendar.emit('local::monthAdd calendarMonthAdd', monthEl);
|
|
1658
|
+
});
|
|
1659
|
+
|
|
1660
|
+
// Trigger events
|
|
1661
|
+
if ($el) {
|
|
1662
|
+
$el.trigger('calendar:open');
|
|
1663
|
+
}
|
|
1664
|
+
if ($inputEl) {
|
|
1665
|
+
$inputEl.trigger('calendar:open');
|
|
1666
|
+
}
|
|
1667
|
+
calendar.emit('local::open calendarOpen', calendar);
|
|
1668
|
+
}
|
|
1669
|
+
onOpened() {
|
|
1670
|
+
const calendar = this;
|
|
1671
|
+
calendar.opening = false;
|
|
1672
|
+
if (calendar.$el) {
|
|
1673
|
+
calendar.$el.trigger('calendar:opened');
|
|
1674
|
+
}
|
|
1675
|
+
if (calendar.$inputEl) {
|
|
1676
|
+
calendar.$inputEl.trigger('calendar:opened');
|
|
1677
|
+
}
|
|
1678
|
+
calendar.emit('local::opened calendarOpened', calendar);
|
|
1679
|
+
}
|
|
1680
|
+
onClose() {
|
|
1681
|
+
const calendar = this;
|
|
1682
|
+
const app = calendar.app;
|
|
1683
|
+
calendar.opening = false;
|
|
1684
|
+
calendar.closing = true;
|
|
1685
|
+
if (calendar.$inputEl) {
|
|
1686
|
+
if (app.theme === 'md') {
|
|
1687
|
+
calendar.$inputEl.trigger('blur');
|
|
1688
|
+
} else {
|
|
1689
|
+
const validate = calendar.$inputEl.attr('validate');
|
|
1690
|
+
const required = calendar.$inputEl.attr('required');
|
|
1691
|
+
if (validate && required) {
|
|
1692
|
+
app.input.validate(calendar.$inputEl);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
if (calendar.detachCalendarEvents) {
|
|
1697
|
+
calendar.detachCalendarEvents();
|
|
1698
|
+
}
|
|
1699
|
+
if (calendar.$el) {
|
|
1700
|
+
calendar.$el.trigger('calendar:close');
|
|
1701
|
+
}
|
|
1702
|
+
if (calendar.$inputEl) {
|
|
1703
|
+
calendar.$inputEl.trigger('calendar:close');
|
|
1704
|
+
}
|
|
1705
|
+
calendar.emit('local::close calendarClose', calendar);
|
|
1706
|
+
}
|
|
1707
|
+
onClosed() {
|
|
1708
|
+
const calendar = this;
|
|
1709
|
+
calendar.opened = false;
|
|
1710
|
+
calendar.closing = false;
|
|
1711
|
+
if (!calendar.inline) {
|
|
1712
|
+
nextTick(() => {
|
|
1713
|
+
if (calendar.modal && calendar.modal.el && calendar.modal.destroy) {
|
|
1714
|
+
if (!calendar.params.routableModals) {
|
|
1715
|
+
calendar.modal.destroy();
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
delete calendar.modal;
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
if (calendar.timePickerInstance) {
|
|
1722
|
+
if (calendar.timePickerInstance.destroy) calendar.timePickerInstance.destroy();
|
|
1723
|
+
delete calendar.timePickerInstance;
|
|
1724
|
+
}
|
|
1725
|
+
if (calendar.$el) {
|
|
1726
|
+
calendar.$el.trigger('calendar:closed');
|
|
1727
|
+
}
|
|
1728
|
+
if (calendar.$inputEl) {
|
|
1729
|
+
calendar.$inputEl.trigger('calendar:closed');
|
|
1730
|
+
}
|
|
1731
|
+
calendar.emit('local::closed calendarClosed', calendar);
|
|
1732
|
+
}
|
|
1733
|
+
open() {
|
|
1734
|
+
const calendar = this;
|
|
1735
|
+
const {
|
|
1736
|
+
app,
|
|
1737
|
+
opened,
|
|
1738
|
+
inline,
|
|
1739
|
+
$inputEl,
|
|
1740
|
+
params
|
|
1741
|
+
} = calendar;
|
|
1742
|
+
if (opened) return;
|
|
1743
|
+
if (inline) {
|
|
1744
|
+
calendar.$el = $(calendar.render());
|
|
1745
|
+
calendar.$el[0].f7Calendar = calendar;
|
|
1746
|
+
calendar.$wrapperEl = calendar.$el.find('.calendar-months-wrapper');
|
|
1747
|
+
calendar.$months = calendar.$wrapperEl.find('.calendar-month');
|
|
1748
|
+
calendar.$containerEl.append(calendar.$el);
|
|
1749
|
+
calendar.onOpen();
|
|
1750
|
+
calendar.onOpened();
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
let modalType = params.openIn;
|
|
1754
|
+
if (modalType === 'auto') {
|
|
1755
|
+
modalType = calendar.isPopover() ? 'popover' : 'sheet';
|
|
1756
|
+
}
|
|
1757
|
+
const modalContent = calendar.render();
|
|
1758
|
+
const modalParams = {
|
|
1759
|
+
targetEl: $inputEl,
|
|
1760
|
+
scrollToEl: params.scrollToInput ? $inputEl : undefined,
|
|
1761
|
+
content: modalContent,
|
|
1762
|
+
backdrop: params.backdrop === true || (modalType === 'popover' || modalType === 'customModal') && app.params.popover.backdrop !== false && params.backdrop !== false,
|
|
1763
|
+
closeByBackdropClick: params.closeByBackdropClick,
|
|
1764
|
+
on: {
|
|
1765
|
+
open() {
|
|
1766
|
+
const modal = this;
|
|
1767
|
+
calendar.modal = modal;
|
|
1768
|
+
calendar.$el = modalType === 'popover' ? modal.$el.find('.calendar') : modal.$el;
|
|
1769
|
+
calendar.$wrapperEl = calendar.$el.find('.calendar-months-wrapper');
|
|
1770
|
+
calendar.$months = calendar.$wrapperEl.find('.calendar-month');
|
|
1771
|
+
calendar.$el[0].f7Calendar = calendar;
|
|
1772
|
+
if (modalType === 'customModal') {
|
|
1773
|
+
$(calendar.$el).find('.calendar-close').once('click', () => {
|
|
1774
|
+
calendar.close();
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
calendar.onOpen();
|
|
1778
|
+
},
|
|
1779
|
+
opened() {
|
|
1780
|
+
calendar.onOpened();
|
|
1781
|
+
},
|
|
1782
|
+
close() {
|
|
1783
|
+
calendar.onClose();
|
|
1784
|
+
},
|
|
1785
|
+
closed() {
|
|
1786
|
+
calendar.onClosed();
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
if (modalType === 'sheet') {
|
|
1791
|
+
modalParams.push = params.sheetPush;
|
|
1792
|
+
modalParams.swipeToClose = params.sheetSwipeToClose;
|
|
1793
|
+
}
|
|
1794
|
+
if (params.routableModals && calendar.view) {
|
|
1795
|
+
calendar.view.router.navigate({
|
|
1796
|
+
url: calendar.url,
|
|
1797
|
+
route: {
|
|
1798
|
+
path: calendar.url,
|
|
1799
|
+
[modalType]: modalParams
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
} else {
|
|
1803
|
+
calendar.modal = app[modalType].create(modalParams);
|
|
1804
|
+
calendar.modal.open();
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
close() {
|
|
1808
|
+
const calendar = this;
|
|
1809
|
+
const {
|
|
1810
|
+
opened,
|
|
1811
|
+
inline
|
|
1812
|
+
} = calendar;
|
|
1813
|
+
if (!opened) return;
|
|
1814
|
+
if (inline) {
|
|
1815
|
+
calendar.onClose();
|
|
1816
|
+
calendar.onClosed();
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
if (calendar.params.routableModals && calendar.view) {
|
|
1820
|
+
calendar.view.router.back();
|
|
1821
|
+
} else {
|
|
1822
|
+
calendar.modal.close();
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
init() {
|
|
1826
|
+
const calendar = this;
|
|
1827
|
+
calendar.initInput();
|
|
1828
|
+
if (calendar.inline) {
|
|
1829
|
+
calendar.open();
|
|
1830
|
+
calendar.emit('local::init calendarInit', calendar);
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
if (!calendar.initialized && calendar.params.value) {
|
|
1834
|
+
calendar.setValue(calendar.normalizeValues(calendar.params.value));
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
// Attach input Events
|
|
1838
|
+
if (calendar.$inputEl) {
|
|
1839
|
+
calendar.attachInputEvents();
|
|
1840
|
+
}
|
|
1841
|
+
if (calendar.params.closeByOutsideClick) {
|
|
1842
|
+
calendar.attachHtmlEvents();
|
|
1843
|
+
}
|
|
1844
|
+
calendar.emit('local::init calendarInit', calendar);
|
|
1845
|
+
}
|
|
1846
|
+
destroy() {
|
|
1847
|
+
const calendar = this;
|
|
1848
|
+
if (calendar.destroyed) return;
|
|
1849
|
+
const {
|
|
1850
|
+
$el
|
|
1851
|
+
} = calendar;
|
|
1852
|
+
calendar.emit('local::beforeDestroy calendarBeforeDestroy', calendar);
|
|
1853
|
+
if ($el) $el.trigger('calendar:beforedestroy');
|
|
1854
|
+
calendar.close();
|
|
1855
|
+
|
|
1856
|
+
// Detach Events
|
|
1857
|
+
if (calendar.$inputEl) {
|
|
1858
|
+
calendar.detachInputEvents();
|
|
1859
|
+
}
|
|
1860
|
+
if (calendar.params.closeByOutsideClick) {
|
|
1861
|
+
calendar.detachHtmlEvents();
|
|
1862
|
+
}
|
|
1863
|
+
if (calendar.timePickerInstance) {
|
|
1864
|
+
if (calendar.timePickerInstance.destroy) calendar.timePickerInstance.destroy();
|
|
1865
|
+
delete calendar.timePickerInstance;
|
|
1866
|
+
}
|
|
1867
|
+
if ($el && $el.length) delete calendar.$el[0].f7Calendar;
|
|
1868
|
+
deleteProps(calendar);
|
|
1869
|
+
calendar.destroyed = true;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
export default Calendar;
|