Преглед на файлове

Evolution #143: Commentaires sur un élément

bastien преди 12 години
родител
ревизия
d7180e934c

+ 9 - 0
app/Resources/translations/elements.fr.yml Целия файл

@@ -34,8 +34,17 @@ element:
34 34
     hideare:            Cacher les commentaires
35 35
     add_submit:         Commenter
36 36
     add_cancel:         Annuler
37
+    edit_submit:        Envoyer
38
+    edit_cancel:        Annuler
37 39
     add_error:
38 40
       min:              Le commentaire doit être de %limit% caractéres minimum
41
+      max:              Le commentaire doit être de %limit% caractéres maximum
42
+  
43
+comment:
44
+  edit:
45
+    link:               Modifier votre commentaire
46
+  remove:
47
+    link:               Supprimer votre commentaire
39 48
   
40 49
 elements:
41 50
   ajax:

+ 1 - 0
app/Resources/translations/messages.fr.yml Целия файл

@@ -1,2 +1,3 @@
1 1
 
2 2
 Username:     Nom d'utilisateur
3
+

+ 167 - 23
src/Muzich/CommentBundle/Controller/CommentController.php Целия файл

@@ -8,7 +8,7 @@ use Muzich\CoreBundle\Managers\CommentsManager;
8 8
 class CommentController extends Controller
9 9
 {
10 10
   
11
-  public function addAction($element_id)
11
+  public function addAction($element_id, $token)
12 12
   {
13 13
     if (($response = $this->mustBeConnected(true)))
14 14
     {
@@ -16,41 +16,151 @@ class CommentController extends Controller
16 16
     }
17 17
     
18 18
     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
19
-      ->findOneById($element_id)))
19
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
20 20
     {
21
-      throw $this->createNotFoundException('Not found');
21
+      return $this->jsonResponse(array(
22
+        'status' => 'error',
23
+        'errors' => array('NotFound')
24
+      ));
22 25
     }
26
+    
27
+    $length = strlen((($comment = $this->getRequest()->request->get('comment'))));
23 28
         
24 29
     // TODO: Faire un objet pour le formulaire ajout de commentaire
25
-    if (
26
-      strlen((($comment = $this->getRequest()->request->get('comment'))))
27
-      >= $this->container->getParameter('comment_add_min_length')
28
-    )
30
+    if ($length  < $this->container->getParameter('comment_add_min_length'))
29 31
     {
32
+      return $this->jsonResponse(array(
33
+        'status' => 'error',
34
+        'errors' => array($this->trans(
35
+          'element.comments.add_error.min', 
36
+          array(
37
+            '%limit%' => $this->container->getParameter('comment_add_min_length')
38
+          ), 
39
+          'elements'
40
+        )
41
+      )));
42
+    }
43
+    if ($length > $this->container->getParameter('comment_add_max_length'))
44
+    {
45
+      return $this->jsonResponse(array(
46
+        'status' => 'error',
47
+        'errors' => array($this->trans(
48
+          'element.comments.add_error.max', 
49
+          array(
50
+            '%limit%' => $this->container->getParameter('comment_add_max_length')
51
+          ), 
52
+          'elements'
53
+        )
54
+      )));
55
+    }
56
+    
30 57
       
