Kaynağa Gözat

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

bastien 12 yıl önce
ebeveyn
işleme
4108403ce9

+ 5 - 1
app/Resources/translations/users.fr.yml Dosyayı Görüntüle

@@ -1,5 +1,9 @@
1 1
 
2 2
 user:
3 3
   follow:                       Suivre
4
+  following:                    Suivi
4 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 Dosyayı Görüntüle

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

+ 5 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig Dosyayı Görüntüle

@@ -23,6 +23,11 @@
23 23
   <script src="{{ asset('js/formdefault/jquery.formdefaults.js') }}" type="text/javascript"></script>
24 24
   <script src="{{ asset('js/jquery.form-2.14.js') }}" type="text/javascript"></script>
25 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 31
   {% block js %}{% endblock %}
27 32
   
28 33
 </head>

+ 17 - 5
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig Dosyayı Görüntüle

@@ -4,24 +4,36 @@
4 4
 
5 5
 {% block content %}
6 6
 
7
-  <span class="follow_link following">
7
+  <!--<span class="follow_link following">
8 8
     
9 9
     <a href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
10 10
       {{ 'user.view_favorites'|trans({}, 'users') }}
11 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 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 25
       {% if following %}
16
-        {{ 'user.notfollow'|trans({}, 'users') }}
26
+        {{ 'user.following'|trans({}, 'users') }}
17 27
       {% else %}
18 28
         {{ 'user.follow'|trans({}, 'users') }}
19 29
       {% endif %}
20 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 38
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
27 39
     

+ 8 - 0
web/bundles/muzichcore/css/main.css Dosyayı Görüntüle

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

BIN
web/bundles/muzichcore/img/1328276321_add_small.png Dosyayı Görüntüle


BIN
web/bundles/muzichcore/img/1328276855_list-remove.png Dosyayı Görüntüle


BIN
web/bundles/muzichcore/img/1328276953_clean.png Dosyayı Görüntüle


BIN
web/bundles/muzichcore/img/1328277278_dialog-close.png Dosyayı Görüntüle


+ 37 - 1
web/bundles/muzichhome/css/home.css Dosyayı Görüntüle

@@ -1,8 +1,44 @@
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 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 42
   text-decoration: none;
7 43
 }
8 44
 

+ 37 - 0
web/bundles/muzichhome/js/home.js Dosyayı Görüntüle

@@ -16,4 +16,41 @@ $(document).ready(function(){
16 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
  });