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 <git@yardenshoham.com>
Co-authored-by: silverwind <me@silverwind.io>
(cherry picked from commit 5902372e63db2d3f31150251dfffdb305fa9aaee)
This commit is contained in:
Yarden Shoham 2024-02-16 17:48:01 +02:00 committed by Earl Warren
parent 2e887067df
commit 1bf7b70118
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -1,14 +1,15 @@
import $ from 'jquery';
import {initCompLabelEdit} from './comp/LabelEdit.js'; import {initCompLabelEdit} from './comp/LabelEdit.js';
import {toggleElem} from '../utils/dom.js'; import {toggleElem} from '../utils/dom.js';
export function initCommonOrganization() { export function initCommonOrganization() {
if ($('.organization').length === 0) { if (!document.querySelectorAll('.organization').length) {
return; return;
} }
$('.organization.settings.options #org_name').on('input', function () { const orgNameInput = document.querySelector('.organization.settings.options #org_name');
const nameChanged = $(this).val().toLowerCase() !== $(this).attr('data-org-name').toLowerCase(); if (!orgNameInput) return;
orgNameInput.addEventListener('input', function () {
const nameChanged = this.value.toLowerCase() !== this.getAttribute('data-org-name').toLowerCase();
toggleElem('#org-name-change-prompt', nameChanged); toggleElem('#org-name-change-prompt', nameChanged);
}); });