31
-      // On met a jour les commentaires
32
-      $cm = new CommentsManager($element->getComments());
33
-      $cm->add($this->getUser(), $comment);
34
-      $element->setComments($cm->get());
35
-      
36
-      $this->getDoctrine()->getEntityManager()->persist($element);
37
-      $this->getDoctrine()->getEntityManager()->flush();
38
-      
39
-      // On récupère le html du li avec le comment pour la réponse
40
-      $html = $this->render('MuzichCommentBundle:Comment:comment.html.twig', array(
41
-        'comment'     => $cm->getLast()
42
-      ))->getContent();
43
-      
58
+    // On met a jour les commentaires
59
+    $cm = new CommentsManager($element->getComments());
60
+    $cm->add($this->getUser(), $comment);
61
+    $element->setComments($cm->get());
62
+
63
+    $this->getDoctrine()->getEntityManager()->persist($element);
64
+    $this->getDoctrine()->getEntityManager()->flush();
65
+
66
+    // On récupère le html du li avec le comment pour la réponse
67
+    $html = $this->render('MuzichCommentBundle:Comment:li.comment.html.twig', array(
68
+      'comment'     => $cm->getLast(),
69
+      'element_id'  => $element->getId()
70
+    ))->getContent();
71
+
72
+    return $this->jsonResponse(array(
73
+      'status' => 'success',
74
+      'html'   => $html
75
+    ));
76
+         
77
+  }
78
+  
79
+  public function deleteAction($element_id, $date, $token)
80
+  {
81
+    if (($response = $this->mustBeConnected(true)))
82
+    {
83
+      return $response;
84
+    }
85
+    
86
+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
87
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
88
+    {
44 89
       return $this->jsonResponse(array(
45
-        'status' => 'success',
46
-        'html'   => $html
90
+        'status' => 'error',
91
+        'errors' => array('NotFound')
47 92
       ));
93
+    }
94
+    
95
+    // On met a jour les commentaires
96
+    $cm = new CommentsManager($element->getComments());
97
+    $cm->delete($this->getUserId(), $date);
98
+    $element->setComments($cm->get());
48 99
       
100
+    $this->getDoctrine()->getEntityManager()->persist($element);
101
+    $this->getDoctrine()->getEntityManager()->flush();
102
+    
103
+    return $this->jsonResponse(array(
104
+      'status' => 'success'
105
+    ));
106
+  }
107
+  
108
+  public function editAction($element_id, $date, $token)
109
+  {
110
+    if (($response = $this->mustBeConnected(true)))
111
+    {
112
+      return $response;
113
+    }
114
+    
115
+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
116
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
117
+    {
118
+      return $this->jsonResponse(array(
119
+        'status' => 'error',
120
+        'errors' => array('NotFound')
121
+      ));
49 122
     }
50
-    else
123
+    
124
+    $cm = new CommentsManager($element->getComments());
125
+    $comment = $cm->get($cm->getIndex($this->getUserId(), $date));
126
+    
127
+    $html = $this->render('MuzichCommentBundle:Comment:edit.html.twig', array(
128
+      'comment'     => $comment,
129
+      'element_id'  => $element->getId(),
130
+      'date'        => $date
131
+    ))->getContent();
132
+    
133
+    return $this->jsonResponse(array(
134
+      'status' => 'success',
135
+      'html'   => $html
136
+    ));
137
+  }
138
+  
139
+  public function updateAction($element_id, $date, $token, $dom_id)
140
+  {
141
+    if (($response = $this->mustBeConnected(true)))
142
+    {
143
+      return $response;
144
+    }
145
+    
146
+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
147
+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token)
51 148
     {
52 149
       return $this->jsonResponse(array(
53 150
         'status' => 'error',
151
+        'errors' => array('NotFound')
152
+      ));
153
+    }
154
+        
155
+    // TODO: Faire un objet pour le formulaire ajout de commentaire
156
+    $length = strlen((($comment = $this->getRequest()->request->get('comment'))));
157
+        
158
+    // TODO: Faire un objet pour le formulaire ajout de commentaire
159
+    if ($length  < $this->container->getParameter('comment_add_min_length'))
160
+    {
161
+      return $this->jsonResponse(array(
162
+        'status' => 'error',
163
+        'dom_id' => $dom_id,
54 164
         'errors' => array($this->trans(
55 165
           'element.comments.add_error.min', 
56 166
           array(
@@ -60,6 +170,40 @@ class CommentController extends Controller
60 170
         )
61 171
       )));
62 172
     }
173
+    if ($length > $this->container->getParameter('comment_add_max_length'))
174
+    {
175
+      return $this->jsonResponse(array(
176
+        'status' => 'error',
177
+        'dom_id' => $dom_id,
178
+        'errors' => array($this->trans(
179
+          'element.comments.add_error.max', 
180
+          array(
181
+            '%limit%' => $this->container->getParameter('comment_add_max_length')
182
+          ), 
183
+          'elements'
184
+        )
185
+      )));
186
+    }
187
+      
188
+    // On met a jour les commentaires
189
+    $cm = new CommentsManager($element->getComments());
190
+    $cm->update($this->getUser(), $date, $comment);
191
+    $element->setComments($cm->get());
192
+
193
+    $this->getDoctrine()->getEntityManager()->persist($element);
194
+    $this->getDoctrine()->getEntityManager()->flush();
195
+
196
+    // On récupère le html du li avec le comment pour la réponse
197
+    $html = $this->render('MuzichCommentBundle:Comment:comment.html.twig', array(
198
+      'comment'     => $cm->get($cm->getIndex($this->getUserId(), $date)),
199
+      'element_id'  => $element->getId()
200
+    ))->getContent();
201
+
202
+    return $this->jsonResponse(array(
203
+      'status' => 'success',
204
+      'dom_id' => $dom_id,
205
+      'html'   => $html
206
+    ));
63 207
     
64 208
   }
