Skip to content

Commit

Permalink
remove jq and fix value check
Browse files Browse the repository at this point in the history
  • Loading branch information
Zettat123 committed Mar 2, 2023
1 parent e72b39c commit 993d74e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions web_src/js/features/tag-name-editor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import $ from 'jquery';
import {hideElem, showElem} from '../utils/dom.js';

export function initTagNameEditor() {
Expand All @@ -12,18 +11,18 @@ export function initTagNameEditor() {
const newTagHelperText = el.getAttribute('data-tag-helper-new');
const existingTagHelperText = el.getAttribute('data-tag-helper-existing');

$('#tag-name').on('keyup', (e) => {
document.getElementById('tag-name').addEventListener('keyup', (e) => {
const value = e.target.value;
if (existingTags.includes(value)) {
// If the tag already exists, hide the target branch selector.
hideElem($('#tag-target-selector'));
$('#tag-helper').text(existingTagHelperText);
hideElem('#tag-target-selector');
document.getElementById('tag-helper').innerText = existingTagHelperText;
} else {
showElem($('#tag-target-selector'));
if (typeof value === 'string' && value.length > 0) {
$('#tag-helper').text(newTagHelperText);
showElem('#tag-target-selector');
if (value) {
document.getElementById('tag-helper').innerText = newTagHelperText;
} else {
$('#tag-helper').text(defaultTagHelperText);
document.getElementById('tag-helper').innerText = defaultTagHelperText;
}
}
});
Expand Down

0 comments on commit 993d74e

Please sign in to comment.