Skip to content

Remove jQuery import from some files #32512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web_src/js/components/DashboardRepoList.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import {createApp, nextTick} from 'vue';
import $ from 'jquery';
import {SvgIcon} from '../svg.ts';
import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

const {appSubUrl, assetUrlPrefix, pageData} = window.config;

Expand Down Expand Up @@ -102,7 +102,7 @@ const sfc = {
mounted() {
const el = document.querySelector('#dashboard-repo-list');
this.changeReposFilter(this.reposFilter);
$(el).find('.dropdown').dropdown();
fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
nextTick(() => {
this.$refs.search.focus();
});
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/components/RepoContributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import {chartJsColors} from '../utils/color.ts';
import {sleep} from '../utils.ts';
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
import $ from 'jquery';
import {fomanticQuery} from '../modules/fomantic/base.ts';

const customEventListener = {
id: 'customEventListener',
Expand Down Expand Up @@ -77,7 +77,7 @@ export default {
mounted() {
this.fetchGraphData();

$('#repo-contributors').dropdown({
fomanticQuery('#repo-contributors').dropdown({
onChange: (val) => {
this.xAxisMin = this.xAxisStart;
this.xAxisMax = this.xAxisEnd;
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/citation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from 'jquery';
import {getCurrentLocale} from '../utils.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

const {pageData} = window.config;

Expand Down Expand Up @@ -71,6 +71,6 @@ export async function initCitationFileCopyContent() {
dropdownBtn.classList.remove('is-loading');
}

$('#cite-repo-modal').modal('show');
fomanticQuery('#cite-repo-modal').modal('show');
});
}
7 changes: 3 additions & 4 deletions web_src/js/features/common-form.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import $ from 'jquery';
import {initAreYouSure} from '../vendor/jquery.are-you-sure.ts';
import {applyAreYouSure, initAreYouSure} from '../vendor/jquery.are-you-sure.ts';
import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.ts';

export function initGlobalFormDirtyLeaveConfirm() {
initAreYouSure(window.jQuery);
// Warn users that try to leave a page after entering data into a form.
// Except on sign-in pages, and for forms marked as 'ignore-dirty'.
if (!$('.user.signin').length) {
$('form:not(.ignore-dirty)').areYouSure();
if (!document.querySelector('.page-content.user.signin')) {
applyAreYouSure('form:not(.ignore-dirty)');
}
}

Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/comp/ConfirmModal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'jquery';
import {svg} from '../../svg.ts';
import {htmlEscape} from 'escape-goat';
import {createElementFromHTML} from '../../utils/dom.ts';
import {fomanticQuery} from '../../modules/fomantic/base.ts';

const {i18n} = window.config;

Expand All @@ -17,7 +17,7 @@ export function confirmModal(content, {confirmButtonColor = 'primary'} = {}) {
</div>
`);
document.body.append(modal);
const $modal = $(modal);
const $modal = fomanticQuery(modal);
$modal.modal({
onApprove() {
resolve(true);
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/comp/ReactionSelector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from 'jquery';
import {POST} from '../../modules/fetch.ts';
import {fomanticQuery} from '../../modules/fomantic/base.ts';

export function initCompReactionSelector() {
for (const container of document.querySelectorAll('.issue-content, .diff-file-body')) {
Expand Down Expand Up @@ -29,7 +29,7 @@ export function initCompReactionSelector() {
if (data.html) {
commentContainer.insertAdjacentHTML('beforeend', data.html);
const bottomReactionsDropdowns = commentContainer.querySelectorAll('.bottom-reactions .dropdown.select-reaction');
$(bottomReactionsDropdowns).dropdown(); // re-init the dropdown
fomanticQuery(bottomReactionsDropdowns).dropdown(); // re-init the dropdown
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/comp/SearchUserBox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from 'jquery';
import {htmlEscape} from 'escape-goat';
import {fomanticQuery} from '../../modules/fomantic/base.ts';

const {appSubUrl} = window.config;
const looksLikeEmailAddressCheck = /^\S+@\S+$/;
Expand All @@ -10,7 +10,7 @@ export function initCompSearchUserBox() {

const allowEmailInput = searchUserBox.getAttribute('data-allow-email') === 'true';
const allowEmailDescription = searchUserBox.getAttribute('data-allow-email-description') ?? undefined;
$(searchUserBox).search({
fomanticQuery(searchUserBox).search({
minCharacters: 2,
apiSettings: {
url: `${appSubUrl}/user/search_candidates?q={query}`,
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/repo-branch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from 'jquery';
import {toggleElem} from '../utils/dom.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

export function initRepoBranchButton() {
initRepoCreateBranchButton();
Expand All @@ -18,7 +18,7 @@ function initRepoCreateBranchButton() {
const fromSpanName = el.getAttribute('data-modal-from-span') || '#modal-create-branch-from-span';
document.querySelector(fromSpanName).textContent = el.getAttribute('data-branch-from');

$(el.getAttribute('data-modal')).modal('show');
fomanticQuery(el.getAttribute('data-modal')).modal('show');
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions web_src/js/features/repo-graph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from 'jquery';
import {hideElem, showElem} from '../utils/dom.ts';
import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

export function initRepoGraphGit() {
const graphContainer = document.querySelector('#git-graph-container');
Expand Down Expand Up @@ -83,8 +83,8 @@ export function initRepoGraphGit() {
}

const flowSelectRefsDropdown = document.querySelector('#flow-select-refs-dropdown');
$(flowSelectRefsDropdown).dropdown('set selected', dropdownSelected);
$(flowSelectRefsDropdown).dropdown({
fomanticQuery(flowSelectRefsDropdown).dropdown('set selected', dropdownSelected);
fomanticQuery(flowSelectRefsDropdown).dropdown({
clearable: true,
fullTextSeach: 'exact',
onRemove(toRemove) {
Expand Down
6 changes: 3 additions & 3 deletions web_src/js/features/repo-home.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import $ from 'jquery';
import {stripTags} from '../utils.ts';
import {hideElem, queryElemChildren, showElem} from '../utils/dom.ts';
import {POST} from '../modules/fetch.ts';
import {showErrorToast} from '../modules/toast.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

const {appSubUrl} = window.config;

Expand Down Expand Up @@ -73,7 +73,7 @@ export function initRepoTopicBar() {
}
});

$(topicDropdown).dropdown({
fomanticQuery(topicDropdown).dropdown({
allowAdditions: true,
forceSelection: false,
fullTextSearch: 'exact',
Expand Down Expand Up @@ -136,7 +136,7 @@ export function initRepoTopicBar() {
onLabelCreate(value) {
value = value.toLowerCase().trim();
this.attr('data-value', value).contents().first().replaceWith(value);
return $(this);
return fomanticQuery(this);
},
onAdd(addedValue, _addedText, $addedChoice) {
addedValue = addedValue.toLowerCase().trim();
Expand Down
4 changes: 4 additions & 0 deletions web_src/js/vendor/jquery.are-you-sure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ export function initAreYouSure($) {
});
};
}

export function applyAreYouSure(selector: string) {
$(selector).areYouSure();
}