To keep blame info accurate and to avoid [changes like this](https://github.com/go-gitea/gitea/pull/29977/files#diff-c3422631a14edbe1e508c4b22f0c718db318be08a6e889427802f9b6165d88d6R359), it's good to always have a trailing comma, so let's enforce it in JS. This rule is completely automatically fixable with `make lint-js-fix` and that's what I did here.tags/v1.22.0-rc0
"@stylistic/js/arrow-spacing": [2, {before: true, after: true}] | "@stylistic/js/arrow-spacing": [2, {before: true, after: true}] | ||||
"@stylistic/js/block-spacing": [0] | "@stylistic/js/block-spacing": [0] | ||||
"@stylistic/js/brace-style": [2, 1tbs, {allowSingleLine: true}] | "@stylistic/js/brace-style": [2, 1tbs, {allowSingleLine: true}] | ||||
"@stylistic/js/comma-dangle": [2, only-multiline] | |||||
"@stylistic/js/comma-dangle": [2, always-multiline] | |||||
"@stylistic/js/comma-spacing": [2, {before: false, after: true}] | "@stylistic/js/comma-spacing": [2, {before: false, after: true}] | ||||
"@stylistic/js/comma-style": [2, last] | "@stylistic/js/comma-style": [2, last] | ||||
"@stylistic/js/computed-property-spacing": [2, never] | "@stylistic/js/computed-property-spacing": [2, never] |
* Maximum time expect() should wait for the condition to be met. | * Maximum time expect() should wait for the condition to be met. | ||||
* For example in `await expect(locator).toHaveText();` | * For example in `await expect(locator).toHaveText();` | ||||
*/ | */ | ||||
timeout: 2000 | |||||
timeout: 2000, | |||||
}, | }, | ||||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | /* Fail the build on CI if you accidentally left test.only in the source code. */ |
'removeDimensions', | 'removeDimensions', | ||||
{ | { | ||||
name: 'addAttributesToSVGElement', | name: 'addAttributesToSVGElement', | ||||
params: {attributes: [{width: size}, {height: size}]} | |||||
params: {attributes: [{width: size}, {height: size}]}, | |||||
}, | }, | ||||
], | ], | ||||
}); | }); |
attributes: [ | attributes: [ | ||||
{'xmlns': 'http://www.w3.org/2000/svg'}, | {'xmlns': 'http://www.w3.org/2000/svg'}, | ||||
{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}, | {'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}, | ||||
] | |||||
} | |||||
], | |||||
}, | |||||
}, | }, | ||||
], | ], | ||||
}); | }); |
props: { | props: { | ||||
status: { | status: { | ||||
type: String, | type: String, | ||||
required: true | |||||
required: true, | |||||
}, | }, | ||||
size: { | size: { | ||||
type: Number, | type: Number, | ||||
default: 16 | |||||
default: 16, | |||||
}, | }, | ||||
className: { | className: { | ||||
type: String, | type: String, | ||||
default: '' | |||||
default: '', | |||||
}, | }, | ||||
localeStatus: { | localeStatus: { | ||||
type: String, | type: String, | ||||
default: '' | |||||
} | |||||
default: '', | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
</script> | </script> |
locale: { | locale: { | ||||
type: Object, | type: Object, | ||||
default: () => {}, | default: () => {}, | ||||
} | |||||
}, | |||||
}, | }, | ||||
data: () => ({ | data: () => ({ | ||||
colorRange: [ | colorRange: [ | ||||
const newSearch = params.toString(); | const newSearch = params.toString(); | ||||
window.location.search = newSearch.length ? `?${newSearch}` : ''; | window.location.search = newSearch.length ? `?${newSearch}` : ''; | ||||
} | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
</script> | </script> |
} | } | ||||
return {name: label.name, color: `#${label.color}`, textColor}; | return {name: label.name, color: `#${label.color}`, textColor}; | ||||
}); | }); | ||||
} | |||||
}, | |||||
}, | }, | ||||
mounted() { | mounted() { | ||||
this.$refs.root.addEventListener('ce-load-context-popup', (e) => { | this.$refs.root.addEventListener('ce-load-context-popup', (e) => { | ||||
} finally { | } finally { | ||||
this.loading = false; | this.loading = false; | ||||
} | } | ||||
} | |||||
} | |||||
}, | |||||
}, | |||||
}; | }; | ||||
</script> | </script> | ||||
<template> | <template> |
...webSearchRepo.repository, | ...webSearchRepo.repository, | ||||
latest_commit_status_state: webSearchRepo.latest_commit_status.State, | latest_commit_status_state: webSearchRepo.latest_commit_status.State, | ||||
locale_latest_commit_status_state: webSearchRepo.locale_latest_commit_status, | locale_latest_commit_status_state: webSearchRepo.locale_latest_commit_status, | ||||
latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL | |||||
latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL, | |||||
}; | }; | ||||
}); | }); | ||||
const count = response.headers.get('X-Total-Count'); | const count = response.headers.get('X-Total-Count'); | ||||
if (this.activeIndex === -1 || this.activeIndex > this.repos.length - 1) { | if (this.activeIndex === -1 || this.activeIndex > this.repos.length - 1) { | ||||
this.activeIndex = 0; | this.activeIndex = 0; | ||||
} | } | ||||
} | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
}, | }, | ||||
commits: [], | commits: [], | ||||
hoverActivated: false, | hoverActivated: false, | ||||
lastReviewCommitSha: null | |||||
lastReviewCommitSha: null, | |||||
}; | }; | ||||
}, | }, | ||||
computed: { | computed: { | ||||
}, | }, | ||||
issueLink() { | issueLink() { | ||||
return this.$el.parentNode.getAttribute('data-issuelink'); | return this.$el.parentNode.getAttribute('data-issuelink'); | ||||
} | |||||
}, | |||||
}, | }, | ||||
mounted() { | mounted() { | ||||
document.body.addEventListener('click', this.onBodyClick); | document.body.addEventListener('click', this.onBodyClick); | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
} | |||||
}, | |||||
}; | }; | ||||
</script> | </script> | ||||
<template> | <template> |
}, | }, | ||||
loadMoreData() { | loadMoreData() { | ||||
loadMoreFiles(this.store.linkLoadMore); | loadMoreFiles(this.store.linkLoadMore); | ||||
} | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
</script> | </script> |
let newParent = { | let newParent = { | ||||
name: split, | name: split, | ||||
children: [], | children: [], | ||||
isFile | |||||
isFile, | |||||
}; | }; | ||||
if (isFile === true) { | if (isFile === true) { | ||||
if (parent) { | if (parent) { | ||||
// check if the folder already exists | // check if the folder already exists | ||||
const existingFolder = parent.children.find( | const existingFolder = parent.children.find( | ||||
(x) => x.name === split | |||||
(x) => x.name === split, | |||||
); | ); | ||||
if (existingFolder) { | if (existingFolder) { | ||||
newParent = existingFolder; | newParent = existingFolder; | ||||
// reduce the depth of our tree. | // reduce the depth of our tree. | ||||
mergeChildIfOnlyOneDir(result); | mergeChildIfOnlyOneDir(result); | ||||
return result; | return result; | ||||
} | |||||
}, | |||||
}, | }, | ||||
mounted() { | mounted() { | ||||
// Default to true if unset | // Default to true if unset |
props: { | props: { | ||||
item: { | item: { | ||||
type: Object, | type: Object, | ||||
required: true | |||||
required: true, | |||||
}, | }, | ||||
}, | }, | ||||
data: () => ({ | data: () => ({ |
for (const elem of document.querySelectorAll('[data-pull-merge-style]')) { | for (const elem of document.querySelectorAll('[data-pull-merge-style]')) { | ||||
toggleElem(elem, elem.getAttribute('data-pull-merge-style') === val); | toggleElem(elem, elem.getAttribute('data-pull-merge-style') === val); | ||||
} | } | ||||
} | |||||
}, | |||||
}, | }, | ||||
created() { | created() { | ||||
this.mergeStyleAllowedCount = this.mergeForm.mergeStyles.reduce((v, msd) => v + (msd.allowed ? 1 : 0), 0); | this.mergeStyleAllowedCount = this.mergeForm.mergeStyles.reduce((v, msd) => v + (msd.allowed ? 1 : 0), 0); |
name: '', | name: '', | ||||
link: '', | link: '', | ||||
}, | }, | ||||
} | |||||
}, | |||||
}, | }, | ||||
currentJob: { | currentJob: { | ||||
title: '', | title: '', | ||||
const logLine = this.$refs.steps.querySelector(selectedLogStep); | const logLine = this.$refs.steps.querySelector(selectedLogStep); | ||||
if (!logLine) return; | if (!logLine) return; | ||||
logLine.querySelector('.line-num').click(); | logLine.querySelector('.line-num').click(); | ||||
} | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
skipped: el.getAttribute('data-locale-status-skipped'), | skipped: el.getAttribute('data-locale-status-skipped'), | ||||
blocked: el.getAttribute('data-locale-status-blocked'), | blocked: el.getAttribute('data-locale-status-blocked'), | ||||
}, | }, | ||||
} | |||||
}, | |||||
}); | }); | ||||
view.mount(el); | view.mount(el); | ||||
} | } |
this.colors.barColor = refStyle.backgroundColor; | this.colors.barColor = refStyle.backgroundColor; | ||||
this.colors.textColor = refStyle.color; | this.colors.textColor = refStyle.color; | ||||
this.colors.textAltColor = refAltStyle.color; | this.colors.textAltColor = refAltStyle.color; | ||||
} | |||||
}, | |||||
}; | }; | ||||
export function initRepoActivityTopAuthorsChart() { | export function initRepoActivityTopAuthorsChart() { |
}, | }, | ||||
shouldCreateTag() { | shouldCreateTag() { | ||||
return this.mode === 'tags'; | return this.mode === 'tags'; | ||||
} | |||||
}, | |||||
}, | }, | ||||
watch: { | watch: { | ||||
this.focusSearchField(); | this.focusSearchField(); | ||||
this.fetchBranchesOrTags(); | this.fetchBranchesOrTags(); | ||||
} | } | ||||
} | |||||
}, | |||||
}, | }, | ||||
beforeMount() { | beforeMount() { | ||||
this.isLoading = false; | this.isLoading = false; | ||||
} | } | ||||
}, | }, | ||||
} | |||||
}, | |||||
}; | }; | ||||
export function initRepoBranchTagSelector(selector) { | export function initRepoBranchTagSelector(selector) { |
props: { | props: { | ||||
locale: { | locale: { | ||||
type: Object, | type: Object, | ||||
required: true | |||||
required: true, | |||||
}, | }, | ||||
}, | }, | ||||
data: () => ({ | data: () => ({ | ||||
}, | }, | ||||
ticks: { | ticks: { | ||||
maxRotation: 0, | maxRotation: 0, | ||||
maxTicksLimit: 12 | |||||
maxTicksLimit: 12, | |||||
}, | }, | ||||
}, | }, | ||||
y: { | y: { | ||||
ticks: { | ticks: { | ||||
maxTicksLimit: 6 | |||||
maxTicksLimit: 6, | |||||
}, | }, | ||||
}, | }, | ||||
}, | }, |
chart.resetZoom(); | chart.resetZoom(); | ||||
opts.instance.updateOtherCharts(args.event, true); | opts.instance.updateOtherCharts(args.event, true); | ||||
} | } | ||||
} | |||||
}, | |||||
}; | }; | ||||
Chart.defaults.color = chartJsColors.text; | Chart.defaults.color = chartJsColors.text; | ||||
this.xAxisMax = this.xAxisEnd; | this.xAxisMax = this.xAxisEnd; | ||||
this.type = val; | this.type = val; | ||||
this.sortContributors(); | this.sortContributors(); | ||||
} | |||||
}, | |||||
}); | }); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
// Normally, chartjs handles this automatically, but it will resize the graph when you | // Normally, chartjs handles this automatically, but it will resize the graph when you | ||||
// zoom, pan etc. I think resizing the graph makes it harder to compare things visually. | // zoom, pan etc. I think resizing the graph makes it harder to compare things visually. | ||||
const maxValue = Math.max( | const maxValue = Math.max( | ||||
...this.totalStats.weeks.map((o) => o[this.type]) | |||||
...this.totalStats.weeks.map((o) => o[this.type]), | |||||
); | ); | ||||
const [coefficient, exp] = maxValue.toExponential().split('e').map(Number); | const [coefficient, exp] = maxValue.toExponential().split('e').map(Number); | ||||
if (coefficient % 1 === 0) return maxValue; | if (coefficient % 1 === 0) return maxValue; | ||||
// for contributors' graph. If I let chartjs do this for me, it will choose different | // for contributors' graph. If I let chartjs do this for me, it will choose different | ||||
// maxY value for each contributors' graph which again makes it harder to compare. | // maxY value for each contributors' graph which again makes it harder to compare. | ||||
const maxValue = Math.max( | const maxValue = Math.max( | ||||
...this.sortedContributors.map((c) => c.max_contribution_type) | |||||
...this.sortedContributors.map((c) => c.max_contribution_type), | |||||
); | ); | ||||
const [coefficient, exp] = maxValue.toExponential().split('e').map(Number); | const [coefficient, exp] = maxValue.toExponential().split('e').map(Number); | ||||
if (coefficient % 1 === 0) return maxValue; | if (coefficient % 1 === 0) return maxValue; |
props: { | props: { | ||||
locale: { | locale: { | ||||
type: Object, | type: Object, | ||||
required: true | |||||
required: true, | |||||
}, | }, | ||||
}, | }, | ||||
data: () => ({ | data: () => ({ | ||||
}, | }, | ||||
ticks: { | ticks: { | ||||
maxRotation: 0, | maxRotation: 0, | ||||
maxTicksLimit: 52 | |||||
maxTicksLimit: 52, | |||||
}, | }, | ||||
}, | }, | ||||
y: { | y: { | ||||
ticks: { | ticks: { | ||||
maxTicksLimit: 6 | |||||
maxTicksLimit: 6, | |||||
}, | }, | ||||
}, | }, | ||||
}, | }, |
'repository', | 'repository', | ||||
'user'); | 'user'); | ||||
return categories; | return categories; | ||||
} | |||||
}, | |||||
}, | }, | ||||
mounted() { | mounted() { | ||||
} | } | ||||
// no scopes selected, show validation error | // no scopes selected, show validation error | ||||
showElem(warningEl); | showElem(warningEl); | ||||
} | |||||
}, | |||||
}, | }, | ||||
}; | }; | ||||
const params = { | const params = { | ||||
sitekey: siteKey, | sitekey: siteKey, | ||||
theme: isDark ? 'dark' : 'light' | |||||
theme: isDark ? 'dark' : 'light', | |||||
}; | }; | ||||
switch (captchaEl.getAttribute('data-captcha-type')) { | switch (captchaEl.getAttribute('data-captcha-type')) { | ||||
siteKey: { | siteKey: { | ||||
instanceUrl: new URL(instanceURL), | instanceUrl: new URL(instanceURL), | ||||
key: siteKey, | key: siteKey, | ||||
} | |||||
}, | |||||
}); | }); | ||||
break; | break; | ||||
} | } |
loadingTitle: el.getAttribute('data-locale-loading-title'), | loadingTitle: el.getAttribute('data-locale-loading-title'), | ||||
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | ||||
loadingInfo: el.getAttribute('data-locale-loading-info'), | loadingInfo: el.getAttribute('data-locale-loading-info'), | ||||
} | |||||
}, | |||||
}); | }); | ||||
View.mount(el); | View.mount(el); | ||||
} catch (err) { | } catch (err) { |
rules: [ | rules: [ | ||||
{ | { | ||||
background: getColor('--color-code-bg'), | background: getColor('--color-code-bg'), | ||||
} | |||||
}, | |||||
], | ], | ||||
colors: { | colors: { | ||||
'editor.background': getColor('--color-code-bg'), | 'editor.background': getColor('--color-code-bg'), | ||||
'input.foreground': getColor('--color-input-text'), | 'input.foreground': getColor('--color-input-text'), | ||||
'scrollbar.shadow': getColor('--color-shadow'), | 'scrollbar.shadow': getColor('--color-shadow'), | ||||
'progressBar.background': getColor('--color-primary'), | 'progressBar.background': getColor('--color-primary'), | ||||
} | |||||
}, | |||||
}); | }); | ||||
// Quick fix: https://github.com/microsoft/monaco-editor/issues/2962 | // Quick fix: https://github.com/microsoft/monaco-editor/issues/2962 |
const data = await response.json(); | const data = await response.json(); | ||||
window.location.href = data.redirect; | window.location.href = data.redirect; | ||||
} | } | ||||
} | |||||
}, | |||||
}).modal('show'); | }).modal('show'); | ||||
} | } | ||||
}, | }, | ||||
icon: svg('octicon-chevron-right'), | icon: svg('octicon-chevron-right'), | ||||
title: 'Add Inline Code', | title: 'Add Inline Code', | ||||
} | |||||
}, | |||||
}; | }; | ||||
for (const [key, value] of Object.entries(actions)) { | for (const [key, value] of Object.entries(actions)) { |
$.each(response.data, (_i, item) => { | $.each(response.data, (_i, item) => { | ||||
const resultItem = { | const resultItem = { | ||||
title: item.login, | title: item.login, | ||||
image: item.avatar_url | |||||
image: item.avatar_url, | |||||
}; | }; | ||||
if (item.full_name) { | if (item.full_name) { | ||||
resultItem.description = htmlEscape(item.full_name); | resultItem.description = htmlEscape(item.full_name); | ||||
if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) { | if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) { | ||||
const resultItem = { | const resultItem = { | ||||
title: searchQuery, | title: searchQuery, | ||||
description: allowEmailDescription | |||||
description: allowEmailDescription, | |||||
}; | }; | ||||
items.push(resultItem); | items.push(resultItem); | ||||
} | } | ||||
return {results: items}; | return {results: items}; | ||||
} | |||||
}, | |||||
}, | }, | ||||
searchFields: ['login', 'full_name'], | searchFields: ['login', 'full_name'], | ||||
showNoResults: false | |||||
showNoResults: false, | |||||
}); | }); | ||||
} | } |
interactiveBorder: 5, | interactiveBorder: 5, | ||||
onShow: () => { | onShow: () => { | ||||
el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}})); | el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}})); | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } | ||||
} | } |
loadingTitle: el.getAttribute('data-locale-loading-title'), | loadingTitle: el.getAttribute('data-locale-loading-title'), | ||||
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | ||||
loadingInfo: el.getAttribute('data-locale-loading-info'), | loadingInfo: el.getAttribute('data-locale-loading-info'), | ||||
} | |||||
}, | |||||
}); | }); | ||||
View.mount(el); | View.mount(el); | ||||
} catch (err) { | } catch (err) { |
this.eventSource.addEventListener(eventType, (event) => { | this.eventSource.addEventListener(eventType, (event) => { | ||||
this.notifyClients({ | this.notifyClients({ | ||||
type: eventType, | type: eventType, | ||||
data: event.data | |||||
data: event.data, | |||||
}); | }); | ||||
}); | }); | ||||
} | } |
if (img.width > 1 && img.width < MaxSize && img.height > 1 && img.height < MaxSize) { | if (img.width > 1 && img.width < MaxSize && img.height > 1 && img.height < MaxSize) { | ||||
return { | return { | ||||
width: img.width, | width: img.width, | ||||
height: img.height | |||||
height: img.height, | |||||
}; | }; | ||||
} | } | ||||
if (svg.hasAttribute('viewBox')) { | if (svg.hasAttribute('viewBox')) { | ||||
const viewBox = svg.viewBox.baseVal; | const viewBox = svg.viewBox.baseVal; | ||||
return { | return { | ||||
width: DefaultSize, | width: DefaultSize, | ||||
height: DefaultSize * viewBox.width / viewBox.height | |||||
height: DefaultSize * viewBox.width / viewBox.height, | |||||
}; | }; | ||||
} | } | ||||
return { | return { | ||||
width: DefaultSize, | width: DefaultSize, | ||||
height: DefaultSize | |||||
height: DefaultSize, | |||||
}; | }; | ||||
} | } | ||||
return null; | return null; | ||||
function createContext(image1, image2) { | function createContext(image1, image2) { | ||||
const size1 = { | const size1 = { | ||||
width: image1 && image1.width || 0, | width: image1 && image1.width || 0, | ||||
height: image1 && image1.height || 0 | |||||
height: image1 && image1.height || 0, | |||||
}; | }; | ||||
const size2 = { | const size2 = { | ||||
width: image2 && image2.width || 0, | width: image2 && image2.width || 0, | ||||
height: image2 && image2.height || 0 | |||||
height: image2 && image2.height || 0, | |||||
}; | }; | ||||
const max = { | const max = { | ||||
width: Math.max(size2.width, size1.width), | width: Math.max(size2.width, size1.width), | ||||
height: Math.max(size2.height, size1.height) | |||||
height: Math.max(size2.height, size1.height), | |||||
}; | }; | ||||
return { | return { | ||||
Math.floor(max.width - size1.width) / 2, | Math.floor(max.width - size1.width) / 2, | ||||
Math.floor(max.height - size1.height) / 2, | Math.floor(max.height - size1.height) / 2, | ||||
Math.floor(max.width - size2.width) / 2, | Math.floor(max.width - size2.width) / 2, | ||||
Math.floor(max.height - size2.height) / 2 | |||||
] | |||||
Math.floor(max.height - size2.height) / 2, | |||||
], | |||||
}; | }; | ||||
} | } | ||||
path: this.getAttribute('data-path-after'), | path: this.getAttribute('data-path-after'), | ||||
mime: this.getAttribute('data-mime-after'), | mime: this.getAttribute('data-mime-after'), | ||||
$images: $container.find('img.image-after'), // matches 3 <img> | $images: $container.find('img.image-after'), // matches 3 <img> | ||||
$boundsInfo: $container.find('.bounds-info-after') | |||||
$boundsInfo: $container.find('.bounds-info-after'), | |||||
}, { | }, { | ||||
path: this.getAttribute('data-path-before'), | path: this.getAttribute('data-path-before'), | ||||
mime: this.getAttribute('data-mime-before'), | mime: this.getAttribute('data-mime-before'), | ||||
$images: $container.find('img.image-before'), // matches 3 <img> | $images: $container.find('img.image-before'), // matches 3 <img> | ||||
$boundsInfo: $container.find('.bounds-info-before') | |||||
$boundsInfo: $container.find('.bounds-info-before'), | |||||
}]; | }]; | ||||
await Promise.all(imageInfos.map(async (info) => { | await Promise.all(imageInfos.map(async (info) => { | ||||
sizes.image1.css({ | sizes.image1.css({ | ||||
width: sizes.size1.width * factor, | width: sizes.size1.width * factor, | ||||
height: sizes.size1.height * factor | |||||
height: sizes.size1.height * factor, | |||||
}); | }); | ||||
sizes.image2.css({ | sizes.image2.css({ | ||||
width: sizes.size2.width * factor, | width: sizes.size2.width * factor, | ||||
height: sizes.size2.height * factor | |||||
height: sizes.size2.height * factor, | |||||
}); | }); | ||||
sizes.image1.parent().css({ | sizes.image1.parent().css({ | ||||
margin: `${sizes.ratio[1] * factor}px ${sizes.ratio[0] * factor}px`, | margin: `${sizes.ratio[1] * factor}px ${sizes.ratio[0] * factor}px`, | ||||
width: sizes.size1.width * factor + 2, | width: sizes.size1.width * factor + 2, | ||||
height: sizes.size1.height * factor + 2 | |||||
height: sizes.size1.height * factor + 2, | |||||
}); | }); | ||||
sizes.image2.parent().css({ | sizes.image2.parent().css({ | ||||
margin: `${sizes.ratio[3] * factor}px ${sizes.ratio[2] * factor}px`, | margin: `${sizes.ratio[3] * factor}px ${sizes.ratio[2] * factor}px`, | ||||
width: sizes.size2.width * factor + 2, | width: sizes.size2.width * factor + 2, | ||||
height: sizes.size2.height * factor + 2 | |||||
height: sizes.size2.height * factor + 2, | |||||
}); | }); | ||||
// some inner elements are `position: absolute`, so the container's height must be large enough | // some inner elements are `position: absolute`, so the container's height must be large enough | ||||
const $range = $container.find("input[type='range']"); | const $range = $container.find("input[type='range']"); | ||||
const onInput = () => sizes.image1.parent().css({ | const onInput = () => sizes.image1.parent().css({ | ||||
opacity: $range.val() / 100 | |||||
opacity: $range.val() / 100, | |||||
}); | }); | ||||
$range.on('input', onInput); | $range.on('input', onInput); | ||||
onInput(); | onInput(); |
const defaultDbHosts = { | const defaultDbHosts = { | ||||
mysql: '127.0.0.1:3306', | mysql: '127.0.0.1:3306', | ||||
postgres: '127.0.0.1:5432', | postgres: '127.0.0.1:5432', | ||||
mssql: '127.0.0.1:1433' | |||||
mssql: '127.0.0.1:1433', | |||||
}; | }; | ||||
const dbHost = document.getElementById('db_host'); | const dbHost = document.getElementById('db_host'); |
$.each(response.data, (_i, item) => { | $.each(response.data, (_i, item) => { | ||||
items.push({ | items.push({ | ||||
title: item.repository.full_name.split('/')[1], | title: item.repository.full_name.split('/')[1], | ||||
description: item.repository.full_name | |||||
description: item.repository.full_name, | |||||
}); | }); | ||||
}); | }); | ||||
return {results: items}; | return {results: items}; | ||||
} | |||||
}, | |||||
}, | }, | ||||
searchFields: ['full_name'], | searchFields: ['full_name'], | ||||
showNoResults: false | |||||
showNoResults: false, | |||||
}); | }); | ||||
} | } |
loadingTitle: el.getAttribute('data-locale-loading-title'), | loadingTitle: el.getAttribute('data-locale-loading-title'), | ||||
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'), | ||||
loadingInfo: el.getAttribute('data-locale-loading-info'), | loadingInfo: el.getAttribute('data-locale-loading-info'), | ||||
} | |||||
}, | |||||
}); | }); | ||||
View.mount(el); | View.mount(el); | ||||
} catch (err) { | } catch (err) { |
tippy.popper.addEventListener('click', () => { | tippy.popper.addEventListener('click', () => { | ||||
tippy.hide(); | tippy.hide(); | ||||
}, {once: true}); | }, {once: true}); | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } | ||||
addedValue = addedValue.toLowerCase().trim(); | addedValue = addedValue.toLowerCase().trim(); | ||||
$($addedChoice).attr('data-value', addedValue); | $($addedChoice).attr('data-value', addedValue); | ||||
$($addedChoice).attr('data-text', addedValue); | $($addedChoice).attr('data-text', addedValue); | ||||
} | |||||
}, | |||||
}); | }); | ||||
$.fn.form.settings.rules.validateTopic = function (_values, regExp) { | $.fn.form.settings.rules.validateTopic = function (_values, regExp) { | ||||
{ | { | ||||
type: 'validateTopic', | type: 'validateTopic', | ||||
value: /^\s*[a-z0-9][-.a-z0-9]{0,35}\s*$/, | value: /^\s*[a-z0-9][-.a-z0-9]{0,35}\s*$/, | ||||
prompt: topicPrompts.formatPrompt | |||||
prompt: topicPrompts.formatPrompt, | |||||
}, | }, | ||||
{ | { | ||||
type: 'maxCount[25]', | type: 'maxCount[25]', | ||||
prompt: topicPrompts.countPrompt | |||||
} | |||||
] | |||||
prompt: topicPrompts.countPrompt, | |||||
}, | |||||
], | |||||
}, | }, | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } |
}, | }, | ||||
onHide() { | onHide() { | ||||
$(this).dropdown('clear', true); | $(this).dropdown('clear', true); | ||||
} | |||||
}, | |||||
}); | }); | ||||
$dialog.modal({ | $dialog.modal({ | ||||
async onShow() { | async onShow() { |
try { | try { | ||||
const response = await POST($('#update-issue-deadline-form').attr('action'), { | const response = await POST($('#update-issue-deadline-form').attr('action'), { | ||||
data: {due_date: realDeadline} | |||||
data: {due_date: realDeadline}, | |||||
}); | }); | ||||
if (response.ok) { | if (response.ok) { | ||||
$pullUpdateButton.find('.button-text').text($choice.text()); | $pullUpdateButton.find('.button-text').text($choice.text()); | ||||
$pullUpdateButton.data('do', $url); | $pullUpdateButton.data('do', $url); | ||||
} | } | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } | ||||
$.each(response.data, (_r, repo) => { | $.each(response.data, (_r, repo) => { | ||||
filteredResponse.results.push({ | filteredResponse.results.push({ | ||||
name: htmlEscape(repo.repository.full_name), | name: htmlEscape(repo.repository.full_name), | ||||
value: repo.repository.full_name | |||||
value: repo.repository.full_name, | |||||
}); | }); | ||||
}); | }); | ||||
return filteredResponse; | return filteredResponse; | ||||
const $form = $choice.closest('form'); | const $form = $choice.closest('form'); | ||||
$form.attr('action', `${appSubUrl}/${_text}/issues/new`); | $form.attr('action', `${appSubUrl}/${_text}/issues/new`); | ||||
}, | }, | ||||
fullTextSearch: true | |||||
fullTextSearch: true, | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
window.scrollTo({ | window.scrollTo({ | ||||
top: $commentDiv.offset().top - offset, | top: $commentDiv.offset().top - offset, | ||||
behavior: 'instant' | |||||
behavior: 'instant', | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
// Replace branch name to keep translation from HTML template | // Replace branch name to keep translation from HTML template | ||||
$selectionTextField.html($selectionTextField.html().replace( | $selectionTextField.html($selectionTextField.html().replace( | ||||
`${baseName}:${branchNameOld}`, | `${baseName}:${branchNameOld}`, | ||||
`${baseName}:${branchNameNew}` | |||||
`${baseName}:${branchNameNew}`, | |||||
)); | )); | ||||
$selectionTextField.data('branch', branchNameNew); // update branch name in setting | $selectionTextField.data('branch', branchNameNew); // update branch name in setting | ||||
}; | }; | ||||
const editor = await initComboMarkdownEditor($markdownEditor, { | const editor = await initComboMarkdownEditor($markdownEditor, { | ||||
onContentChanged: (editor) => { | onContentChanged: (editor) => { | ||||
$formField.val(editor.value()); | $formField.val(editor.value()); | ||||
} | |||||
}, | |||||
}); | }); | ||||
$formField.on('focus', async () => { | $formField.on('focus', async () => { |
$text.text('(none)'); // prevent from misleading users when the access mode is undefined | $text.text('(none)'); // prevent from misleading users when the access mode is undefined | ||||
} | } | ||||
}, 0); | }, 0); | ||||
} | |||||
}, | |||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
$.each(response.data, (_i, item) => { | $.each(response.data, (_i, item) => { | ||||
items.push({ | items.push({ | ||||
title: item.name, | title: item.name, | ||||
description: `${item.permission} access` // TODO: translate this string | |||||
description: `${item.permission} access`, // TODO: translate this string | |||||
}); | }); | ||||
}); | }); | ||||
return {results: items}; | return {results: items}; | ||||
} | |||||
}, | |||||
}, | }, | ||||
searchFields: ['name', 'description'], | searchFields: ['name', 'description'], | ||||
showNoResults: false | |||||
showNoResults: false, | |||||
}); | }); | ||||
} | } | ||||
const filteredResponse = {success: true, results: []}; | const filteredResponse = {success: true, results: []}; | ||||
filteredResponse.results.push({ | filteredResponse.results.push({ | ||||
name: '', | name: '', | ||||
value: '' | |||||
value: '', | |||||
}); | }); | ||||
// Parse the response from the api to work with our dropdown | // Parse the response from the api to work with our dropdown | ||||
$.each(response.data, (_r, repo) => { | $.each(response.data, (_r, repo) => { | ||||
filteredResponse.results.push({ | filteredResponse.results.push({ | ||||
name: htmlEscape(repo.repository.full_name), | name: htmlEscape(repo.repository.full_name), | ||||
value: repo.repository.id | |||||
value: repo.repository.id, | |||||
}); | }); | ||||
}); | }); | ||||
return filteredResponse; | return filteredResponse; | ||||
cache: false, | cache: false, | ||||
}, | }, | ||||
fullTextSearch: true | |||||
fullTextSearch: true, | |||||
}); | }); | ||||
}; | }; | ||||
$('#uid').on('change', changeOwner); | $('#uid').on('change', changeOwner); |
'gitea-code-inline', 'code', 'quote', '|', 'gitea-checkbox-empty', 'gitea-checkbox-checked', '|', | 'gitea-code-inline', 'code', 'quote', '|', 'gitea-checkbox-empty', 'gitea-checkbox-checked', '|', | ||||
'unordered-list', 'ordered-list', '|', | 'unordered-list', 'ordered-list', '|', | ||||
'link', 'image', 'table', 'horizontal-rule', '|', | 'link', 'image', 'table', 'horizontal-rule', '|', | ||||
'preview', 'fullscreen', 'side-by-side', '|', 'gitea-switch-to-textarea' | |||||
'preview', 'fullscreen', 'side-by-side', '|', 'gitea-switch-to-textarea', | |||||
], | ], | ||||
}, | }, | ||||
}); | }); |
}, | }, | ||||
menuItemTemplate: (item) => { | menuItemTemplate: (item) => { | ||||
return `<div class="tribute-item">${emojiHTML(item.original)}<span>${htmlEscape(item.original)}</span></div>`; | return `<div class="tribute-item">${emojiHTML(item.original)}<span>${htmlEscape(item.original)}</span></div>`; | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } | ||||
${item.original.fullname && item.original.fullname !== '' ? `<span class="fullname">${htmlEscape(item.original.fullname)}</span>` : ''} | ${item.original.fullname && item.original.fullname !== '' ? `<span class="fullname">${htmlEscape(item.original.fullname)}</span>` : ''} | ||||
</div> | </div> | ||||
`; | `; | ||||
} | |||||
}, | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
try { | try { | ||||
const credential = await navigator.credentials.get({ | const credential = await navigator.credentials.get({ | ||||
publicKey: options.publicKey | |||||
publicKey: options.publicKey, | |||||
}); | }); | ||||
await verifyAssertion(credential); | await verifyAssertion(credential); | ||||
} catch (err) { | } catch (err) { | ||||
delete options.publicKey.extensions.appid; | delete options.publicKey.extensions.appid; | ||||
try { | try { | ||||
const credential = await navigator.credentials.get({ | const credential = await navigator.credentials.get({ | ||||
publicKey: options.publicKey | |||||
publicKey: options.publicKey, | |||||
}); | }); | ||||
await verifyAssertion(credential); | await verifyAssertion(credential); | ||||
} catch (err) { | } catch (err) { | ||||
try { | try { | ||||
const credential = await navigator.credentials.create({ | const credential = await navigator.credentials.create({ | ||||
publicKey: options.publicKey | |||||
publicKey: options.publicKey, | |||||
}); | }); | ||||
await webauthnRegistered(credential); | await webauthnRegistered(credential); | ||||
} catch (err) { | } catch (err) { |
const observerConnect = (observer) => observer.observe(document, { | const observerConnect = (observer) => observer.observe(document, { | ||||
subtree: true, | subtree: true, | ||||
childList: true, | childList: true, | ||||
attributeFilter: ['data-tooltip-content', 'title'] | |||||
attributeFilter: ['data-tooltip-content', 'title'], | |||||
}); | }); | ||||
const observer = new MutationObserver((mutationList, observer) => { | const observer = new MutationObserver((mutationList, observer) => { | ||||
const pending = observer.takeRecords(); | const pending = observer.takeRecords(); |
docExpansion: 'none', | docExpansion: 'none', | ||||
defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete | defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete | ||||
presets: [ | presets: [ | ||||
SwaggerUI.presets.apis | |||||
SwaggerUI.presets.apis, | |||||
], | ], | ||||
plugins: [ | plugins: [ | ||||
SwaggerUI.plugins.DownloadUrl | |||||
] | |||||
SwaggerUI.plugins.DownloadUrl, | |||||
], | |||||
}); | }); | ||||
window.ui = ui; | window.ui = ui; |
name: {type: String, required: true}, | name: {type: String, required: true}, | ||||
size: {type: Number, default: 16}, | size: {type: Number, default: 16}, | ||||
className: {type: String, default: ''}, | className: {type: String, default: ''}, | ||||
symbolId: {type: String} | |||||
symbolId: {type: String}, | |||||
}, | }, | ||||
render() { | render() { | ||||
let {svgOuter, svgInnerHtml} = svgParseOuterInner(this.name); | let {svgOuter, svgInnerHtml} = svgParseOuterInner(this.name); |
textarea.removeEventListener('mousemove', onUserResize); | textarea.removeEventListener('mousemove', onUserResize); | ||||
textarea.removeEventListener('input', resizeToFit); | textarea.removeEventListener('input', resizeToFit); | ||||
textarea.form?.removeEventListener('reset', onFormReset); | textarea.form?.removeEventListener('reset', onFormReset); | ||||
} | |||||
}, | |||||
}; | }; | ||||
} | } | ||||
return { | return { | ||||
format(value) { | format(value) { | ||||
return ` ${value} ${options.unit}`; | return ` ${value} ${options.unit}`; | ||||
} | |||||
}, | |||||
}; | }; | ||||
} | } | ||||
return intlNumberFormat(locales, options); | return intlNumberFormat(locales, options); |
], | ], | ||||
}, | }, | ||||
}, | }, | ||||
} | |||||
}, | |||||
], | ], | ||||
}, | }, | ||||
{ | { | ||||
type: 'asset/resource', | type: 'asset/resource', | ||||
generator: { | generator: { | ||||
filename: 'fonts/[name].[contenthash:8][ext]', | filename: 'fonts/[name].[contenthash:8][ext]', | ||||
} | |||||
}, | |||||
}, | }, | ||||
{ | { | ||||
test: /\.png$/i, | test: /\.png$/i, | ||||
type: 'asset/resource', | type: 'asset/resource', | ||||
generator: { | generator: { | ||||
filename: 'img/webpack/[name].[contenthash:8][ext]', | filename: 'img/webpack/[name].[contenthash:8][ext]', | ||||
} | |||||
}, | |||||
}, | }, | ||||
], | ], | ||||
}, | }, |