first commit
This commit is contained in:
5
services/web/frontend/js/features/utils/bootstrap-5.ts
Normal file
5
services/web/frontend/js/features/utils/bootstrap-5.ts
Normal 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
|
||||
@@ -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')
|
||||
}
|
||||
14
services/web/frontend/js/features/utils/fileUrl.js
Normal file
14
services/web/frontend/js/features/utils/fileUrl.js
Normal 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}`
|
||||
}
|
||||
}
|
||||
28
services/web/frontend/js/features/utils/format-date.ts
Normal file
28
services/web/frontend/js/features/utils/format-date.ts
Normal 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')
|
||||
}
|
||||
12
services/web/frontend/js/features/utils/swapModal.js
Normal file
12
services/web/frontend/js/features/utils/swapModal.js
Normal 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')
|
||||
}
|
||||
Reference in New Issue
Block a user