Browse Source

Evolution #414: Navigation en mode non inscrit

Sevajol Bastien 12 years ago
parent
commit
46c9ba4f37

+ 20 - 4
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

2720
 
2720
 
2721
 $(document).ready(function(){
2721
 $(document).ready(function(){
2722
    
2722
    
2723
-   $('#registration_link').click(function(){
2723
+   $('#registration_link').live('click', function(){
2724
      $('#registration_box').slideDown("slow");
2724
      $('#registration_box').slideDown("slow");
2725
      $('#login_box').slideUp("slow");
2725
      $('#login_box').slideUp("slow");
2726
      $(this).hide();
2726
      $(this).hide();
2728
      return false;
2728
      return false;
2729
    });
2729
    });
2730
    
2730
    
2731
-   $('#login_link').click(function(){
2731
+   $('#login_link').live('click', function(){
2732
      $('#login_box').slideDown("slow");
2732
      $('#login_box').slideDown("slow");
2733
      $('#registration_box').slideUp("slow");
2733
      $('#registration_box').slideUp("slow");
2734
      $('#registration_link').show();
2734
      $('#registration_link').show();
2736
      return false;
2736
      return false;
2737
    });
2737
    });
2738
    
2738
    
2739
-   
2740
  });
2739
  });
2741
 
2740
 
2742
 $(document).ready(function(){
2741
 $(document).ready(function(){
2944
       if (open_login_part)
2943
       if (open_login_part)
2945
       {
2944
       {
2946
         $('div#helpbox div#login_box').show();
2945
         $('div#helpbox div#login_box').show();
2946
+        $('a#registration_link').show();
2947
       }
2947
       }
2948
       else
2948
       else
2949
       {
2949
       {
2950
         $('div#helpbox div#registration_box').show();
2950
         $('div#helpbox div#registration_box').show();
2951
+        $('a#login_link').show();
2951
       }
2952
       }
2952
       
2953
       
2953
       $('a#helpbox_close').click(function(){
2954
       $('a#helpbox_close').click(function(){
2954
         window_login_or_subscription_opened = false;
2955
         window_login_or_subscription_opened = false;
2955
       });
2956
       });
2956
       
2957
       
2958
+      $('div.login form').submit(function(){
2959
+        $(this).find('img.loader').show();
2960
+      });
2957
       $('div.login form').ajaxForm(function(response) {
2961
       $('div.login form').ajaxForm(function(response) {
2962
+        $('div.login form').find('img.loader').hide();
2958
         if (response.status == 'success')
2963
         if (response.status == 'success')
2959
         {
2964
         {
2960
           $(location).attr('href', url_home);
2965
           $(location).attr('href', url_home);
2966
         }
2971
         }
2967
       });
2972
       });
2968
       
2973
       
2974
+      $('div.register form.fos_user_registration_register').submit(function(){
2975
+        $(this).find('img.loader').show();
2976
+      });
2969
       $('div.register form.fos_user_registration_register').ajaxForm(function(response) {
2977
       $('div.register form.fos_user_registration_register').ajaxForm(function(response) {
2970
-        
2978
+        $('div.register form.fos_user_registration_register').find('img.loader').hide();
2979
+        if (response.status == 'success')
2980
+        {
2981
+          $(location).attr('href', url_home);
2982
+        }
2983
+        else if (response.status == 'error')
2984
+        {
2985
+          $('div.register form').html(response.data.html);
2986
+        }
2971
       });
2987
       });
2972
       
2988
       
2973
     });
2989
     });

+ 0 - 0
src/Muzich/CoreBundle/Security/Http/Authentication/AuthenticationFailureHandler.php View File


+ 0 - 0
src/Muzich/CoreBundle/Security/Http/Authentication/AuthenticationSuccessHandler.php View File


+ 48 - 18
src/Muzich/UserBundle/Controller/UserController.php View File

141
     if ($process)
141
     if ($process)