65 209
   

+ 14 - 2
src/Muzich/CommentBundle/Resources/config/routing.yml Целия файл

@@ -1,4 +1,16 @@
1 1
 
2 2
 ajax_add_comment:
3
-  pattern: /ajax/comment/add/{element_id}
4
-  defaults: { _controller: MuzichCommentBundle:Comment:add }
3
+  pattern: /ajax/comment/add/{element_id}/{token}
4
+  defaults: { _controller: MuzichCommentBundle:Comment:add }
5
+  
6
+ajax_edit_comment:
7
+  pattern: /ajax/comment/edit/{element_id}/{date}/{token}
8
+  defaults: { _controller: MuzichCommentBundle:Comment:edit }
9
+  
10
+ajax_update_comment:
11
+  pattern: /ajax/comment/update/{element_id}/{date}/{token}/{dom_id}
12
+  defaults: { _controller: MuzichCommentBundle:Comment:update }
13
+  
14
+ajax_delete_comment:
15
+  pattern: /ajax/comment/delete/{element_id}/{date}/{token}
16
+  defaults: { _controller: MuzichCommentBundle:Comment:delete }

+ 24 - 5
src/Muzich/CommentBundle/Resources/views/Comment/comment.html.twig Целия файл

@@ -1,5 +1,24 @@
1
-<li class="comment">
2
-  <a href="{{ path('show_user', {'slug': comment.u.s}) }}" >{{ comment.u.n }}</a>: 
3
-  {{ comment.c }}
4
-  <span class="datesince">({{ comment.d|date_or_relative_date }})</span>
5
-</li>
1
+<a href="{{ path('show_user', {'slug': comment.u.s}) }}" >{{ comment.u.n }}</a>: 
2
+{{ comment.c }}
3
+<span class="datesince">({{ comment.d|date_or_relative_date }})</span>
4
+
5
+{% if app.user.id == comment.u.i %}
6
+  <a title="{{ 'comment.edit.link'|trans({}, 'elements') }}" class="comment_edit_link" 
7
+     href="{{ path('ajax_edit_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash})  }}" style="display: none;"
8
+  >
9
+    <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
10
+  </a>
11
+
12
+  <a title="{{ 'comment.remove.link'|trans({}, 'elements') }}" class="comment_remove_link" 
13
+     href="{{ path('ajax_delete_comment', {'element_id': element_id, 'date':comment.d, 'token':app.user.getPersonalHash})  }}" style="display: none;"
14
+  >
15
+    <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
16
+  </a>
17
+
18
+  <img 
19
+    class="comment_loader" 
20
+    style="display: none;" 
21
+    src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" 
22
+    alt="loading"
23
+  />
24
+{% endif %}

+ 18 - 0
src/Muzich/CommentBundle/Resources/views/Comment/edit.html.twig Целия файл

@@ -0,0 +1,18 @@
1
+<form 
2
+  id="edit_{{ comment.u.i }}_{{ comment.d|date_epurate }}"
3
+  action="{{ path('ajax_update_comment', {
4
+    'element_id':element_id, 
5
+    'date': date, 
6
+    'token':app.user.getPersonalHash,
7
+    'dom_id': comment.u.i~'_'~(comment.d|date_epurate)
8
+  }) }}" 
9
+  method="post" 
10
+  name="edit_comment"
11
+  class="edit_comment"
12
+>
13
+  {% include "MuzichCommentBundle:Comment:form.html.twig" with {
14
+    'submit_value' : 'element.comments.edit_submit'|trans({}, 'elements'),
15
+    'cancel_value' : 'element.comments.edit_cancel'|trans({}, 'elements'),
16
+    'comment_value' : comment.c
17
+  } %}
18
+</form>

