').addClass('modal-content').append(json.block);var id,label,description;$('input.form-text',$modal).each(function(i){id=$(this).attr('id');label=$('label[for='+id+']').hide().text();description=$(this).parent().find('.description').hide().text();$(this).attr('placeholder',label).attr('title',description);});$('body').append($('
').addClass('modal-wrapper').append($modal));$('.modal-wrapper').bind('click',function(event){$(this).remove();});$('.modal-content').bind('click',function(event){event.stopPropagation();});$.event.trigger('ajax-register-block-loaded');$("#user-register-form #edit-submit, #user-register-form #edit-submit--2",$modal).click(function(event){event.preventDefault();$(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(),success:function(data){onUserLoginRegisterSubmit($('#user-register-form'),data,destination);},error:function(jqXHR,textStatus,errorThrown){trace('error : '+textStatus+' | '+errorThrown);}});return false;});$("#user-login #edit-submit",$modal).click(function(event){event.preventDefault();$.ajax({type:'POST',dataType:'json',url:Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",data:$('#user-login',$modal).serialize(),success:function(data){onUserLoginRegisterSubmit($('#user-login'),data,destination);},error:function(jqXHR,textStatus,errorThrown){trace('error : '+textStatus+' | '+errorThrown);}});return false;});};function onUserLoginRegisterSubmit($form,data,destination){cleanModalErrors();if(data.errors!=null){for(field in data.errors){$('input[name='+field+']',$form).addClass('error');$form.prepend($('
').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{window.location=destination.replace('%23','#');}};function cleanModalErrors(){$('.message-error','.modal-content').remove();$('input','.modal-content').removeClass('error');}
init();};$(document).ready(function(){var materiouser=new MaterioUser();});})(jQuery);