Add show-password checkbox and make it work
authorJef van Schendel <mail@jefvanschendel.nl>
Fri, 2 Dec 2011 22:48:40 +0000 (23:48 +0100)
committerJef van Schendel <mail@jefvanschendel.nl>
Fri, 2 Dec 2011 22:48:40 +0000 (23:48 +0100)
mediagoblin/auth/forms.py
mediagoblin/templates/mediagoblin/auth/register.html
mediagoblin/templates/mediagoblin/base.html

index dcb6766c416b7b5704acd7ac508fa6c82a012b2d..4cd3e9d82db7d51076bf9b790b4ee7c4f8ca2595 100644 (file)
@@ -29,15 +29,7 @@ class RegistrationForm(wtforms.Form):
     password = wtforms.PasswordField(
         _('Password'),
         [wtforms.validators.Required(),
-         wtforms.validators.Length(min=6, max=30),
-         wtforms.validators.EqualTo(
-                'confirm_password',
-                _('Passwords must match.'))])
-    confirm_password = wtforms.PasswordField(
-        _('Confirm password'),
-        [wtforms.validators.Required()],
-        description=_(
-            u"Type it again here to make sure there are no spelling mistakes."))
+         wtforms.validators.Length(min=6, max=30)])
     email = wtforms.TextField(
         _('Email address'),
         [wtforms.validators.Required(),
index a0d0a2775ecbc912f0444713f72ca07018352d7e..bded1d7ee64e37c2ab1cfbd36289bef4ba3f9a6d 100644 (file)
 
 {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
 
+{% block mediagoblin_head %}
+  <script>
+    $(document).ready(function(){
+      $("#password").after('<input type="text" value="" name="password_clear" id="password_clear" /><input type="checkbox" id="password_boolean" />Show password');
+      $('#password_clear').hide();
+      $('#password_boolean').click(function(){
+        if($('#password_boolean').prop("checked")) {
+          $('#password_clear').val($('#password').val());
+          $('#password').hide();
+          $('#password_clear').show();
+        } else {
+          $('#password').val($('#password_clear').val());
+          $('#password_clear').hide();
+          $('#password').show();
+        };
+      });
+    });
+  </script>
+{% endblock mediagoblin_head %}
+
 {% block mediagoblin_content %}
 
   <form action="{{ request.urlgen('mediagoblin.auth.register') }}"
index 29639026573ce77a3d75b8398eee14aa5478576c..3441365f041a400f7e4551ca4782faebd0f86979 100644 (file)
           href="{{ request.staticdirect('/css/video-js.css') }}"/>
     <link rel="shortcut icon"
           href="{{ request.staticdirect('/images/goblin.ico') }}" />
+    <script type="text/javascript"
+          src="{{ request.staticdirect('/js/extlib/jquery.js') }}"></script>
     {% block mediagoblin_head %}
     {% endblock mediagoblin_head %}
   </head>
-
   <body>
     {% block mediagoblin_body %}
     <div class="mediagoblin_body">