Browse Source

Evolution #90: Ajaxsification des actions: Suivre/ne plus suivre

bastien 13 years ago
parent
commit
4108403ce9

+ 5 - 1
app/Resources/translations/users.fr.yml View File

1
 
1
 
2
 user:
2
 user:
3
   follow:                       Suivre
3
   follow:                       Suivre
4
+  following:                    Suivi
4
   notfollow:                    Ne plus suivre
5
   notfollow:                    Ne plus suivre
5
-  view_favorites:               Voir les favoris
6
+  view_favorites:               Voir les favoris
7
+  stop_follow:                  Ne plus suivre
8
+  show:
9
+    title:                      Diffusions de %name%

+ 6 - 1
src/Muzich/CoreBundle/Controller/CoreController.php View File

100
       // L'utilisateur suis déjà, on doit détruire l'entité
100
       // L'utilisateur suis déjà, on doit détruire l'entité
101
       $em->remove($Follow);
101
       $em->remove($Follow);
102
       $em->flush();
102
       $em->flush();
103
+      $following = false;
103
     }
104
     }
104
     // Sinon, c'est qu'il veut le suivre
105
     // Sinon, c'est qu'il veut le suivre
105
     else
106
     else
121
       
122
       
122
       $em->persist($Follow);
123
       $em->persist($Follow);
123
       $em->flush();
124
       $em->flush();
125
+      $following = true;
124
     }
126
     }
125
     
127
     
126
     if ($this->getRequest()->isXmlHttpRequest())
128
     if ($this->getRequest()->isXmlHttpRequest())
127
     {
129
     {
128
-      
130
+      return $this->jsonResponse(array(
131
+        'status'    => 'success',
132
+        'following' => $following
133
+      ));
129
     }
134
     }
130
     else
135
     else
131
     {
136
     {

+ 5 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

23
   <script src="{{ asset('js/formdefault/jquery.formdefaults.js') }}" type="text/javascript"></script>
23
   <script src="{{ asset('js/formdefault/jquery.formdefaults.js') }}" type="text/javascript"></script>
24
   <script src="{{ asset('js/jquery.form-2.14.js') }}" type="text/javascript"></script>
24
   <script src="{{ asset('js/jquery.form-2.14.js') }}" type="text/javascript"></script>
25
   <script src="{{ asset('js/jConfirmAction/jconfirmaction.jquery.js') }}" type="text/javascript"></script>
25
   <script src="{{ asset('js/jConfirmAction/jconfirmaction.jquery.js') }}" type="text/javascript"></script>
26
+  <script type="text/javascript">
27
+    string_follow_stop = "{{ 'user.stop_follow'|trans({}, 'users') }}";
28
+    string_follow_following = "{{ 'user.following'|trans({}, 'users') }}";
29
+    string_follow_follow = "{{ 'user.follow'|trans({}, 'users') }}";
30
+  </script>
26
   {% block js %}{% endblock %}
31
   {% block js %}{% endblock %}
27
   
32
   
28
 </head>
33
 </head>

+ 17 - 5
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

4
 
4
 
5
 {% block content %}
5
 {% block content %}
6
 
6
 
7
-  <span class="follow_link following">
7
+  <!--<span class="follow_link following">
8
     
8
     
9
     <a href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
9
     <a href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
10
       {{ 'user.view_favorites'|trans({}, 'users') }}
10
       {{ 'user.view_favorites'|trans({}, 'users') }}
11
     </a>
11
     </a>
12
     | 
12
     | 
13
+        
14
+    
15
+  </span>-->
16
+
17
+  <div class="show_options">
18
+    
19
+    <a class="button" href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
20
+      {{ 'user.view_favorites'|trans({}, 'users') }}
21
+    </a>
22
+    
13
     <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash }) }}" 
23
     <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash }) }}" 
14
-       class="follow_link {% if following %}following{% else %}notfollowing{% endif %}" >
24
+       class="follow_link button {% if following %}following{% else %}notfollowing{% endif %}" >
15
       {% if following %}
25
       {% if following %}
16
-        {{ 'user.notfollow'|trans({}, 'users') }}
26
+        {{ 'user.following'|trans({}, 'users') }}
17
       {% else %}
27
       {% else %}
18
         {{ 'user.follow'|trans({}, 'users') }}
28
         {{ 'user.follow'|trans({}, 'users') }}
19
       {% endif %}
29
       {% endif %}
20
     </a>
30
     </a>
21
     
31
     
22
-  </span>
32
+  </div>
33
+  
23
 
34
 
24
-  <h2>{{ viewed_user.name }}</h2>
35
+  <h2>{{ 'user.show.title'|trans({'%name%' : viewed_user.name}, 'users') }}</h2>
36
+  
25
   
37
   
26
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
38
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
27
     
39
     

+ 8 - 0
web/bundles/muzichcore/css/main.css View File

32
 {
32
 {
33
   margin-top: 5px;
33
   margin-top: 5px;
34
   margin-bottom: 5px;
34
   margin-bottom: 5px;
35
+  font-size: 1.7em;
35
   
36
   
36
   text-shadow: 1px 1px 2px #666;
37
   text-shadow: 1px 1px 2px #666;
37
 }
38
 }
