Добавлен переключатель видимости пароля на всех страницах входа
This commit is contained in:
25
myproject/accounts/static/accounts/js/auth.js
Normal file
25
myproject/accounts/static/accounts/js/auth.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Authentication-related JavaScript functionality
|
||||||
|
|
||||||
|
// Password visibility toggle handler
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Add click handlers to all password toggle buttons
|
||||||
|
document.querySelectorAll('.show-password-btn').forEach(button => {
|
||||||
|
button.addEventListener('click', function() {
|
||||||
|
const targetId = this.getAttribute('data-target');
|
||||||
|
const targetInput = document.getElementById(targetId);
|
||||||
|
const icon = this.querySelector('i');
|
||||||
|
|
||||||
|
if (targetInput && icon) {
|
||||||
|
if (targetInput.type === 'password') {
|
||||||
|
targetInput.type = 'text';
|
||||||
|
icon.classList.remove('bi-eye');
|
||||||
|
icon.classList.add('bi-eye-slash');
|
||||||
|
} else {
|
||||||
|
targetInput.type = 'password';
|
||||||
|
icon.classList.remove('bi-eye-slash');
|
||||||
|
icon.classList.add('bi-eye');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -39,25 +39,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// Добавляем обработчик для показа/скрытия пароля
|
|
||||||
document.querySelectorAll('.show-password-btn').forEach(button => {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
const targetId = this.getAttribute('data-target');
|
|
||||||
const targetInput = document.getElementById(targetId);
|
|
||||||
const icon = this.querySelector('i');
|
|
||||||
|
|
||||||
if (targetInput.type === 'password') {
|
|
||||||
targetInput.type = 'text';
|
|
||||||
icon.classList.remove('bi-eye');
|
|
||||||
icon.classList.add('bi-eye-slash');
|
|
||||||
} else {
|
|
||||||
targetInput.type = 'password';
|
|
||||||
icon.classList.remove('bi-eye-slash');
|
|
||||||
icon.classList.add('bi-eye');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -32,25 +32,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// Добавляем обработчик для показа/скрытия пароля
|
|
||||||
document.querySelectorAll('.show-password-btn').forEach(button => {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
const targetId = this.getAttribute('data-target');
|
|
||||||
const targetInput = document.getElementById(targetId);
|
|
||||||
const icon = this.querySelector('i');
|
|
||||||
|
|
||||||
if (targetInput.type === 'password') {
|
|
||||||
targetInput.type = 'text';
|
|
||||||
icon.classList.remove('bi-eye');
|
|
||||||
icon.classList.add('bi-eye-slash');
|
|
||||||
} else {
|
|
||||||
targetInput.type = 'password';
|
|
||||||
icon.classList.remove('bi-eye-slash');
|
|
||||||
icon.classList.add('bi-eye');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -54,6 +54,9 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/i18n/ru.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/i18n/ru.js"></script>
|
||||||
|
|
||||||
|
<!-- Auth functionality -->
|
||||||
|
<script src="{% static 'accounts/js/auth.js' %}"></script>
|
||||||
|
|
||||||
{% block extra_js %}{% endblock %}
|
{% block extra_js %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -32,25 +32,4 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// Добавляем обработчик для показа/скрытия пароля
|
|
||||||
document.querySelectorAll('.show-password-btn').forEach(button => {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
const targetId = this.getAttribute('data-target');
|
|
||||||
const targetInput = document.getElementById(targetId);
|
|
||||||
const icon = this.querySelector('i');
|
|
||||||
|
|
||||||
if (targetInput.type === 'password') {
|
|
||||||
targetInput.type = 'text';
|
|
||||||
icon.classList.remove('bi-eye');
|
|
||||||
icon.classList.add('bi-eye-slash');
|
|
||||||
} else {
|
|
||||||
targetInput.type = 'password';
|
|
||||||
icon.classList.remove('bi-eye-slash');
|
|
||||||
icon.classList.add('bi-eye');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -31,10 +31,7 @@
|
|||||||
<label for="email" class="form-label">Email</label>
|
<label for="email" class="form-label">Email</label>
|
||||||
<input type="email" class="form-control" id="email" name="email" required autofocus>
|
<input type="email" class="form-control" id="email" name="email" required autofocus>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
{% include 'accounts/password_input.html' with field_name='password' field_label='Пароль' required=True %}
|
||||||
<label for="password" class="form-label">Пароль</label>
|
|
||||||
<input type="password" class="form-control" id="password" name="password" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary w-100 py-2 mb-3">Войти</button>
|
<button type="submit" class="btn btn-primary w-100 py-2 mb-3">Войти</button>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user