first commit

This commit is contained in:
2025-04-24 13:11:28 +08:00
commit ff9c54d5e4
5960 changed files with 834111 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import getMeta from '@/utils/meta'
// The reason this is a function is to ensure that the meta tag is read before
// any isBootstrap5 check is performed
export const isBootstrap5 = () => getMeta('ol-bootstrapVersion') === 5

View File

@@ -0,0 +1,9 @@
export function disableElement(el) {
el.setAttribute('disabled', '')
el.setAttribute('aria-disabled', 'true')
}
export function enableElement(el) {
el.removeAttribute('disabled')
el.removeAttribute('aria-disabled')
}

View File

@@ -0,0 +1,14 @@
// Helper function to compute the url for a file in history-v1 or filestore.
// This will be obsolete when the migration to history-v1 is complete.
import getMeta from '@/utils/meta'
const projectHistoryBlobsEnabled = getMeta('ol-projectHistoryBlobsEnabled')
export function fileUrl(projectId, id, hash) {
if (projectHistoryBlobsEnabled && hash) {
return `/project/${projectId}/blob/${hash}?fallback=${id}`
} else {
return `/project/${projectId}/file/${id}`
}
}

View File

@@ -0,0 +1,28 @@
import moment from 'moment'
moment.updateLocale('en', {
calendar: {
lastDay: '[Yesterday]',
sameDay: '[Today]',
nextDay: '[Tomorrow]',
lastWeek: 'ddd, Do MMM YY',
nextWeek: 'ddd, Do MMM YY',
sameElse: 'ddd, Do MMM YY',
},
})
export function formatTime(date: moment.MomentInput, format = 'h:mm a') {
return moment(date).format(format)
}
export function relativeDate(date: moment.MomentInput) {
return moment(date).calendar()
}
export function formatTimeBasedOnYear(date: moment.MomentInput) {
const currentDate = moment()
return currentDate.diff(date, 'years') > 0
? formatTime(date, 'D MMMM YYYY, h:mm a')
: formatTime(date, 'D MMMM, h:mm a')
}

View File

@@ -0,0 +1,12 @@
export function swapModal(selectorBefore, selectorAfter) {
const modalBefore = $(selectorBefore)
const modalAfter = $(selectorAfter)
// Disable the fade-out + fade-in animation when swapping the forms.
modalBefore.removeClass('fade')
modalAfter.removeClass('fade')
modalAfter.modal()
modalBefore.modal('hide')
modalBefore.addClass('fade')
modalAfter.addClass('fade')
}