Formatted some function names
This commit is contained in:
@@ -16,7 +16,7 @@ interface DirectionLabels {
|
|||||||
futureFar: string
|
futureFar: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const { currentConfig, decrementMonth, incrementMonth, decrementYear, incrementYear } =
|
const { currentConfig, decrementViewMonth, incrementViewMonth, decrementViewYear, incrementViewYear } =
|
||||||
useCalendar()
|
useCalendar()
|
||||||
|
|
||||||
const activeDirectionLabels: ComputedRef<DirectionLabels> = computed(() => {
|
const activeDirectionLabels: ComputedRef<DirectionLabels> = computed(() => {
|
||||||
@@ -59,20 +59,20 @@ const activeDirectionLabels: ComputedRef<DirectionLabels> = computed(() => {
|
|||||||
function toPastFar(): void {
|
function toPastFar(): void {
|
||||||
switch (currentConfig.viewType) {
|
switch (currentConfig.viewType) {
|
||||||
case 'month':
|
case 'month':
|
||||||
decrementYear()
|
decrementViewYear()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'year':
|
case 'year':
|
||||||
decrementYear(10)
|
decrementViewYear(10)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'decade':
|
case 'decade':
|
||||||
decrementYear(100)
|
decrementViewYear(100)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'century':
|
case 'century':
|
||||||
default:
|
default:
|
||||||
decrementYear(1000)
|
decrementViewYear(1000)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,20 +80,20 @@ function toPastFar(): void {
|
|||||||
function toPastNear(): void {
|
function toPastNear(): void {
|
||||||
switch (currentConfig.viewType) {
|
switch (currentConfig.viewType) {
|
||||||
case 'month':
|
case 'month':
|
||||||
decrementMonth()
|
decrementViewMonth()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'year':
|
case 'year':
|
||||||
decrementYear()
|
decrementViewYear()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'decade':
|
case 'decade':
|
||||||
decrementYear(10)
|
decrementViewYear(10)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'century':
|
case 'century':
|
||||||
default:
|
default:
|
||||||
decrementYear(100)
|
decrementViewYear(100)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,20 +101,20 @@ function toPastNear(): void {
|
|||||||
function toFutureNear(): void {
|
function toFutureNear(): void {
|
||||||
switch (currentConfig.viewType) {
|
switch (currentConfig.viewType) {
|
||||||
case 'month':
|
case 'month':
|
||||||
incrementMonth()
|
incrementViewMonth()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'year':
|
case 'year':
|
||||||
incrementYear()
|
incrementViewYear()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'decade':
|
case 'decade':
|
||||||
incrementYear(10)
|
incrementViewYear(10)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'century':
|
case 'century':
|
||||||
default:
|
default:
|
||||||
incrementYear(100)
|
incrementViewYear(100)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,20 +122,20 @@ function toFutureNear(): void {
|
|||||||
function toFutureFar(): void {
|
function toFutureFar(): void {
|
||||||
switch (currentConfig.viewType) {
|
switch (currentConfig.viewType) {
|
||||||
case 'month':
|
case 'month':
|
||||||
incrementYear()
|
incrementViewYear()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'year':
|
case 'year':
|
||||||
incrementYear(10)
|
incrementViewYear(10)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'decade':
|
case 'decade':
|
||||||
incrementYear(100)
|
incrementViewYear(100)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'century':
|
case 'century':
|
||||||
default:
|
default:
|
||||||
incrementYear(1000)
|
incrementViewYear(1000)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { useCalendar } from '@/stores/CalendarStore'
|
import { useCalendar } from '@/stores/CalendarStore'
|
||||||
import { useThrottleFn } from '@vueuse/core'
|
import { useThrottleFn } from '@vueuse/core'
|
||||||
|
|
||||||
const { currentDate, decrementMonth, incrementMonth } = useCalendar()
|
const { currentDate, decrementViewMonth, incrementViewMonth } = useCalendar()
|
||||||
const { currentMonthData } = storeToRefs(useCalendar())
|
const { currentMonthData } = storeToRefs(useCalendar())
|
||||||
|
|
||||||
function handleWheel(e: WheelEvent) {
|
function handleWheel(e: WheelEvent) {
|
||||||
@@ -15,11 +15,11 @@ function handleWheel(e: WheelEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const moveCalendarLeft = useThrottleFn(() => {
|
const moveCalendarLeft = useThrottleFn(() => {
|
||||||
decrementMonth()
|
decrementViewMonth()
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
const moveCalendarRight = useThrottleFn(() => {
|
const moveCalendarRight = useThrottleFn(() => {
|
||||||
incrementMonth()
|
incrementViewMonth()
|
||||||
}, 100)
|
}, 100)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { useCalendar } from '@/stores/CalendarStore'
|
import { useCalendar } from '@/stores/CalendarStore'
|
||||||
import { useThrottleFn } from '@vueuse/core'
|
import { useThrottleFn } from '@vueuse/core'
|
||||||
|
|
||||||
const { decrementYear, incrementYear } = useCalendar()
|
const { decrementViewYear, incrementViewYear } = useCalendar()
|
||||||
const { sortedMonths: months } = storeToRefs(useCalendar())
|
const { sortedMonths: months } = storeToRefs(useCalendar())
|
||||||
|
|
||||||
function handleWheel(e: WheelEvent) {
|
function handleWheel(e: WheelEvent) {
|
||||||
@@ -15,11 +15,11 @@ function handleWheel(e: WheelEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const moveCalendarLeft = useThrottleFn(() => {
|
const moveCalendarLeft = useThrottleFn(() => {
|
||||||
decrementYear()
|
decrementViewYear()
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
const moveCalendarRight = useThrottleFn(() => {
|
const moveCalendarRight = useThrottleFn(() => {
|
||||||
incrementYear()
|
incrementViewYear()
|
||||||
}, 100)
|
}, 100)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -205,14 +205,14 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
/**
|
/**
|
||||||
* Moves the current date forward one month
|
* Moves the current date forward one month
|
||||||
*/
|
*/
|
||||||
function incrementMonth(): void {
|
function incrementViewMonth(): void {
|
||||||
let newValue = Number(params.month) + 1
|
let newValue = Number(params.month) + 1
|
||||||
|
|
||||||
// If the new value would exceed the max number of month per year
|
// If the new value would exceed the max number of month per year
|
||||||
if (newValue >= monthsPerYear.value) {
|
if (newValue >= monthsPerYear.value) {
|
||||||
newValue = 0
|
newValue = 0
|
||||||
// Increment the year
|
// Increment the year
|
||||||
incrementYear()
|
incrementViewYear()
|
||||||
}
|
}
|
||||||
|
|
||||||
params.month = newValue.toString()
|
params.month = newValue.toString()
|
||||||
@@ -221,26 +221,26 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
/**
|
/**
|
||||||
* Moves the current date backward one month
|
* Moves the current date backward one month
|
||||||
*/
|
*/
|
||||||
function decrementMonth(): void {
|
function decrementViewMonth(): void {
|
||||||
let newValue = Number(params.month) - 1
|
let newValue = Number(params.month) - 1
|
||||||
|
|
||||||
// If the new value would go below 0
|
// If the new value would go below 0
|
||||||
if (newValue < 0) {
|
if (newValue < 0) {
|
||||||
newValue = monthsPerYear.value - 1
|
newValue = monthsPerYear.value - 1
|
||||||
// Decrement the year
|
// Decrement the year
|
||||||
decrementYear()
|
decrementViewYear()
|
||||||
}
|
}
|
||||||
|
|
||||||
params.month = newValue.toString()
|
params.month = newValue.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the previous month number
|
* Get the previous month number of the calendar view
|
||||||
*
|
*
|
||||||
* @param monthNumber Initial month
|
* @param monthNumber Initial month
|
||||||
* @returns The previous month number in the year
|
* @returns The previous month number in the year
|
||||||
*/
|
*/
|
||||||
function getPreviousMonth(monthNumber: number): number {
|
function getPreviousViewMonth(monthNumber: number): number {
|
||||||
const target: number = monthNumber - 1
|
const target: number = monthNumber - 1
|
||||||
|
|
||||||
if (target < 0) {
|
if (target < 0) {
|
||||||
@@ -251,12 +251,12 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the following month number
|
* Get the following month number of the calendar view
|
||||||
*
|
*
|
||||||
* @param monthNumber Initial month
|
* @param monthNumber Initial month
|
||||||
* @returns The next month number in the year
|
* @returns The next month number in the year
|
||||||
*/
|
*/
|
||||||
function getNextMonth(monthNumber: number): number {
|
function getNextViewMonth(monthNumber: number): number {
|
||||||
const target: number = monthNumber + 1
|
const target: number = monthNumber + 1
|
||||||
|
|
||||||
if (target + 1 > monthsPerYear.value) {
|
if (target + 1 > monthsPerYear.value) {
|
||||||
@@ -267,9 +267,9 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current date to a particular month
|
* Moves the current view to a particular month
|
||||||
*/
|
*/
|
||||||
function setMonth(target: number): void {
|
function setViewMonth(target: number): void {
|
||||||
// If the target is outside the month bounds
|
// If the target is outside the month bounds
|
||||||
if (target < 0 || target >= monthsPerYear.value) {
|
if (target < 0 || target >= monthsPerYear.value) {
|
||||||
return
|
return
|
||||||
@@ -279,18 +279,18 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current date forward one year
|
* Moves the current view forward one year
|
||||||
*/
|
*/
|
||||||
function incrementYear(inc: number = 1): void {
|
function incrementViewYear(inc: number = 1): void {
|
||||||
const newValue = Number(params.year) + inc
|
const newValue = Number(params.year) + inc
|
||||||
|
|
||||||
params.year = newValue.toString()
|
params.year = newValue.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current date backward one year
|
* Moves the current view backward one year
|
||||||
*/
|
*/
|
||||||
function decrementYear(inc: number = 1): void {
|
function decrementViewYear(inc: number = 1): void {
|
||||||
const newValue = Number(params.year) - inc
|
const newValue = Number(params.year) - inc
|
||||||
|
|
||||||
params.year = newValue.toString()
|
params.year = newValue.toString()
|
||||||
@@ -583,9 +583,9 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
const currentMonth = sortedMonths.value[datePivot.month]
|
const currentMonth = sortedMonths.value[datePivot.month]
|
||||||
dateAcc.day = currentMonth.days - datePivot.day
|
dateAcc.day = currentMonth.days - datePivot.day
|
||||||
if (direction === 'future') {
|
if (direction === 'future') {
|
||||||
datePivot.month = getNextMonth(datePivot.month)
|
datePivot.month = getNextViewMonth(datePivot.month)
|
||||||
} else {
|
} else {
|
||||||
datePivot.month = getPreviousMonth(datePivot.month)
|
datePivot.month = getPreviousViewMonth(datePivot.month)
|
||||||
}
|
}
|
||||||
datePivot.day = 1
|
datePivot.day = 1
|
||||||
|
|
||||||
@@ -914,13 +914,13 @@ export const useCalendar = defineStore('calendar', () => {
|
|||||||
selectedDate: skipHydrate(selectedDate),
|
selectedDate: skipHydrate(selectedDate),
|
||||||
selectDate,
|
selectDate,
|
||||||
params,
|
params,
|
||||||
incrementMonth,
|
incrementViewMonth,
|
||||||
decrementMonth,
|
decrementViewMonth,
|
||||||
setMonth,
|
setViewMonth,
|
||||||
getPreviousMonth,
|
getPreviousViewMonth,
|
||||||
getNextMonth,
|
getNextViewMonth,
|
||||||
incrementYear,
|
incrementViewYear,
|
||||||
decrementYear,
|
decrementViewYear,
|
||||||
jumpToDate,
|
jumpToDate,
|
||||||
jumpToDefaultDate,
|
jumpToDefaultDate,
|
||||||
getFormattedDateTitle,
|
getFormattedDateTitle,
|
||||||
|
|||||||
Reference in New Issue
Block a user