56
 	-webkit-border-radius: 5px;
57
 	-webkit-border-radius: 5px;
57
 	-khtml-border-radius: 5px;
58
 	-khtml-border-radius: 5px;
58
 	border-radius: 5px;
59
 	border-radius: 5px;
60
+  border: 1px solid #2b82ad;
59
 }
61
 }
60
 input.button, button.button {
62
 input.button, button.button {
61
 	border: 0px none;
63
 	border: 0px none;
71
   color: #00d0de;
73
   color: #00d0de;
72
 }
74
 }
73
 
75
 
76
+#container a.button
77
+{
78
+  color: white;
79
+}
80
+
74
 #container a:hover
81
 #container a:hover
75
 {
82
 {
76
   text-decoration: underline;
83
   text-decoration: underline;
548
 	-khtml-border-radius: 5px;
555
 	-khtml-border-radius: 5px;
549
 	border-radius: 5px;
556
 	border-radius: 5px;
550
   background-color: #bdf1fe;
557
   background-color: #bdf1fe;
558
+  padding-left: 3px;
551
 }
559
 }
552
 
560
 
553
 ul.tagbox li.input
561
 ul.tagbox li.input

BIN
web/bundles/muzichcore/img/1328276321_add_small.png View File


BIN
web/bundles/muzichcore/img/1328276855_list-remove.png View File


BIN
web/bundles/muzichcore/img/1328276953_clean.png View File


BIN
web/bundles/muzichcore/img/1328277278_dialog-close.png View File


+ 37 - 1
web/bundles/muzichhome/css/home.css View File

1
 
1
 
2
+/*
3
+1328276321_add_small.png
4
+      1328276855_list-remove.png
5
+      1328276953_clean.png */
2
 
6
 
3
-#container .follow_link
7
+div.show_options
4
 {
8
 {
5
   float: right;
9
   float: right;
10
+}
11
+
12
+#container .follow_link
13
+{
14
+  text-decoration: none;
15
+  width: 110px;
16
+  text-align: center;
17
+}
18
+
19
+#container a.following
20
+{
21
+  background: -moz-linear-gradient(top, #08ec00 0%, #10d400 39%, #0a9800 100%);
22
+  background: -webkit-linear-gradient(top, #08ec00 0%, #10d400 39%, #0a9800 100%);
23
+  background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #08ec00), color-stop(0.39, #10d400), color-stop(1, #0a9800));
24
+  background: -o-linear-gradient(top, #08ec00 0%, #10d400 39%, #0a9800 100%);
25
+  background: -ms-linear-gradient(top, #08ec00 0%, #10d400 39%, #0a9800 100%);
26
+  background: linear-gradient(top, #08ec00 0%, #10d400 39%, #0a9800 100%);
27
+  
28
+  border: 1px solid #0a9800;
29
+  color: white;
30
+}
31
+
32
+#container a.following:hover
33
+{  
34
+  background: -moz-linear-gradient(top, #ff1e00 0%, #e50600 35%, #bf0a00 100%);
35
+  background: -webkit-linear-gradient(top, #ff1e00 0%, #e50600 35%, #bf0a00 100%);
36
+  background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ff1e00), color-stop(0.35, #e50600), color-stop(1, #bf0a00));
37
+  background: -o-linear-gradient(top, #ff1e00 0%, #e50600 35%, #bf0a00 100%);
38
+  background: -ms-linear-gradient(top, #ff1e00 0%, #e50600 35%, #bf0a00 100%);
39
+  background: linear-gradient(top, #ff1e00 0%, #e50600 35%, #bf0a00 100%);
40
+
41
+  border: 1px solid #bf0a00;
6
   text-decoration: none;
42
   text-decoration: none;
7
 }
43
 }
8
 
44
 

+ 37 - 0
web/bundles/muzichhome/js/home.js View File

16
      return false;
16
      return false;
17
    }); 
17
    }); 
18
    
18
    
19
+   // Bouton suivre
20
+   $('div.show_options a.following').live({
21
+    mouseenter:
22
+      function()
23
+      {
24
+        $(this).html(string_follow_stop);
25
+      },
26
+    mouseleave:
27
+      function()
28
+      {
29
+       $(this).html(string_follow_following);
30
+      }
31
+    }
32
+  );
33
+    
34
+  $('div.show_options a.follow_link').live('click', function(){
35
+    link = $(this);
36
+    $.getJSON(link.attr('href'), function(response) {
37
+       if (response.status == 'success')
38
+       {
39
+         if (response.following)
40
+         {
41
+           link.html(string_follow_following);
42
+           link.removeClass('notfollowing');
43
+           link.addClass('following');
44
+         }
45
+         else
46
+         {
47
+           link.html(string_follow_follow);
48
+           link.addClass('notfollowing');
49
+           link.removeClass('following');
50
+         }
51
+       }
52
+     });
53
+     return false;
54
+  });
55
+   
19
  });
56
  });