From 1bf7b701180cf3d0de9ff3085aa152575bdd0940 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 17:48:01 +0200 Subject: [PATCH] Remove jQuery from organization rename prompt toggle (#29195) - Switched to plain JavaScript - Tested the organization rename prompt toggling functionality and it works as before # Demo using JavaScript without jQuery ![action](https://github.com/go-gitea/gitea/assets/20454870/e6f641b0-aa46-4b85-9693-0d608cca855e) --------- Signed-off-by: Yarden Shoham Co-authored-by: silverwind (cherry picked from commit 5902372e63db2d3f31150251dfffdb305fa9aaee) --- web_src/js/features/common-organization.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web_src/js/features/common-organization.js b/web_src/js/features/common-organization.js index 352e824b05..a950af3adf 100644 --- a/web_src/js/features/common-organization.js +++ b/web_src/js/features/common-organization.js @@ -1,14 +1,15 @@ -import $ from 'jquery'; import {initCompLabelEdit} from './comp/LabelEdit.js'; import {toggleElem} from '../utils/dom.js'; export function initCommonOrganization() { - if ($('.organization').length === 0) { + if (!document.querySelectorAll('.organization').length) { return; } - $('.organization.settings.options #org_name').on('input', function () { - const nameChanged = $(this).val().toLowerCase() !== $(this).attr('data-org-name').toLowerCase(); + const orgNameInput = document.querySelector('.organization.settings.options #org_name'); + if (!orgNameInput) return; + orgNameInput.addEventListener('input', function () { + const nameChanged = this.value.toLowerCase() !== this.getAttribute('data-org-name').toLowerCase(); toggleElem('#org-name-change-prompt', nameChanged); });