[extensions-web] registration: prevent registration button double click



commit a50d3717700185e0aa61c9048d8d4e81338d5233
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Sun Jan 13 21:45:48 2019 +0400

    registration: prevent registration button double click

 sweettooth/auth/templates/registration/login.html      |  2 +-
 .../templates/registration/password_change_form.html   |  2 +-
 .../templates/registration/password_reset_confirm.html |  2 +-
 .../templates/registration/password_reset_form.html    |  2 +-
 .../auth/templates/registration/registration_form.html |  2 +-
 sweettooth/static/css/sweettooth.css                   | 18 +++++++++---------
 sweettooth/static/js/main.js                           |  6 ++++++
 7 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/sweettooth/auth/templates/registration/login.html 
b/sweettooth/auth/templates/registration/login.html
index e76599d..6b2b30c 100644
--- a/sweettooth/auth/templates/registration/login.html
+++ b/sweettooth/auth/templates/registration/login.html
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% block body %}
 <div class="col-sm-8 col-md-6 col-centered">
-<form action="" method="POST" class="form" id="auth_form">
+<form action="" method="POST" class="form auth_form">
   <h3>User Login</h3>
   <input type="hidden" name="next" value="{{ next }}">
   {% csrf_token %}
diff --git a/sweettooth/auth/templates/registration/password_change_form.html 
b/sweettooth/auth/templates/registration/password_change_form.html
index 80487f7..49330e2 100644
--- a/sweettooth/auth/templates/registration/password_change_form.html
+++ b/sweettooth/auth/templates/registration/password_change_form.html
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% block body %}
 <div class="col-sm-8 col-md-6 col-centered">
-<form action="" method="POST" id="auth_form">
+<form action="" method="POST" class="auth_form">
   {% csrf_token %}
   <h3>Change your password</h3>
   <ul>
diff --git a/sweettooth/auth/templates/registration/password_reset_confirm.html 
b/sweettooth/auth/templates/registration/password_reset_confirm.html
index 0b1e35d..ac28e0a 100644
--- a/sweettooth/auth/templates/registration/password_reset_confirm.html
+++ b/sweettooth/auth/templates/registration/password_reset_confirm.html
@@ -2,7 +2,7 @@
 {% block body %}
 {% if validlink %}
 <div class="col-sm-8 col-md-6 col-centered">
-<form action="" method="POST" id="auth_form">
+<form action="" method="POST" class="auth_form">
   {% csrf_token %}
   <h3>Password reset</h3>
   <ul>
diff --git a/sweettooth/auth/templates/registration/password_reset_form.html 
b/sweettooth/auth/templates/registration/password_reset_form.html
index e100ef2..05c690f 100644
--- a/sweettooth/auth/templates/registration/password_reset_form.html
+++ b/sweettooth/auth/templates/registration/password_reset_form.html
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% block body %}
 <div class="col-sm-8 col-md-6 col-centered">
-<form action="" method="POST" id="auth_form">
+<form action="" method="POST" class="auth_form">
   {% csrf_token %}
   <h3>Password reset</h3>
   <p>Forgotten your password? Enter your e-mail address below, and we’ll e-mail instructions for setting a 
new one.</p>
diff --git a/sweettooth/auth/templates/registration/registration_form.html 
b/sweettooth/auth/templates/registration/registration_form.html
index 4c39ea2..9117984 100644
--- a/sweettooth/auth/templates/registration/registration_form.html
+++ b/sweettooth/auth/templates/registration/registration_form.html
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% block body %}
 <div class="col-sm-8 col-md-6 col-centered">
-<form action="" method="POST" id="auth_form">
+<form action="" method="POST" class="auth_form" id='registration'>
   {% csrf_token %}
   <h3>Account Registration</h3>
   <ul>
diff --git a/sweettooth/static/css/sweettooth.css b/sweettooth/static/css/sweettooth.css
index f89d424..bd6d9f8 100644
--- a/sweettooth/static/css/sweettooth.css
+++ b/sweettooth/static/css/sweettooth.css
@@ -40,45 +40,45 @@ div.navbar-header a.unreviewed_counter:hover {
 /* Login Area */
 /* ==================================================================== */
 
-#auth_form  {
+.auth_form  {
     padding: 0;
     margin: 0;
 }
 
-#auth_form h3 {
+.auth_form h3 {
     color: #0489B7;
 }
 
-#auth_form li, #auth_form ol {
+.auth_form li, .auth_form ol {
     list-style-type: none;
 }
 
-#auth_form ul {
+.auth_form ul {
     padding: 0px;
 }
 
-#auth_form ul > li {
+.auth_form ul > li {
     margin-bottom: 15px;
 }
 
-#auth_form .helptext {
+.auth_form .helptext {
     display: block;
 }
 
-#auth_form label {
+.auth_form label {
     display: inline-block;
     line-height: 1.8;
     vertical-align: top;
 }
 
-#auth_form input {
+.auth_form input {
     width: 100%;
     height: 34px;
     padding: 6px 12px;
     font-size: 14px;
     line-height: 1.42857143;
 }
-#auth_form input:focus {
+.auth_form input:focus {
     border-color: #66afe9;
     outline: 0;
 }
diff --git a/sweettooth/static/js/main.js b/sweettooth/static/js/main.js
index 7a21c99..5025ba6 100644
--- a/sweettooth/static/js/main.js
+++ b/sweettooth/static/js/main.js
@@ -51,6 +51,12 @@ function($, messages, modal, hashParamUtils, templates, staticfiles, cookie) {
             return false;
         });
 
+        // Prevent double click on registration button
+        $('form#registration').on('submit', function(event) {
+               $("form#registration button[type='submit']").prop('disabled', true);
+               return true;
+        });
+
         // Add lightbox for screenshots
         $('div.extension-details').on('click', 'div.screenshot > a', function(event) {
             event.preventDefault();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]