142
     {
142
     {
143
       $user = $form->getData();
143
       $user = $form->getData();
144
-
144
+      
145
       $authUser = false;
145
       $authUser = false;
146
       if ($confirmationEnabled) {
146
       if ($confirmationEnabled) {
147
           $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
147
           $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
150
           $authUser = true;
150
           $authUser = true;
151
           $route = 'start';
151
           $route = 'start';
152
       }
152
       }
153
-
154
-      $this->setFlash('fos_user_success', 'registration.flash.user_created');
155
-      $url = $this->container->get('router')->generate($route);
156
-      $response = new RedirectResponse($url);
157
-
153
+      
154
+      $response = $this->getSuccessRegistrationResponse();
158
       if ($authUser) {
155
       if ($authUser) {
159
-          $this->authenticateUser($user, $response);
156
+        $this->authenticateUser($user, $response);
160
       }
157
       }
161
       
158
       
162
       $formHandler->getToken()->addUseCount();
159
       $formHandler->getToken()->addUseCount();
167
       return $response;
164
       return $response;
168
     }
165
     }
169
     
166
     
170
-    return $this->container->get('templating')->renderResponse(
171
-      'MuzichIndexBundle:Index:index.html.twig',
172
-      array(
173
-        'form'                     => $form->createView(),
174
-        'error'                    => null,
175
-        'registration_errors'      => $form->getErrors(),
176
-        'registration_errors_pers' => $formHandler->getErrors(),
177
-        'last_username'            => null,
178
-        'registration_page'        => true,
179
-        'presubscription_form'     => $this->getPreSubscriptionForm()->createView()
180
-      )
167
+    return $this->getFailureRegistrationResponse($form, $formHandler);
168
+  }
169
+  
170
+  protected function getSuccessRegistrationResponse()
171
+  {
172
+    if (!$this->getRequest()->isXmlHttpRequest())
173
+    {
174
+      $url = $this->container->get('router')->generate($route);
175
+      return new RedirectResponse($url);
176
+    }
177
+    
178
+    return $this->jsonResponse(array(
179
+      'status' => 'success'
180
+    ));
181
+  }
182
+  
183
+  protected function getFailureRegistrationResponse($form, $formHandler)
184
+  {
185
+    $parameters = array(
186
+      'form'                     => $form->createView(),
187
+      'error'                    => null,
188
+      'registration_errors'      => $form->getErrors(),
189
+      'registration_errors_pers' => $formHandler->getErrors(),
190
+      'last_username'            => null,
191
+      'registration_page'        => true,
192
+      'presubscription_form'     => $this->getPreSubscriptionForm()->createView()
181
     );
193
     );
194
+    
195
+    if (!$this->getRequest()->isXmlHttpRequest())
196
+    {
197
+      return $this->render(
198
+        'MuzichIndexBundle:Index:index.html.twig',
199
+        $parameters
200
+      );
201
+    }
202
+    
203
+    return $this->jsonResponse(array(
204
+      'status' => 'error',
205
+      'data'   => array(
206
+        'html' => $this->render(
207
+          'MuzichUserBundle:Registration:register_form_content.html.twig',
208
+          $parameters
209
+        )->getContent()
210
+      )
211
+    ));
182
   }
212
   }
183
   
213
   
