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