+ 14 - 0
src/Muzich/CommentBundle/Resources/views/Comment/form.html.twig Целия файл

@@ -0,0 +1,14 @@
1
+<textarea name="comment">{% if comment_value is defined %}{{ comment_value }}{% endif %}</textarea>
2
+<div class="buttons">
3
+  <input 
4
+    type="submit" 
5
+    value="{{ submit_value }}" 
6
+    class="button"
7
+  />
8
+  <br />
9
+  <input 
10
+    type="button" 
11
+    value="{{ cancel_value }}" 
12
+    class="button cancel"
13
+  />
14
+</div>

+ 3 - 0
src/Muzich/CommentBundle/Resources/views/Comment/li.comment.html.twig Целия файл

@@ -0,0 +1,3 @@
1
+<li class="comment" id="{{ comment.u.i }}_{{ comment.d|date_epurate }}">
2
+  {% include "MuzichCommentBundle:Comment:comment.html.twig" %}  
3
+</li>

+ 5 - 1
src/Muzich/CoreBundle/DataFixtures/ORM/LoadElementData.php Целия файл

@@ -66,8 +66,12 @@ class LoadElementData  extends AbstractFixture implements OrderedFixtureInterfac
66 66
     $this->entity_manager->persist($element);
67 67
   }
68 68
   
69
-  protected function dateD($ecal)
69
+  protected function dateD($ecal, $micro = false)
70 70
   {
71
+    if ($micro)
72
+    {
73
+      return date('Y-m-d H:i:s u', time() - 60 * 60 *24 * $ecal);
74
+    }
71 75
     return date('Y-m-d H:i:s', time() - 60 * 60 *24 * $ecal);
72 76
   }
73 77
   

+ 10 - 1
src/Muzich/CoreBundle/Extension/MyTwigExtension.php Целия файл

