Skip to content

Commit

Permalink
Merge branch 'master' into form_autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 authored Nov 3, 2023
2 parents 86ceb07 + 0310edb commit d506266
Show file tree
Hide file tree
Showing 15 changed files with 256 additions and 28 deletions.
16 changes: 16 additions & 0 deletions portal/static/portal/js/independentLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$(document).ready(() => {
$('#independent_student_login_form').on('click', '#password-field-icon', () => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_password').attr('type', inputType);
$('#password-field-icon').attr('data-icon', dataIcon);
});
});
62 changes: 62 additions & 0 deletions portal/static/portal/js/organisation_manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,65 @@ function showDeleteAccountConfirmation(delete_password, unsubscribe_newsletter,
function hideDeleteAccountPopup() {
$("#popup-delete-review").removeClass("popup--fade");
}

$(document).ready(() => {
$('#edit_account_details_password, #student_account_form').on(
'click',
'#password-field-icon, #confirm-password-field-icon',
() => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_password').attr('type', inputType);
$('#id_confirm_password').attr('type', inputType);

$('#password-field-icon').attr('data-icon', dataIcon);
$('#confirm-password-field-icon').attr('data-icon', dataIcon);
}
);

$('#edit_account_details_password, #student_account_form').on(
'click',
'#current-password-field-icon',
() => {
let inputType;
let dataIcon = $('#current-password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_current_password').attr('type', inputType);
$('#current-password-field-icon').attr('data-icon', dataIcon);
}
);

$('#delete-account, #delete-indy-account').on(
'click',
'#delete-password-field-icon',
() => {
let inputType;
let dataIcon = $('#delete-password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_delete_password').attr('type', inputType);
$('#delete-password-field-icon').attr('data-icon', dataIcon);
}
);
});
46 changes: 46 additions & 0 deletions portal/static/portal/js/passwordStrength.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,56 @@ async function handlePwnedPasswordApiAvailability() {
}
}

function onClickPasswordVisibility(
formId,
passwordIconId,
confirmPasswordIconId,
passwordId,
confirmPasswordId
) {
// Delegate event listeners.
$(formId).on('click', '[data-icon^="material-symbols:visibility"]', function () {
// Get icons and input types.
let inputType;
let dataIcon;
if ($(this).attr('data-icon') === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

// Set icons.
$(passwordIconId).attr('data-icon', dataIcon);
$(confirmPasswordIconId).attr('data-icon', dataIcon);

// Set input types.
$(passwordId).attr('type', inputType);
$(confirmPasswordId).attr('type', inputType);
})
}

$(document).ready(function () {
handlePasswordStrength(); // the password strength text is updated dynamically hence this is the initial first call
handlePwnedPasswordApiAvailability();
$(
`#${TEACHER_PASSWORD_FIELD_ID}, #${INDEP_STUDENT_PASSWORD_FIELD_ID}`
).on('input change focus blur', handlePasswordStrength);

onClickPasswordVisibility(
'#teacher-register-form',
'#teacher-password-field-icon',
'#teacher-confirm-password-field-icon',
'#id_teacher_signup-teacher_password',
'#id_teacher_signup-teacher_confirm_password'
);

onClickPasswordVisibility(
'#independent-student-register-form',
'#independent-student-password-field-icon',
'#independent-student-confirm-password-field-icon',
'#id_independent_student_signup-password',
'#id_independent_student_signup-confirm_password'
);
});
23 changes: 23 additions & 0 deletions portal/static/portal/js/resetPassword.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$(document).ready(() => {
$('#reset-password-form').on(
'click',
'#password-field-icon, #confirm-password-field-icon',
() => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_new_password1').attr('type', inputType);
$('#id_new_password2').attr('type', inputType);

$('#password-field-icon').attr('data-icon', dataIcon);
$('#confirm-password-field-icon').attr('data-icon', dataIcon);
}
);
});
16 changes: 16 additions & 0 deletions portal/static/portal/js/studentLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$(document).ready(() => {
$('#form-login-school').on('click', '#password-field-icon', () => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_password').attr('type', inputType);
$('#password-field-icon').attr('data-icon', dataIcon);
});
});
23 changes: 23 additions & 0 deletions portal/static/portal/js/teacherEditStudent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$(document).ready(() => {
$('#edit-student-password-form').on(
'click',
'#password-field-icon, #confirm-password-field-icon',
() => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_password').attr('type', inputType);
$('#id_confirm_password').attr('type', inputType);

$('#password-field-icon').attr('data-icon', dataIcon);
$('#confirm-password-field-icon').attr('data-icon', dataIcon);
}
);
});
16 changes: 16 additions & 0 deletions portal/static/portal/js/teacherLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$(document).ready(() => {
$('#form-login-teacher').on('click', '#password-field-icon', () => {
let inputType;
let dataIcon = $('#password-field-icon').attr('data-icon');
if (dataIcon === 'material-symbols:visibility') {
inputType = 'password';
dataIcon = 'material-symbols:visibility-off';
} else {
inputType = 'text';
dataIcon = 'material-symbols:visibility';
}

$('#id_auth-password').attr('type', inputType);
$('#password-field-icon').attr('data-icon', dataIcon);
});
});
7 changes: 5 additions & 2 deletions portal/templates/portal/login/independent_student.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ <h5>Please enter your login details.</h5>
{{ form.username.errors }}
</div>

<div class="form__input">
{{ form.password }}
<div class="form--row">
<div class="input--icon">
{{ form.password }} <span id="password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.password.help_text }}</small>
{{ form.password.errors }}
</div>
Expand All @@ -42,4 +44,5 @@ <h5>Please enter your login details.</h5>
class="button button--home button--login button-right-arrow">Log in</button>
</div>
</form>
<script type="text/javascript" src="{% static 'portal/js/independentLogin.js' %}"></script>
{% endblock form_content %}
7 changes: 5 additions & 2 deletions portal/templates/portal/login/student.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ <h5>Please enter your login details.</h5>
{{ form.username.errors }}
</div>

