disabled submit on registration to avoid duplicate account creation
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
(function($) {
|
||||
|
||||
MaterioUser = function(){
|
||||
|
||||
|
||||
var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
|
||||
|
||||
function init() {
|
||||
@@ -17,7 +17,7 @@ MaterioUser = function(){
|
||||
// trace('initAdhesion');
|
||||
$('.get-link a').bind('click', function(event) {
|
||||
// trace('get-link click');
|
||||
|
||||
|
||||
// do not show the registration form if already logged-in
|
||||
if($('body').is('.logged-in'))
|
||||
return true;
|
||||
@@ -29,7 +29,7 @@ MaterioUser = function(){
|
||||
href = $this.attr("href"),
|
||||
destination = href.match('/\?destination=([^,]+)');
|
||||
|
||||
destination = "/" + destination[1].replace('%23', '#');
|
||||
destination = "/" + destination[1].replace('%23', '#');
|
||||
destination = destination.replace('//', '/');
|
||||
// trace('destination', destination);
|
||||
|
||||
@@ -55,7 +55,7 @@ MaterioUser = function(){
|
||||
function formLoaded(json, destination){
|
||||
//trace('formLoaded | json', json);
|
||||
var $modal = $('<div>').addClass('modal-content').append(json.block);
|
||||
|
||||
|
||||
var id,label, description;
|
||||
$('input.form-text', $modal).each(function(i) {
|
||||
id = $(this).attr('id');
|
||||
@@ -83,11 +83,16 @@ MaterioUser = function(){
|
||||
|
||||
$("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
|
||||
event.preventDefault();
|
||||
|
||||
// disable submit button to avoid duplicate user creation
|
||||
// console.log('click', this);
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType:'json',
|
||||
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
|
||||
data: $('#user-register-form', $modal).serialize(),
|
||||
data: $('#user-register-form', $modal).serialize(),
|
||||
success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
|
||||
error: function() {trace('error');}
|
||||
});
|
||||
@@ -100,14 +105,14 @@ MaterioUser = function(){
|
||||
type: 'POST',
|
||||
dataType:'json',
|
||||
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
|
||||
data: $('#user-login', $modal).serialize(),
|
||||
data: $('#user-login', $modal).serialize(),
|
||||
success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
|
||||
error: function() { trace('error'); }
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// google analytics
|
||||
// google analytics
|
||||
// $.event.trigger({
|
||||
// type : "record-stat",
|
||||
// categorie : 'Search',
|
||||
@@ -120,12 +125,21 @@ MaterioUser = function(){
|
||||
};
|
||||
|
||||
function onUserLoginRegisterSubmit($form, data, destination){
|
||||
// console.log('data', data);
|
||||
cleanModalErrors();
|
||||
if(data.errors != null){
|
||||
for(field in data.errors){
|
||||
$('input[name='+field+']', $form).addClass('error');
|
||||
$form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
|
||||
}
|
||||
|
||||
(function($form){
|
||||
setTimeout(function(){
|
||||
console.log('enabled');
|
||||
$('input[type=submit]', $form).removeAttr('disabled');
|
||||
}, 0.5*1000);
|
||||
})($form);
|
||||
|
||||
}else{
|
||||
// trace('destination = '+destination);
|
||||
window.location.pathname = destination;
|
||||
@@ -143,5 +157,5 @@ MaterioUser = function(){
|
||||
$(document).ready(function() {
|
||||
var materiouser = new MaterioUser();
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
30
js/materio_user.min.js
vendored
30
js/materio_user.min.js
vendored
@@ -374,7 +374,7 @@ function getElementAngle(x1, y1, x2, y2) {
|
||||
(function($) {
|
||||
|
||||
MaterioUser = function(){
|
||||
|
||||
|
||||
var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
|
||||
|
||||
function init() {
|
||||
@@ -387,7 +387,7 @@ MaterioUser = function(){
|
||||
// trace('initAdhesion');
|
||||
$('.get-link a').bind('click', function(event) {
|
||||
// trace('get-link click');
|
||||
|
||||
|
||||
// do not show the registration form if already logged-in
|
||||
if($('body').is('.logged-in'))
|
||||
return true;
|
||||
@@ -399,7 +399,7 @@ MaterioUser = function(){
|
||||
href = $this.attr("href"),
|
||||
destination = href.match('/\?destination=([^,]+)');
|
||||
|
||||
destination = "/" + destination[1].replace('%23', '#');
|
||||
destination = "/" + destination[1].replace('%23', '#');
|
||||
destination = destination.replace('//', '/');
|
||||
// trace('destination', destination);
|
||||
|
||||
@@ -425,7 +425,7 @@ MaterioUser = function(){
|
||||
function formLoaded(json, destination){
|
||||
//trace('formLoaded | json', json);
|
||||
var $modal = $('<div>').addClass('modal-content').append(json.block);
|
||||
|
||||
|
||||
var id,label, description;
|
||||
$('input.form-text', $modal).each(function(i) {
|
||||
id = $(this).attr('id');
|
||||
@@ -453,11 +453,16 @@ MaterioUser = function(){
|
||||
|
||||
$("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
|
||||
event.preventDefault();
|
||||
|
||||
// disable submit button to avoid duplicate user creation
|
||||
// console.log('click', this);
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType:'json',
|
||||
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
|
||||
data: $('#user-register-form', $modal).serialize(),
|
||||
data: $('#user-register-form', $modal).serialize(),
|
||||
success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
|
||||
error: function() {trace('error');}
|
||||
});
|
||||
@@ -470,14 +475,14 @@ MaterioUser = function(){
|
||||
type: 'POST',
|
||||
dataType:'json',
|
||||
url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
|
||||
data: $('#user-login', $modal).serialize(),
|
||||
data: $('#user-login', $modal).serialize(),
|
||||
success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
|
||||
error: function() { trace('error'); }
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// google analytics
|
||||
// google analytics
|
||||
// $.event.trigger({
|
||||
// type : "record-stat",
|
||||
// categorie : 'Search',
|
||||
@@ -490,12 +495,21 @@ MaterioUser = function(){
|
||||
};
|
||||
|
||||
function onUserLoginRegisterSubmit($form, data, destination){
|
||||
// console.log('data', data);
|
||||
cleanModalErrors();
|
||||
if(data.errors != null){
|
||||
for(field in data.errors){
|
||||
$('input[name='+field+']', $form).addClass('error');
|
||||
$form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
|
||||
}
|
||||
|
||||
(function($form){
|
||||
setTimeout(function(){
|
||||
console.log('enabled');
|
||||
$('input[type=submit]', $form).removeAttr('disabled');
|
||||
}, 0.5*1000);
|
||||
})($form);
|
||||
|
||||
}else{
|
||||
// trace('destination = '+destination);
|
||||
window.location.pathname = destination;
|
||||
@@ -513,5 +527,5 @@ MaterioUser = function(){
|
||||
$(document).ready(function() {
|
||||
var materiouser = new MaterioUser();
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
Reference in New Issue
Block a user