@@ -17,7 +17,8 @@ class MyTwigExtension extends \Twig_Extension {
17 17
   {
18 18
     return array(
19 19
       'var_dump'               => new \Twig_Filter_Function('var_dump'),
20
-      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date')
20
+      'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
21
+      'date_epurate'            => new \Twig_Filter_Method($this, 'date_epurate')
21 22
     );
22 23
   }
23 24
   
@@ -105,5 +106,13 @@ class MyTwigExtension extends \Twig_Extension {
105 106
   {
106 107
     return 'my_twig_extension';
107 108
   }
109
+  
110
+  public function date_epurate($date)
111
+  {
112
+    $date = str_replace(' ', '', $date);
113
+    $date = str_replace('-', '', $date);
114
+    $date = str_replace(':', '', $date);
115
+    return $date;
116
+  }
108 117
 
109 118
 }

+ 52 - 1
src/Muzich/CoreBundle/Managers/CommentsManager.php Целия файл

@@ -25,7 +25,7 @@ class CommentsManager
25 25
   {
26 26
     if (!$date)
27 27
     {
28
-      $date = date('Y-m-d H:i:s');
28
+      $date = date('Y-m-d H:i:s u');
29 29
     }
30 30
     
31 31
     $this->comments[] = array(
@@ -49,6 +49,57 @@ class CommentsManager
49 49
     return $this->get(count($this->comments)-1);
50 50
   }
51 51
   
52
+  public function update($user, $date, $comment_c)
53
+  {
54
+    $comments = array();
55
+    foreach ($this->comments as $comment)
56
+    {
57
+      if ($comment['u']['i'] == $user->getId() && $comment['d'] == $date)
58
+      {
59
+        $comments[] = array(
60
+          "u" => array(
61
+            "i" => $user->getId(),
62
+            "s" => $user->getSlug(),
63
+            "n" => $user->getName()
64
+          ),
65
+          "u" => date('Y-m-d H:i:s u'),
66
+          "d" => $date,
67
+          "c" => $comment_c
68
+        );
69
+      }
70
+      else
71
+      {
72
+        $comments[] = $comment;
73
+      }
74
+    }
75
+    $this->comments = $comments;
76
+  }
77
+  
78
+  public function delete($user_id, $date)
79
+  {
80
+    $comments = array();
81
+    foreach ($this->comments as $comment)
82
+    {
83
+      if ($comment['u']['i'] != $user_id || $comment['d'] != $date)
84
+      {
85
+        $comments[] = $comment;
86
+      }
87
+    }
88
+    $this->comments = $comments;
89
+  }
90
+  
91
+  public function getIndex($user_id, $date)
92
+  {
93
+    foreach ($this->comments as $i => $comment)
94
+    {
95
+      if ($comment['u']['i'] == $user_id && $comment['d'] == $date)
96
+      {
97
+        return $i;
98
+      }
99
+    }
100
+    return null;
101
+  }
102
+  
52 103
   /**
53 104
    *
54 105
    * @return array

+ 6 - 16
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig Целия файл

@@ -150,7 +150,7 @@
150 150
     <ul class="comments">
151 151
     {% if element.comments|length %}
152 152
       {% for comment in element.comments %}
153
-        {% include "MuzichCommentBundle:Comment:comment.html.twig" %}
153
+        {% include "MuzichCommentBundle:Comment:li.comment.html.twig" with {'element_id' : element.id} %}
154 154
       {% endfor %}
155 155
     {% endif %}
156 156
     </ul>
@@ -160,26 +160,16 @@
160 160
     </div>
161 161
       
162 162
     <form 
163
-      action="{{ path('ajax_add_comment', {'element_id':element.id}) }}" 
163
+      action="{{ path('ajax_add_comment', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}" 
164 164
       method="post" 
165 165
       name="add_comment"
166 166
       style="display: none;"
167 167
       class="add_comment"
168 168
     >
169
-      <textarea name="comment"></textarea>
170
-      <div class="buttons">
171
-        <input 
172
-          type="submit" 
173
-          value="{{ 'element.comments.add_submit'|trans({}, 'elements') }}" 
174
-          class="button"
175
-        />
176
-        <br />
177
-        <input 
178
-          type="button" 
179
-          value="{{ 'element.comments.add_cancel'|trans({}, 'elements') }}" 
180
-          class="button cancel"
181
-        />
182
-      </div>
169
+      {% include "MuzichCommentBundle:Comment:form.html.twig" with {
170
+        'submit_value' : 'element.comments.add_submit'|trans({}, 'elements'),
171
+        'cancel_value' : 'element.comments.add_cancel'|trans({}, 'elements')
172
+      } %}
183 173
     </form>
184 174
       
185 175
     <a href="#add_comment_{{ element.id }}" class="add_comment">

+ 3 - 3
web/bundles/muzichcore/css/main.css Целия файл

@@ -960,19 +960,19 @@ li.comment span.datesince
960 960
   color: #868686;
961 961
 }
962 962
 
963
-div.comments form.add_comment textarea
963
+div.comments form.add_comment textarea, div.comments form.edit_comment textarea
964 964
 {
965 965
   width: 80%;
966 966
   height: 48px;
967 967
 }
968 968
 
969
-div.comments form.add_comment div.buttons
969
+div.comments form.add_comment div.buttons, div.comments form.edit_comment div.buttons
970 970
 {
971 971
   float: right;
972 972
   text-align: center;
973 973
 }
974 974
 
975
-div.comments form.add_comment div.buttons input
975
+div.comments form.add_comment div.buttons input, div.comments form.edit_comment div.buttons input
976 976
 {
977 977
   margin-top: 1px;
978 978
   margin-bottom: 1px;

+ 134 - 0
web/bundles/muzichcore/js/muzich.js Целия файл

@@ -1373,4 +1373,138 @@ $(document).ready(function(){
1373 1373
       li_element.find('form.add_comment textarea').val('');
1374 1374
     }
1375 1375
    
1376
+   // Modifier et supprimer
1377
+   // Affichage du bouton Modifier et Supprimer
1378
+    $('ul.comments li.comment').live({
1379
+      mouseenter:
1380
+        function()
1381
+        {
1382
+          $(this).find('a.comment_edit_link').show();
1383
+          $(this).find('a.comment_remove_link').show();
1384
+        },
1385
+      mouseleave:
1386
+        function()
1387
+        {
1388
+          if (!$(this).find('a.comment_edit_link').hasClass('mustBeDisplayed'))
1389
+          {
1390
+            $(this).find('a.comment_edit_link').hide();
1391
+          }
1392
+          if (!$(this).find('a.comment_remove_link').hasClass('mustBeDisplayed'))
1393
+          {
1394
+            $(this).find('a.comment_remove_link').hide();
1395
+          }
1396
+        }
1397
+      }
1398
+    );
1399
+      
1400
+    // Supprimer
1401
+    $('a.comment_remove_link').jConfirmAction({
1402
+    question : "Vraiment supprimer ?", 
1403
+    yesAnswer : "Oui", 
1404
+    cancelAnswer : "Non",
1405
+    onYes: function(link){
1406
+      
1407
+      li = link.parent('li.comment');
1408
+      li.find('img.comment_loader').show();
1409
+      
1410
+      $.getJSON(link.attr('href'), function(response){
1411
+        
1412
+        li.find('img.comment_loader').hide();
1413
+        
1414
+        if (response.status == 'mustbeconnected')
1415
+        {
1416
+          $(location).attr('href', url_index);
1417
+        }
1418
+        
1419
+        if (response.status == 'success')
1420
+        {
1421
+          li.remove();
1422
+        }
1423
+      });
1424
+
1425
+      return false;
1426
+    },
1427
+    onOpen: function(link){
1428
+      li = link.parent('li.comment');
1429
+      li.find('a.comment_edit_link').addClass('mustBeDisplayed');
1430
+      li.find('a.comment_remove_link').addClass('mustBeDisplayed');
1431
+    },
1432
+    onClose: function(link){
1433
+      li = link.parent('li.comment');
1434
+      li.find('a.comment_edit_link').removeClass('mustBeDisplayed');
1435
+      li.find('a.comment_remove_link').removeClass('mustBeDisplayed');
1436
+      li.find('a.comment_edit_link').hide();
1437
+      li.find('a.comment_remove_link').hide();
1438
+    }
1439
+  });
1440
+  
1441
+  comments_edited = new Array();
1442
+  
1443
+  // Modification
1444
+  // Ouverture du formulaire de modification
1445
+  $('a.comment_edit_link').live('click', function(){
1446
+    
1447
+    link = $(this);
1448
+    li = link.parent('li.comment');
1449
+    // On garde en mémoire l'élément édité en cas d'annulation
1450
+    comments_edited[li.attr('id')] = li.html();
1451
+    loader = li.find('img.comment_loader');
1452
+    li.html(loader);
1453
+    li.find('img.comment_loader').show();
1454
+    
1455
+    $.getJSON($(this).attr('href'), function(response) {
1456
+      
1457
+      if (response.status == 'mustbeconnected')
1458
+      {
1459
+        $(location).attr('href', url_index);
1460
+      }
1461
+      
1462
+      li.html(response.html);
1463
+      // On rend ce formulaire ajaxFormable
1464
+      $('li#'+li.attr('id')+' form.edit_comment input[type="submit"]').live('click', function(){
1465
+        li_current = $(this).parent('div').parent('form').parent('li');
1466
+        li_current.prepend(loader);
1467
+        li_current.find('img.comment_loader').show();
1468
+      });
1469
+      
1470
+      li.find('form.edit_comment').ajaxForm(function(response){
1471
+        
1472
+        li = $('li#'+response.dom_id);
1473
+        li.find('img.comment_loader').hide();
1474
+        
1475
+        if (response.status == 'mustbeconnected')
1476
+        {
1477
+          $(location).attr('href', url_index);
1478
+        }
1479
+        
1480
+        if (response.status == 'success')
1481
+        {
1482
+          li.html(response.html);
1483
+          delete(comments_edited[li.attr('id')]);
1484
+        }
1485
+        else if (response.status == 'error')
1486
+        {
1487
+          li.find('ul.error_list').remove();
1488
+          ul_errors = $('<ul>').addClass('error_list');
1489
+          
1490
+          for (i in response.errors)
1491
+          {
1492
+            ul_errors.append($('<li>').append(response.errors[i]));
1493
+          }
1494
+          
1495
+          li.prepend(ul_errors);
1496
+        }
1497
+      });
1498
+      
1499
+    });
1500
+    return false;
1501
+  });
1502
+  
1503
+  // Annulation d'un formulaire de modification d'un comment
1504
+  $('form.edit_comment input.cancel').live('click', function(){
1505
+    var li = $(this).parent('div').parent('form').parent('li');
1506
+    li.html(comments_edited[li.attr('id')]);
1507
+    delete(comments_edited[li.attr('id')]);
1508
+  });
1509
+   
1376 1510
  });