Added tag validate button
This commit is contained in:
@ -49,9 +49,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="{{ url_for('static', filename='js/main.js') }}" defer></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/upload.js') }}" defer></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/build.js') }}" defer></script>
|
|
||||||
<!-- Delete confirmation modal -->
|
<!-- Delete confirmation modal -->
|
||||||
<div id="delete-modal" class="modal" style="display:none;">
|
<div id="delete-modal" class="modal" style="display:none;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -68,6 +65,6 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/gallery-editor.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/upload.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/upload.js') }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -92,6 +92,14 @@ function renderTags(imgIndex, tags) {
|
|||||||
input.placeholder = 'Add tag...';
|
input.placeholder = 'Add tag...';
|
||||||
inputContainer.appendChild(input);
|
inputContainer.appendChild(input);
|
||||||
|
|
||||||
|
// --- Validate button ---
|
||||||
|
const validateBtn = document.createElement('button');
|
||||||
|
validateBtn.textContent = '✔️';
|
||||||
|
validateBtn.className = 'validate-tag-btn';
|
||||||
|
validateBtn.style.display = 'none'; // hidden by default
|
||||||
|
validateBtn.style.marginLeft = '4px';
|
||||||
|
inputContainer.appendChild(validateBtn);
|
||||||
|
|
||||||
const suggestionBox = document.createElement('ul');
|
const suggestionBox = document.createElement('ul');
|
||||||
suggestionBox.className = 'suggestions';
|
suggestionBox.className = 'suggestions';
|
||||||
inputContainer.appendChild(suggestionBox);
|
inputContainer.appendChild(suggestionBox);
|
||||||
@ -148,8 +156,14 @@ function renderTags(imgIndex, tags) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
input.addEventListener('input', updateSuggestions);
|
input.addEventListener('input', () => {
|
||||||
input.addEventListener('focus', updateSuggestions);
|
updateSuggestions();
|
||||||
|
validateBtn.style.display = input.value.trim() ? 'inline-block' : 'none';
|
||||||
|
});
|
||||||
|
input.addEventListener('focus', () => {
|
||||||
|
updateSuggestions();
|
||||||
|
validateBtn.style.display = input.value.trim() ? 'inline-block' : 'none';
|
||||||
|
});
|
||||||
|
|
||||||
input.addEventListener('keydown', (e) => {
|
input.addEventListener('keydown', (e) => {
|
||||||
const items = suggestionBox.querySelectorAll('li');
|
const items = suggestionBox.querySelectorAll('li');
|
||||||
@ -172,11 +186,13 @@ function renderTags(imgIndex, tags) {
|
|||||||
}
|
}
|
||||||
input.value = '';
|
input.value = '';
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
|
validateBtn.style.display = 'none';
|
||||||
} else if ([' ', ','].includes(e.key)) {
|
} else if ([' ', ','].includes(e.key)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
addTag(input.value);
|
addTag(input.value);
|
||||||
input.value = '';
|
input.value = '';
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
|
validateBtn.style.display = 'none';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,9 +200,20 @@ function renderTags(imgIndex, tags) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
suggestionBox.style.display = 'none';
|
suggestionBox.style.display = 'none';
|
||||||
input.value = '';
|
input.value = '';
|
||||||
|
validateBtn.style.display = 'none';
|
||||||
}, 150);
|
}, 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- Validate button action ---
|
||||||
|
validateBtn.onclick = () => {
|
||||||
|
if (input.value.trim()) {
|
||||||
|
addTag(input.value.trim());
|
||||||
|
input.value = '';
|
||||||
|
updateSuggestions();
|
||||||
|
validateBtn.style.display = 'none';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
input.focus();
|
input.focus();
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
}
|
}
|
@ -165,7 +165,6 @@ h2 {
|
|||||||
/* --- Tags --- */
|
/* --- Tags --- */
|
||||||
.tag-input {
|
.tag-input {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap-reverse;
|
|
||||||
align-content: flex-start;
|
align-content: flex-start;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -889,3 +888,19 @@ justify-content: center;
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.photo button.validate-tag-btn {
|
||||||
|
border-radius: 30px;
|
||||||
|
border: none;
|
||||||
|
background: #049b3d;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-left: 4px;
|
||||||
|
transition: all ease 0.2s;
|
||||||
|
width: 35px;
|
||||||
|
border: 1px solid #585858;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo button.validate-tag-btn:hover {
|
||||||
|
background: #02cb4e;
|
||||||
|
}
|
Reference in New Issue
Block a user