184
   /**
214
   /**

+ 10 - 0
src/Muzich/UserBundle/Resources/views/Account/subscribe_or_login.html.twig View File

1
+
2
+<a href="#" id="registration_link" class="button gradient" style="display: none;">
3
+  {{ 'registration.display'|trans({}, 'navigationui') }}
4
+  <img src="{{ asset('/img/icon_dart_right_white.png') }}" alt="" />
5
+</a>
6
+<a href="#" id="login_link" class="button gradient" style="display: none;">
7
+  {{ 'login.display'|trans({}, 'navigationui') }}
8
+  <img src="{{ asset('/img/icon_dart_left_white.png') }}" alt="" />
9
+</a>
10
+
1
 <div id="login_box" style="display: none;">
11
 <div id="login_box" style="display: none;">
2
   
12
   
3
   {% include "MuzichUserBundle:Security:login.html.twig" %}
13
   {% include "MuzichUserBundle:Security:login.html.twig" %}

+ 1 - 68
src/Muzich/UserBundle/Resources/views/Registration/register.html.twig View File

7
     method="POST" 
7
     method="POST" 
8
     class="fos_user_registration_register nicelabels"
8
     class="fos_user_registration_register nicelabels"
9
   >
9
   >
10
-        
11
-    {% form_theme form 'MuzichCoreBundle:Form:errors.html.twig' %}
12
     
10
     
13
-    {{ form_errors(form) }}
11
+    {% include 'MuzichUserBundle:Registration:register_form_content.html.twig' %}
14
     
12
     
15
-    {% if registration_errors_pers|length > 0 %}
16
-    <ul class="error_list">
17
-      {% for error in registration_errors_pers %}
18
-        <li>{{ error }}</li>
19
-      {% endfor %}
20
-    </ul>
21
-    {% endif %}
22
-    
23
-    <div class="field">
24
-      {{ form_errors(form.username) }}
25
-      {{ form_label(form.username, 'username'|trans({}, 'userform')) }}
26
-      {{ form_widget(form.username, {'attr':{'class':'niceinput'}}) }}
27
-    </div>   
28
-        
29
-    <div class="field">
30
-      {{ form_errors(form.email) }}
31
-      {{ form_label(form.email, 'email'|trans({}, 'userform')) }}
32
-      {{ form_widget(form.email, {'attr':{'class':'niceinput'}}) }}
33
-    </div> 
34
-    
35
-    <div class="field">
36
-      {{ form_errors(form.plainPassword.first) }}
37
-      {{ form_label(form.plainPassword.first, 'password.first'|trans({}, 'userform')) }}
38
-      {{ form_widget(form.plainPassword.first, {'attr':{'class':'niceinput'}}) }}
39
-    </div> 
40
-    
41
-    <div class="field">
42
-      {{ form_errors(form.plainPassword.second) }}
43
-      {{ form_label(form.plainPassword.second, 'password.second'|trans({}, 'userform')) }}
44
-      {{ form_widget(form.plainPassword.second, {'attr':{'class':'niceinput'}}) }}
45
-    </div> 
46
-    
47
-    <span class="help">{{ 'help.token'|trans({}, 'userform') }}</span>
48
-    
49
-    <div class="field">
50
-      {{ form_errors(form.token) }}
51
-      {{ form_label(form.token, 'token'|trans({}, 'userform')) }}
52
-      {{ form_widget(form.token, {'attr':{'class':'niceinput'}}) }}
53
-    </div>
54
-    
55
-    <div class="field">
56
-      {{ form_errors(form.cgu_accepted) }}
57
-      {{ form_widget(form.cgu_accepted, {'attr':{}}) }}
58
-      {% autoescape false %}
59
-      {{ 'cgu_accepted'|trans({'%url%':path('info_cgu')}, 'userform') }}
60
-      {% endautoescape %}
61
-    </div>
62
-    
63
-    <div class="field">
64
-      {{ form_errors(form.mail_newsletter) }}
65
-      {{ form_widget(form.mail_newsletter, {'attr':{}}) }}
66
-      {{ 'mail_newsletter'|trans({}, 'userform') }}
67
-    </div>
68
-    
69
-    <div class="field">
70
-      {{ form_errors(form.mail_partner) }}
71
-      {{ form_widget(form.mail_partner, {'attr':{}}) }}
72
-      {{ 'mail_partner'|trans({}, 'userform') }}
73
-    </div> 
74
-
75
-    {{ form_rest(form) }}
76
-    
77
-    <div class="alignright">
78
-        <input type="submit" class="button" value="{{ 'registration.submit'|trans({}, 'userui') }}" />
79
-    </div>
80
   </form>
13
   </form>
81
 </div>
14
 </div>

+ 74 - 0
src/Muzich/UserBundle/Resources/views/Registration/register_form_content.html.twig View File

1
+{% if registration_errors_pers is not defined %}
2
+  {% set registration_errors_pers = null %}
3
+{% endif %}
4
+
5
+{% form_theme form 'MuzichCoreBundle:Form:errors.html.twig' %}
6
+
7
+{{ form_errors(form) }}
8
+
9
+{% if registration_errors_pers|length > 0 %}
10
+<ul class="error_list">
11
+  {% for error in registration_errors_pers %}
12
+    <li>{{ error }}</li>
13
+  {% endfor %}
14
+</ul>
15
+{% endif %}
16
+
17
+<div class="field">
18
+  {{ form_errors(form.username) }}
19
+  {{ form_label(form.username, 'username'|trans({}, 'userform')) }}
20
+  {{ form_widget(form.username, {'attr':{'class':'niceinput'}}) }}
21
+</div>   
22
+    
23
+<div class="field">
24
+  {{ form_errors(form.email) }}
25
+  {{ form_label(form.email, 'email'|trans({}, 'userform')) }}
26
+  {{ form_widget(form.email, {'attr':{'class':'niceinput'}}) }}
27
+</div> 
28
+
29
+<div class="field">
30
+  {{ form_errors(form.plainPassword.first) }}
31
+  {{ form_label(form.plainPassword.first, 'password.first'|trans({}, 'userform')) }}
32
+  {{ form_widget(form.plainPassword.first, {'attr':{'class':'niceinput'}}) }}
33
+</div> 
34
+
35
+<div class="field">
36
+  {{ form_errors(form.plainPassword.second) }}
37
+  {{ form_label(form.plainPassword.second, 'password.second'|trans({}, 'userform')) }}
38
+  {{ form_widget(form.plainPassword.second, {'attr':{'class':'niceinput'}}) }}
39
+</div> 
40
+
41
+<span class="help">{{ 'help.token'|trans({}, 'userform') }}</span>
42
+
43
+<div class="field">
44
+  {{ form_errors(form.token) }}
45
+  {{ form_label(form.token, 'token'|trans({}, 'userform')) }}
46
+  {{ form_widget(form.token, {'attr':{'class':'niceinput'}}) }}
47
+</div>
48
+
49
+<div class="field">
50
+  {{ form_errors(form.cgu_accepted) }}
51
+  {{ form_widget(form.cgu_accepted, {'attr':{}}) }}
52
+  {% autoescape false %}
53
+  {{ 'cgu_accepted'|trans({'%url%':path('info_cgu')}, 'userform') }}
54
+  {% endautoescape %}
55
+</div>
56
+
57
+<div class="field">
58
+  {{ form_errors(form.mail_newsletter) }}
59
+  {{ form_widget(form.mail_newsletter, {'attr':{}}) }}
60
+  {{ 'mail_newsletter'|trans({}, 'userform') }}
61
+</div>
62
+
63
+<div class="field">
64
+  {{ form_errors(form.mail_partner) }}
65
+  {{ form_widget(form.mail_partner, {'attr':{}}) }}
66
+  {{ 'mail_partner'|trans({}, 'userform') }}
67
+</div> 
68
+
69
+{{ form_rest(form) }}
70
+
71
+<div class="alignright">
72
+  <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
73
+  <input type="submit" class="button" value="{{ 'registration.submit'|trans({}, 'userui') }}" />
74
+</div>

+ 2 - 0
src/Muzich/UserBundle/Resources/views/Security/login.html.twig View File

22
         placeholder="{{ 'security.login.password'|trans({}, 'userui') }}""
22
         placeholder="{{ 'security.login.password'|trans({}, 'userui') }}""
23
       />
23
       />
24
 
24
 
25
+      
26
+  <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
25
       <input type="submit" class="button" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
27
       <input type="submit" class="button" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
26
       
28
       
27
       <div class="textcenter">
29
       <div class="textcenter">