Skip to content

Commit

Permalink
Remove jQuery from organization rename prompt toggle (go-gitea#29195)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
Co-authored-by: silverwind <[email protected]>
  • Loading branch information
yardenshoham and silverwind authored Feb 16, 2024
1 parent 45c1538 commit 5902372
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions web_src/js/features/common-organization.js
Original file line number Diff line number Diff line change
@@ -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);
});

Expand Down

0 comments on commit 5902372

Please sign in to comment.