networks: Fix showing password during PPPoE edit

- Javascript was missing for the template altogether.  Added one similar
  to create case.

- Minor refactoring to existing javascript.

- Consistent styling for display label and field id.
This commit is contained in:
Sunil Mohan Adapa 2015-08-22 20:22:08 +05:30
parent 1e10fb76fc
commit 4f75f44769
3 changed files with 22 additions and 14 deletions

View File

@ -89,8 +89,8 @@ available over this interfaces. Select Internal only for trusted networks.'),
username = forms.CharField(label=_('Username'))
password = forms.CharField(label=_('Password'),
widget=forms.PasswordInput())
showpw = forms.BooleanField(label=_('show password'),
required=False)
show_password = forms.BooleanField(label=_('Show password'),
required=False)
def __init__(self, *args, **kwargs):
"""Initialize the form, populate interface choices."""

View File

@ -58,18 +58,15 @@
}
});
$('#id_showpw').change(function() {
//changing type attribute from password to text is prevented by
//most browsers make a new form field works for me
if ($('#id_showpw').prop('checked')) {
$('#id_password').replaceWith(
$('#id_password').clone().attr(
'type', 'text'));
} else {
$('#id_password').replaceWith(
$('#id_password').clone().attr(
'type', 'password'));
}
$('#id_show_password').change(function() {
// Changing type attribute from password to text is prevented by
// most browsers. Making a new form field works.
new_type = 'password';
if ($('#id_show_password').prop('checked'))
new_type = 'text';
$('#id_password').replaceWith(
$('#id_password').clone().attr('type', new_type));
});
})(jQuery);

View File

@ -58,6 +58,17 @@
}
});
$('#id_show_password').change(function() {
// Changing type attribute from password to text is prevented by
// most browsers. Making a new form field works.
new_type = 'password';
if ($('#id_show_password').prop('checked'))
new_type = 'text';
$('#id_password').replaceWith(
$('#id_password').clone().attr('type', new_type));
});
})(jQuery);
</script>