<div class="form__input">
{{ form.password }}
<div class="form--row">
<div class="input--icon">
{{ form.password }} <span id="password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.password.help_text }}</small>
{{ form.password.errors }}
</div>
Expand All @@ -29,4 +31,5 @@ <h5>Please enter your login details.</h5>
Log in</button>
</div>
</form>
<script type="text/javascript" src="{% static 'portal/js/studentLogin.js' %}"></script>
{% endblock form_content %}
8 changes: 6 additions & 2 deletions portal/templates/portal/login/teacher.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ <h5>Please enter your login details.</h5>
{{ form.username.errors }}
</div>

<div class="form__input">
{{ form.password }}
<div class="form--row">
<div class="input--icon">
{{ form.password }} <span id="password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.password.help_text }}</small>
{{ form.password.errors }}
</div>
Expand All @@ -66,4 +68,6 @@ <h5>Please enter your login details.</h5>
{% include "two_factor/core/login.html" %}
{% endif %}

<script type="text/javascript" src="{% static 'portal/js/teacherLogin.js' %}"></script>

{% endblock content %}
13 changes: 8 additions & 5 deletions portal/templates/portal/play/student_edit_account.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ <h1 class="banner__text--primary">Welcome, {{ user|make_into_username }}</h1>
<div class="form--row__input col-md-4">
<div class="input--icon">
{{ form.password }}
<span class="iconify" data-icon="mdi:security"></span>
<span id="password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.password.help_text }}</small>
{{ form.password.errors }}
</div>
<div class="form--row__input col-md-4">
{{ form.confirm_password }}
<div class="input--icon">
{{ form.confirm_password }}
<span id="confirm-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.confirm_password.help_text }}</small>
{{ form.confirm_password.errors }}
</div>
<div class="form--row__input col-md-4">
<div class="input--icon">
{{ form.current_password }}
<span class="iconify" data-icon="mdi:security"></span>
<span id="current-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ form.current_password.help_text }}</small>
{{ form.current_password.errors }}
Expand Down Expand Up @@ -147,8 +150,8 @@ <h5>Delete account</h5>
<div class="row form--row">
<div class="form--row__input col-sm-6 col-md-4">
<div class="input--icon">
{{ delete_account_form.delete_password }}
<span class="iconify" data-icon="mdi:security"></span>
{{ delete_account_form.delete_password }}
<span id="delete-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ delete_account_form.delete_password.help_text }}</small>
{{ delete_account_form.delete_password.errors }}
Expand Down
12 changes: 6 additions & 6 deletions portal/templates/portal/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div id="signup_page"></div>
<div id="register-forms" class="container registration">
<div class="form--register--text form--register form--register--teacher is-flex-item col-sm-6">
<div class="form-div form">
<div id="teacher-register-form" class="form-div form">
<h4>Teacher/Tutor</h4>
<div class="row form--row">
<p class="semi-bold">Register below to create your school or club.</p>
Expand Down Expand Up @@ -53,15 +53,15 @@ <h4>Teacher/Tutor</h4>
<div class="row form--row">
<label for="id_teacher_signup-teacher_password"></label>
<div class="input--icon">
{{ teacher_signup_form.teacher_password }}<span class="iconify" data-icon="mdi:security"></span>
{{ teacher_signup_form.teacher_password }}<span id="teacher-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ teacher_signup_form.teacher_password.help_text }}</small>
{{ teacher_signup_form.teacher_password.errors }}
</div>
<div class="row form--row">
<label for="id_teacher_signup-teacher_confirm_password"></label>
<div class="input--icon">
{{ teacher_signup_form.teacher_confirm_password }}<span class="iconify" data-icon="mdi:security"></span>
{{ teacher_signup_form.teacher_confirm_password }}<span id="teacher-confirm-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ teacher_signup_form.teacher_confirm_password.help_text }}</small>
{{ teacher_signup_form.teacher_confirm_password.errors }}
Expand All @@ -84,7 +84,7 @@ <h4>Teacher/Tutor</h4>
</div>
</div>
<div class="form--register--text form--register form--register--indep-student is-flex-item col-sm-6">
<div class="form-div">
<div id="independent-student-register-form" class="form-div">
<h4>Independent learner</h4>
<div class="row form--row">
<p class="semi-bold">
Expand Down Expand Up @@ -149,7 +149,7 @@ <h4>Independent learner</h4>
<label for="id_{{ independent_student_signup_form.password.html_name }}">
</label>
<div class="input--icon">
{{ independent_student_signup_form.password }} <span class="iconify" data-icon="mdi:security"></span>
{{ independent_student_signup_form.password }} <span id="independent-student-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ independent_student_signup_form.password.help_text }}</small>
{{ independent_student_signup_form.password.errors }}
Expand All @@ -158,7 +158,7 @@ <h4>Independent learner</h4>
<label for="id_{{ independent_student_signup_form.confirm_password.html_name }}">
</label>
<div class="input--icon">
{{ independent_student_signup_form.confirm_password }}<span class="iconify" data-icon="mdi:security"></span>
{{ independent_student_signup_form.confirm_password }}<span id="independent-student-confirm-password-field-icon" class="iconify" data-icon="material-symbols:visibility-off"></span>
</div>
<small>{{ independent_student_signup_form.confirm_password.help_text }}</small>
{{ independent_student_signup_form.confirm_password.errors }}
Expand Down
Loading

0 comments on commit d506266

Please sign in to comment.