Bladeren bron

Adaptation du code javascript et dom pour compatibilité IE7,8,9

bastien 13 jaren geleden
bovenliggende
commit
4a2f33db08

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig Bestand weergeven

116
       <ul class="element_tags">
116
       <ul class="element_tags">
117
         {% for tag in element.tags %} 
117
         {% for tag in element.tags %} 
118
           <li class="element_tag">
118
           <li class="element_tag">
119
-            <a href="#{{ tag.id }}" class="element_tag button">{{ tag.name }}</a>
119
+            <a id="element_tag_{{ tag.id }}" href="#" class="element_tag button">{{ tag.name }}</a>
120
             <a 
120
             <a 
121
               href="{{ path('ajax_tag_add_to_favorites', {
121
               href="{{ path('ajax_tag_add_to_favorites', {
122
                 'tag_id' : tag.id,
122
                 'tag_id' : tag.id,

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsList.favorite.html.twig Bestand weergeven

6
   <ul id="favorite_tags">
6
   <ul id="favorite_tags">
7
     {% for tag in tags %}
7
     {% for tag in tags %}
8
       <li>
8
       <li>
9
-        <a href="#{{ tag.id }}" class="button tag">
9
+        <a id="filtering_tag_{{ tag.id }}" href="#" class="button tag">
10
           {{ tag.name }}
10
           {{ tag.name }}
11
         </a>
11
         </a>
12
       </li>
12
       </li>

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsList.show.html.twig Bestand weergeven

7
   <ul id="favorite_tags">
7
   <ul id="favorite_tags">
8
     {% for tag in tags %}
8
     {% for tag in tags %}
9
       <li>
9
       <li>
10
-        <a href="#{{ tag.id }}" class="button tag">
10
+        <a id="filtering_tag_{{ tag.id }}" href="#" class="button tag">
11
           {{ tag.name }}
11
           {{ tag.name }}
12
         </a>
12
         </a>
13
       </li>
13
       </li>

+ 114 - 124
web/bundles/muzichcore/js/muzich.js Bestand weergeven

248
     $('img.elements_more_loader').show();
248
     $('img.elements_more_loader').show();
249
     $('ul.elements').html('');
249
     $('ul.elements').html('');
250
     
250
     
251
-    form = $('form[name="search"]');
251
+    var form = $('form[name="search"]');
252
     remove_tags(form.attr('name'));
252
     remove_tags(form.attr('name'));
253
     form.submit();
253
     form.submit();
254
   });
254
   });
259
     $('img.elements_more_loader').show();
259
     $('img.elements_more_loader').show();
260
     $('ul.elements').html('');
260
     $('ul.elements').html('');
261
     
261
     
262
-    form = $(this).parent('div').parent('form');
262
+    var form = $(this).parents('form[name="search"]');
263
     
263
     
264
     $.getJSON(url_get_favorites_tags, function(response) {
264
     $.getJSON(url_get_favorites_tags, function(response) {
265
       if (response.status == 'mustbeconnected')
265
       if (response.status == 'mustbeconnected')
270
       remove_tags(form.attr('name'));
270
       remove_tags(form.attr('name'));
271
 //      if (tags.length)
271
 //      if (tags.length)
272
 //      {
272
 //      {
273
-        inputTag = $("div#tags_prompt_"+form.attr('name')+" input.form-default-value-processed");
273
+        var inputTag = $("div#tags_prompt_"+form.attr('name')+" input.form-default-value-processed");
274
         for (i in response.tags)
274
         for (i in response.tags)
275
         {
275
         {
276
           $('input#tags_selected_tag_'+form.attr('name')).val(i);
276
           $('input#tags_selected_tag_'+form.attr('name')).val(i);
289
   // Tag cliqué dans la liste d'éléments
289
   // Tag cliqué dans la liste d'éléments
290
   $('ul.element_tags li a.element_tag').live('click', function(){
290
   $('ul.element_tags li a.element_tag').live('click', function(){
291
     // Si il y a une liste de tags (comme sur la page favoris, profil)
291
     // Si il y a une liste de tags (comme sur la page favoris, profil)
292
+    var id;
292
     if ($('ul#favorite_tags').length)
293
     if ($('ul#favorite_tags').length)
293
     {
294
     {
294
-      id = str_replace('#', '', $(this).attr('href'));
295
-      link = $('ul#favorite_tags li a[href="#'+id+'"]');
295
+      id = str_replace('element_tag', '', $(this).attr('id'));
296
+      var link = $('ul#favorite_tags li a[href="#'+id+'"]');
296
       list_tag_clicked(link, true);
297
       list_tag_clicked(link, true);
297
     }
298
     }
298
     
299
     
300
     {
301
     {
301
       $('img.elements_more_loader').show();
302
       $('img.elements_more_loader').show();
302
       $('ul.elements').html('');
303
       $('ul.elements').html('');
303
-      form = $('form[name="search"]');
304
-      id = str_replace('#', '', $(this).attr('href'));
304
+      var form = $('form[name="search"]');
305
+      id = str_replace('element_tag', '', $(this).attr('id'));
305
       remove_tags('search');
306
       remove_tags('search');
306
-      inputTag = $("div#tags_prompt_search input.form-default-value-processed");
307
+      var inputTag = $("div#tags_prompt_search input.form-default-value-processed");
307
       $('input#tags_selected_tag_search').val(id);
308
       $('input#tags_selected_tag_search').val(id);
308
       inputTag.val($(this).html());
309
       inputTag.val($(this).html());
309
       inputTag.trigger("selectTag");
310
       inputTag.trigger("selectTag");
316
   // 1328283201_emblem-symbolic-link.png
317
   // 1328283201_emblem-symbolic-link.png
317
   $('a.element_embed_open_link').live("click", function(){
318
   $('a.element_embed_open_link').live("click", function(){
318
     
319
     
319
-     li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
320
+     var li = $(this).parents('li.element');
320
      
321
      
321
      li.find('a.element_embed_close_link').show();
322
      li.find('a.element_embed_close_link').show();
322
      li.find('a.element_embed_open_link_text').hide();
323
      li.find('a.element_embed_open_link_text').hide();
327
   
328
   
328
   $('a.element_name_embed_open_link').live("click", function(){
329
   $('a.element_name_embed_open_link').live("click", function(){
329
     
330
     
330
-     li = $(this).parent('span').parent('td').parent('tr').parent().parent().parent('li.element');
331
+     var li = $(this).parents('li.element');
331
      
332
      
332
      li.find('a.element_embed_close_link').show();
333
      li.find('a.element_embed_close_link').show();
333
      li.find('a.element_embed_open_link_text').hide();
334
      li.find('a.element_embed_open_link_text').hide();
339
   // Fermeture du embed si demandé
340
   // Fermeture du embed si demandé
340
   $('a.element_embed_close_link').live("click", function(){
341
   $('a.element_embed_close_link').live("click", function(){
341
     
342
     
342
-     li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
343
+     var li = $(this).parents('li.element');
343
     
344
     
344
      li.find('div.element_embed').hide();
345
      li.find('div.element_embed').hide();
345
      li.find('a.element_embed_open_link_text').show();
346
      li.find('a.element_embed_open_link_text').show();
353
     mouseenter:
354
     mouseenter:
354
       function()
355
       function()
355
       {
356
       {
356
-        td = $(this).parent('td');
357
-        a = td.find('a.a_thumbnail');
357
+        var td = $(this).parent('td');
358
+        var a = td.find('a.a_thumbnail');
358
         if (a.hasClass('embed'))
359
         if (a.hasClass('embed'))
359
         {
360
         {
360
           td.find('img.play').show();
361
           td.find('img.play').show();
367
     mouseleave:
368
     mouseleave:
368
       function()
369
       function()
369
       {
370
       {
370
-        td = $(this).parent('td');
371
-        a = td.find('a.a_thumbnail');
371
+        var td = $(this).parent('td');
372
+        var a = td.find('a.a_thumbnail');
372
         if (a.hasClass('embed'))
373
         if (a.hasClass('embed'))
373
         {
374
         {
374
           td.find('img.play').hide();
375
           td.find('img.play').hide();
383
 
384
 
384
   // Mise en favoris
385
   // Mise en favoris
385
   $('a.favorite_link').live("click", function(){
386
   $('a.favorite_link').live("click", function(){
386
-    link = $(this);
387
+    var link = $(this);
387
     
388
     
388
     // Pour ne pas attendre la fin du chargement ajax:
389
     // Pour ne pas attendre la fin du chargement ajax:
389
-    img = link.find('img');
390
+    var img = link.find('img');
390
     if (!link.hasClass('loading'))
391
     if (!link.hasClass('loading'))
391
     {
392
     {
392
       if (img.attr('src') == '/bundles/muzichcore/img/favorite_bw.png')
393
       if (img.attr('src') == '/bundles/muzichcore/img/favorite_bw.png')
407
         $(location).attr('href', url_index);
408
         $(location).attr('href', url_index);
408
       }
409
       }
409
       
410
       
410
-      img = link.find('img');
411
+      var img = link.find('img');
411
       link.attr('href', response.link_new_url);
412
       link.attr('href', response.link_new_url);
412
       img.attr('src', response.img_new_src);
413
       img.attr('src', response.img_new_src);
413
       img.attr('title', response.img_new_title);
414
       img.attr('title', response.img_new_title);
440
   );
441
   );
441
     
442
     
442
    // Plus d'éléments
443
    // Plus d'éléments
443
-   last_id = null;
444
+   var last_id = null;
444
    $('a.elements_more').click(function(){
445
    $('a.elements_more').click(function(){
445
-     link = $(this);
446
-     last_element = $('ul.elements li.element:last-child');
447
-     id_last = str_replace('element_', '', last_element.attr('id'));
448
-     invertcolor = 0;
446
+     var link = $(this);
447
+     var last_element = $('ul.elements li.element:last-child');
448
+     var id_last = str_replace('element_', '', last_element.attr('id'));
449
+     var invertcolor = 0;
449
      if (last_element.hasClass('even'))
450
      if (last_element.hasClass('even'))
450
      {
451
      {
451
        invertcolor = 1;
452
        invertcolor = 1;
519
     cancelAnswer : string_element_delete_confirm_no,
520
     cancelAnswer : string_element_delete_confirm_no,
520
     onYes: function(link){
521
     onYes: function(link){
521
       
522
       
522
-      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
523
+      var li = $(this).parents('li.element');
523
       li.find('img.element_loader').show();
524
       li.find('img.element_loader').show();
524
       $.getJSON(link.attr('href'), function(response){
525
       $.getJSON(link.attr('href'), function(response){
525
         if (response.status == 'mustbeconnected')
526
         if (response.status == 'mustbeconnected')
540
       return false;
541
       return false;
541
     },
542
     },
542
     onOpen: function(link){
543
     onOpen: function(link){
543
-      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
544
+      var li = $(this).parents('li.element');
544
       li.find('a.element_edit_link').addClass('mustBeDisplayed');
545
       li.find('a.element_edit_link').addClass('mustBeDisplayed');
545
       li.find('a.element_remove_link').addClass('mustBeDisplayed');
546
       li.find('a.element_remove_link').addClass('mustBeDisplayed');
546
     },
547
     },
547
     onClose: function(link){
548
     onClose: function(link){
548
-      li = link.parent('td').parent('tr').parent().parent().parent('li.element');
549
+      var li = $(this).parents('li.element');
549
       li.find('a.element_edit_link').removeClass('mustBeDisplayed');
550
       li.find('a.element_edit_link').removeClass('mustBeDisplayed');
550
       li.find('a.element_remove_link').removeClass('mustBeDisplayed');
551
       li.find('a.element_remove_link').removeClass('mustBeDisplayed');
551
       li.find('a.element_edit_link').hide();
552
       li.find('a.element_edit_link').hide();
553
     }
554
     }
554
   });
555
   });
555
 
556
 
556
- elements_edited = new Array();
557
+ var elements_edited = new Array();
557
  // Ouverture du formulaire de modification
558
  // Ouverture du formulaire de modification
558
   $('a.element_edit_link').live('click', function(){
559
   $('a.element_edit_link').live('click', function(){
559
     
560
     
560
-    link = $(this);
561
-    li = link.parent('td').parent('tr').parent().parent().parent('li.element');
561
+    var link = $(this);
562
+    var li = link.parents('li.element');
562
     // On garde en mémoire l'élément édité en cas d'annulation
563
     // On garde en mémoire l'élément édité en cas d'annulation
563
     elements_edited[li.attr('id')] = li.html();
564
     elements_edited[li.attr('id')] = li.html();
564
-    div_loader = li.find('div.loader');
565
+    var div_loader = li.find('div.loader');
565
     li.html(div_loader);
566
     li.html(div_loader);
566
     li.find('img.element_loader').show();
567
     li.find('img.element_loader').show();
567
     
568
     
587
       
588
       
588
       // On rend ce formulaire ajaxFormable
589
       // On rend ce formulaire ajaxFormable
589
       $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
590
       $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
590
-        li = $(this).parent('form').parent('li');
591
+        var li = $(this).parents('li.element');
591
         li.prepend(div_loader);
592
         li.prepend(div_loader);
592
         li.find('img.element_loader').show();
593
         li.find('img.element_loader').show();
593
       });
594
       });
598
           $(location).attr('href', url_index);
599
           $(location).attr('href', url_index);
599
         }
600
         }
600
         
601
         
601
-        li = $('li#'+response.dom_id);
602
+        var li = $('li#'+response.dom_id);
602
         
603
         
603
         if (response.status == 'success')
604
         if (response.status == 'success')
604
         {
605
         {
609
         {
610
         {
610
           li.find('img.element_loader').hide();
611
           li.find('img.element_loader').hide();
611
           li.find('ul.error_list').remove();
612
           li.find('ul.error_list').remove();
612
-          ul_errors = $('<ul>').addClass('error_list');
613
+          var ul_errors = $('<ul>').addClass('error_list');
613
           
614
           
614
           for (i in response.errors)
615
           for (i in response.errors)
615
           {
616
           {
626
   
627
   
627
   // Annulation d'un formulaire de modification d'élément
628
   // Annulation d'un formulaire de modification d'élément
628
   $('form.edit_element input.cancel_edit').live('click', function(){
629
   $('form.edit_element input.cancel_edit').live('click', function(){
629
-    var li = $(this).parent('form').parent('li');
630
+    var li = link.parents('li.element');
630
     li.html(elements_edited[li.attr('id')]);
631
     li.html(elements_edited[li.attr('id')]);
631
     delete(elements_edited[li.attr('id')]);
632
     delete(elements_edited[li.attr('id')]);
632
   });
633
   });
633
  
634
  
634
   ////////////////// TAG PROMPT ///////////////
635
   ////////////////// TAG PROMPT ///////////////
635
  
636
  
636
-  ajax_query_timestamp = null;
637
-  tag_text_help = $('input.tag_text_help').val();
637
+  var ajax_query_timestamp = null;
638
+  var tag_text_help = $('input.tag_text_help').val();
638
  
639
  
639
   // Les deux clicks ci-dessous permettent de faire disparaitre
640
   // Les deux clicks ci-dessous permettent de faire disparaitre
640
   // la div de tags lorsque l'on clique ailleurs
641
   // la div de tags lorsque l'on clique ailleurs
657
     {
658
     {
658
 
659
 
659
       // on met en variable l'input
660
       // on met en variable l'input
660
-      inputTag = input;
661
+      var inputTag = input;
661
       
662
       
662
       // On récupére la div de tags
663
       // On récupére la div de tags
663
-      divtags = $("#search_tag_"+form_name);
664
+      var divtags = $("#search_tag_"+form_name);
664
 
665
 
665
       // Si la fenêtre de tags est caché
666
       // Si la fenêtre de tags est caché
666
       if (!divtags.is(':visible'))
667
       if (!divtags.is(':visible'))
667
       {
668
       {
668
         // On la replace
669
         // On la replace
669
-        position = input.position();
670
+        var position = input.position();
670
         divtags.css('left', Math.round(position.left) + 5);
671
         divtags.css('left', Math.round(position.left) + 5);
671
         divtags.css('top', Math.round(position.top) + 28);
672
         divtags.css('top', Math.round(position.top) + 28);
672
         // Et on l'affiche
673
         // Et on l'affiche
675
       // On affiche le loader
676
       // On affiche le loader
676
       $('#tag_loader_'+form_name).show();
677
       $('#tag_loader_'+form_name).show();
677
       // On cache la liste de tags
678
       // On cache la liste de tags
678
-      search_tag_list = divtags.find('ul.search_tag_list');
679
+      var search_tag_list = divtags.find('ul.search_tag_list');
679
       // On supprime les anciens li
680
       // On supprime les anciens li
680
       search_tag_list.find('li').remove();
681
       search_tag_list.find('li').remove();
681
       search_tag_list.hide();
682
       search_tag_list.hide();
682
       // Et on affiche une info
683
       // Et on affiche une info
683
-      span_info = divtags.find('span.info');
684
+      var span_info = divtags.find('span.info');
684
       span_info.show();
685
       span_info.show();
685
       // TODO: multilingue !
686
       // TODO: multilingue !
686
       span_info.text("Recherche des tags correspondants à \""+input.val()+"\" ...");
687
       span_info.text("Recherche des tags correspondants à \""+input.val()+"\" ...");
690
 
691
 
691
       // On récupère le timestamp pour reconnaitre la dernière requête effectué
692
       // On récupère le timestamp pour reconnaitre la dernière requête effectué
692
       ajax_query_timestamp = new Date().getTime();
693
       ajax_query_timestamp = new Date().getTime();
693
-
694
+      
694
       // Récupération des tags correspondants
695
       // Récupération des tags correspondants
695
       $.getJSON(url_search_tag+'/'+input.val()+'/'+ajax_query_timestamp, function(data) {
696
       $.getJSON(url_search_tag+'/'+input.val()+'/'+ajax_query_timestamp, function(data) {
696
         if (data.status == 'mustbeconnected')
697
         if (data.status == 'mustbeconnected')
702
         // ajax a été faite depuis.
703
         // ajax a été faite depuis.
703
         if (data.timestamp == ajax_query_timestamp)
704
         if (data.timestamp == ajax_query_timestamp)
704
         {
705
         {
705
-          status = data.status;
706
-          tags   = data.data;
706
+          var status = data.status;
707
+          var tags   = data.data;
707
 
708
 
708
           // Si on spécifie une erreur
709
           // Si on spécifie une erreur
709
           if (status == 'error')
710
           if (status == 'error')
716
           {
717
           {
717
             if (tags.length > 0)
718
             if (tags.length > 0)
718
             {
719
             {
719
-              more = false;
720
+              var more = false;
720
               // Pour chaque tags retournés
721
               // Pour chaque tags retournés
721
               for (i in tags)
722
               for (i in tags)
722
               {
723
               {
725
                 var t_string = tag_name
726
                 var t_string = tag_name
726
                 // On construit un li
727
                 // On construit un li
727
                 
728
                 
728
-                r_string = $.trim(input.val());
729
+                var r_string = $.trim(input.val());
729
                 var re = new RegExp(r_string, "i");
730
                 var re = new RegExp(r_string, "i");
730
                 t_string = t_string.replace(re,"<strong>" + r_string + "</strong>");
731
                 t_string = t_string.replace(re,"<strong>" + r_string + "</strong>");
731
                 
732
                 
732
                                 
733
                                 
733
-                li_tag = 
734
+                var li_tag = 
734
                   $('<li>').append(
735
                   $('<li>').append(
735
-                    $('<a>').attr('href','#'+tag_id+'#'+tag_name)
736
+                    $('<a>').attr('id','searched_tag_'+tag_id+'_'+tag_name)
737
+                      .attr('href', '#')
736
                     // qui réagit quand on clique dessus
738
                     // qui réagit quand on clique dessus
737
                     .click(function(e){
739
                     .click(function(e){
738
                       // On récupère le nom du tag
740
                       // On récupère le nom du tag
739
-                      name = $(this).attr('href').substr(1,$(this).attr('href').length);
740
-                      name = name.substr(strpos(name, '#')+1, name.length);
741
-                                            
742
-                      id = $(this).attr('href').substr(1,$(this).attr('href').length);
741
+                      var name = $(this).attr('id').substr(13,$(this).attr('id').length);
742
+                      name = name.substr(strpos(name, '_')+1, name.length);
743
+                      
744
+                      var id = $(this).attr('id').substr(13,$(this).attr('id').length);
743
                       id = str_replace(name, '', id);
745
                       id = str_replace(name, '', id);
744
-                      id = str_replace('#', '', id);
745
-                                     
746
+                      id = str_replace('_', '', id);
747
+                      
746
                       $('input#tags_selected_tag_'+form_name).val(id);
748
                       $('input#tags_selected_tag_'+form_name).val(id);
747
                       inputTag.val(name);
749
                       inputTag.val(name);
748
                       // Et on execute l'évènement selectTag de l'input
750
                       // Et on execute l'évènement selectTag de l'input
793
             if (!data.same_found)
795
             if (!data.same_found)
794
             {
796
             {
795
               // Cette variable nous permettra de stocker le lien nouveau tag
797
               // Cette variable nous permettra de stocker le lien nouveau tag
796
-              link_add_tag = null;
798
+              var link_add_tag = null;
797
               
799
               
798
               li_tag = 
800
               li_tag = 
799
                 $('<li>').addClass('new').append(
801
                 $('<li>').addClass('new').append(
810
                     link_add_tag = $(this);
812
                     link_add_tag = $(this);
811
                     
813
                     
812
                     // En premier lieux on fait apparaître la fenêtre de confirmation
814
                     // En premier lieux on fait apparaître la fenêtre de confirmation
813
-                    popup = $('<div>')
815
+                    var popup = $('<div>')
814
                     .attr('id', 'add_tag')
816
                     .attr('id', 'add_tag')
815
                     .addClass('popin_block')
817
                     .addClass('popin_block')
816
                     .css('width', '400px')
818
                     .css('width', '400px')
846
                             $('#add_tag').remove();
848
                             $('#add_tag').remove();
847
                             
849
                             
848
                             // On récupère le nom du tag
850
                             // On récupère le nom du tag
849
-                            name = link_add_tag.attr('href').substr(1,link_add_tag.attr('href').length);
851
+                            var name = link_add_tag.attr('href').substr(1,link_add_tag.attr('href').length);
850
                             name = name.substr(strpos(name, '#')+1, name.length);
852
                             name = name.substr(strpos(name, '#')+1, name.length);
851
 
853
 
852
-                            link_add_tag.parent('li').parent('ul').parent('div').find('img.tag_loader').show();
854
+                            link_add_tag.parents('div.search_tag_list').find('img.tag_loader').show();
853
 
855
 
854
                             var url;
856
                             var url;
855
                             if (arguments)
857
                             if (arguments)
869
                                 $(location).attr('href', url_index);
871
                                 $(location).attr('href', url_index);
870
                               }
872
                               }
871
 
873
 
872
-                              tag_id   = response.tag_id;
873
-                              tag_name = response.tag_name;
874
+                              var tag_id   = response.tag_id;
875
+                              var tag_name = response.tag_name;
874
 
876
 
875
                               $('input#tags_selected_tag_'+form_name).val(tag_id);
877
                               $('input#tags_selected_tag_'+form_name).val(tag_id);
876
                               inputTag.val(tag_name);
878
                               inputTag.val(tag_name);
880
                               divtags.hide();
882
                               divtags.hide();
881
                               inputTag.val(tag_text_help); 
883
                               inputTag.val(tag_text_help); 
882
 
884
 
883
-                              link_add_tag.parent('li').parent('ul').parent('div').find('img.tag_loader').hide();
885
+                              link_add_tag.parents('div.search_tag_list').find('img.tag_loader').hide();
884
                             });
886
                             });
885
                             
887
                             
886
                             return false;
888
                             return false;
922
   }
924
   }
923
  
925
  
924
  
926
  
925
-  last_keypress = 0;
927
+  var last_keypress = 0;
926
   
928
   
927
   function check_timelaps_and_search(input, form_name, time_id, timed, info)
929
   function check_timelaps_and_search(input, form_name, time_id, timed, info)
928
   {
930
   {
965
   // Autocompletion de tags
967
   // Autocompletion de tags
966
   $("div.tags_prompt ul.tagbox li.input input").live('keypress', function(e){
968
   $("div.tags_prompt ul.tagbox li.input input").live('keypress', function(e){
967
     
969
     
968
-    var form_name = $(this).parent('li').parent('ul.tagbox')
969
-      .parent('div.tags_prompt').parent('form').attr('name')
970
-    ;
970
+    var form_name = $(this).parents('form').attr('name');
971
     var code = (e.keyCode ? e.keyCode : e.which);
971
     var code = (e.keyCode ? e.keyCode : e.which);
972
 
972
 
973
     if ((e.which !== 0 && e.charCode !== 0) || (code == 8 || code == 46))
973
     if ((e.which !== 0 && e.charCode !== 0) || (code == 8 || code == 46))
1006
   
1006
   
1007
   // Selection Réseau global / Mon réseau
1007
   // Selection Réseau global / Mon réseau
1008
   $('div.select_network a').live('click', function(){
1008
   $('div.select_network a').live('click', function(){
1009
-    divSelect = $(this).parent('div');
1009
+    var divSelect = $(this).parent('div');
1010
     if ($(this).hasClass('all_network'))
1010
     if ($(this).hasClass('all_network'))
1011
     {
1011
     {
1012
       divSelect.find('a.all_network').addClass('active');
1012
       divSelect.find('a.all_network').addClass('active');
1075
     else if (response.status == 'error')
1075
     else if (response.status == 'error')
1076
     {
1076
     {
1077
       $('form[name="add"]').find('ul.error_list').remove();
1077
       $('form[name="add"]').find('ul.error_list').remove();
1078
-      ul_errors = $('<ul>').addClass('error_list');
1078
+      var ul_errors = $('<ul>').addClass('error_list');
1079
       
1079
       
1080
       for (i in response.errors)
1080
       for (i in response.errors)
1081
       {
1081
       {
1092
   // TODO.
1092
   // TODO.
1093
 
1093
 
1094
  /////////////////////
1094
  /////////////////////
1095
+ var tags_ids_for_filter = new Array();
1095
  // Filtre par tags (show, favorite)
1096
  // Filtre par tags (show, favorite)
1096
  function refresh_elements_with_tags_selected(link)
1097
  function refresh_elements_with_tags_selected(link)
1097
   {
1098
   {
1101
     $('ul.elements').html('');
1102
     $('ul.elements').html('');
1102
     $('div.no_elements').hide();
1103
     $('div.no_elements').hide();
1103
     $('img.elements_more_loader').show();
1104
     $('img.elements_more_loader').show();
1104
-    $.getJSON($('input#get_elements_url').val()+'/'+array2json(tags_ids), function(response){
1105
+    $.getJSON($('input#get_elements_url').val()+'/'+array2json(tags_ids_for_filter), function(response){
1105
       
1106
       
1106
       if (response.status == 'mustbeconnected')
1107
       if (response.status == 'mustbeconnected')
1107
       {
1108
       {
1139
     }
1140
     }
1140
     
1141
     
1141
     // On construit notre liste de tags
1142
     // On construit notre liste de tags
1142
-    tags_ids = new Array();
1143
+    tags_ids_for_filter = new Array();
1143
     $('ul#favorite_tags a.tag.active').each(function(index){
1144
     $('ul#favorite_tags a.tag.active').each(function(index){
1144
-      id = str_replace('#', '', $(this).attr('href'));
1145
-      tags_ids[id] = id;
1145
+      var id = str_replace('filtering_tag_', '', $(this).attr('id'));
1146
+      tags_ids_for_filter[id] = id;
1146
     });
1147
     });
1147
     
1148
     
1148
     // On adapte le lien afficher plus de résultats
1149
     // On adapte le lien afficher plus de résultats
1149
-    a_more = $('a.elements_more');
1150
-    a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids));
1150
+    var a_more = $('a.elements_more');
1151
+    a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1151
     
1152
     
1152
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1153
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1153
   }
1154
   }
1200
   ////////////////////////////////////////
1201
   ////////////////////////////////////////
1201
   /// Gestion de nouveaux éléments
1202
   /// Gestion de nouveaux éléments
1202
   
1203
   
1203
-  do_check_new_elements = false;
1204
+  var do_check_new_elements = false;
1204
   
1205
   
1205
   function check_new_elements()
1206
   function check_new_elements()
1206
   {
1207
   {
1220
           +str_replace('element_', '', $('ul.elements li:first').attr('id'))
1221
           +str_replace('element_', '', $('ul.elements li:first').attr('id'))
1221
         ;
1222
         ;
1222
         $.getJSON(url, function(response){
1223
         $.getJSON(url, function(response){
1223
-
1224
+          
1224
           if (response.status == 'mustbeconnected')
1225
           if (response.status == 'mustbeconnected')
1225
           {
1226
           {
1226
             $(location).attr('href', url_index);
1227
             $(location).attr('href', url_index);
1313
   
1314
   
1314
   // Afficher les commentaires
1315
   // Afficher les commentaires
1315
     $('td.element_content a.display_comments').live('click', function(){
1316
     $('td.element_content a.display_comments').live('click', function(){
1316
-      display_comments(
1317
-        $('li#element_'+
1318
-          str_replace('#comments_', '', $(this).attr('href'))
1319
-        )
1320
-      );
1317
+      display_comments($(this).parents('li.element'));
1321
     });
1318
     });
1322
     
1319
     
1323
     $('td.element_content a.hide_comments').live('click', function(){
1320
     $('td.element_content a.hide_comments').live('click', function(){
1324
-      hide_comments(
1325
-        $('li#element_'+
1326
-          str_replace('#hide_comments_', '', $(this).attr('href'))
1327
-        )
1328
-      );
1321
+      hide_comments($(this).parents('li.element'));
1329
     });
1322
     });
1330
   
1323
   
1331
     function display_comments(li_element)
1324
     function display_comments(li_element)
1344
     
1337
     
1345
   // Ajouter un commentaire
1338
   // Ajouter un commentaire
1346
     $('li.element a.add_comment').live('click', function(){
1339
     $('li.element a.add_comment').live('click', function(){
1347
-      display_add_comment($('li#element_'+
1348
-        str_replace('#add_comment_', '', $(this).attr('href'))
1349
-      ));
1340
+      display_add_comment($(this).parents('li.element'));
1350
     });
1341
     });
1351
     
1342
     
1352
     $('form.add_comment input[type="submit"]').live('click', function(){
1343
     $('form.add_comment input[type="submit"]').live('click', function(){
1353
-      $(this).parent('div').parent('form').parent('div.comments').find('img.comments_loader').show();
1344
+      $(this).parents('div.comments').find('img.comments_loader').show();
1354
     });
1345
     });
1355
         
1346
         
1356
     function display_add_comment(li_element)
1347
     function display_add_comment(li_element)
1376
         else if (response.status == 'error')
1367
         else if (response.status == 'error')
1377
         {
1368
         {
1378
           li_element.find('form.add_comment').find('ul.error_list').remove();
1369
           li_element.find('form.add_comment').find('ul.error_list').remove();
1379
-          ul_errors = $('<ul>').addClass('error_list');
1370
+          var ul_errors = $('<ul>').addClass('error_list');
1380
 
1371
 
1381
           for (i in response.errors)
1372
           for (i in response.errors)
1382
           {
1373
           {
1392
     }
1383
     }
1393
     
1384
     
1394
     $('form.add_comment input.cancel').live('click', function(){
1385
     $('form.add_comment input.cancel').live('click', function(){
1395
-      li_element = $(this).parent('div').parent('form').parent('div.comments').parent('li.element');
1386
+      var li_element = $(this).parents('li.element');
1396
       hide_add_comment(li_element);
1387
       hide_add_comment(li_element);
1397
     });
1388
     });
1398
     
1389
     
1434
     cancelAnswer : string_comment_delete_confirm_no,
1425
     cancelAnswer : string_comment_delete_confirm_no,
1435
     onYes: function(link){
1426
     onYes: function(link){
1436
       
1427
       
1437
-      li = link.parent('li.comment');
1428
+      var li = link.parents('li.comment');
1438
       li.find('img.comment_loader').show();
1429
       li.find('img.comment_loader').show();
1439
       
1430
       
1440
       $.getJSON(link.attr('href'), function(response){
1431
       $.getJSON(link.attr('href'), function(response){
1455
       return false;
1446
       return false;
1456
     },
1447
     },
1457
     onOpen: function(link){
1448
     onOpen: function(link){
1458
-      li = link.parent('li.comment');
1449
+      var li = link.parents('li.comment');
1459
       li.find('a.comment_edit_link').addClass('mustBeDisplayed');
1450
       li.find('a.comment_edit_link').addClass('mustBeDisplayed');
1460
       li.find('a.comment_remove_link').addClass('mustBeDisplayed');
1451
       li.find('a.comment_remove_link').addClass('mustBeDisplayed');
1461
     },
1452
     },
1462
     onClose: function(link){
1453
     onClose: function(link){
1463
-      li = link.parent('li.comment');
1454
+      var li = link.parents('li.comment');
1464
       li.find('a.comment_edit_link').removeClass('mustBeDisplayed');
1455
       li.find('a.comment_edit_link').removeClass('mustBeDisplayed');
1465
       li.find('a.comment_remove_link').removeClass('mustBeDisplayed');
1456
       li.find('a.comment_remove_link').removeClass('mustBeDisplayed');
1466
       li.find('a.comment_edit_link').hide();
1457
       li.find('a.comment_edit_link').hide();
1468
     }
1459
     }
1469
   });
1460
   });
1470
   
1461
   
1471
-  comments_edited = new Array();
1462
+  var comments_edited = new Array();
1472
   
1463
   
1473
   // Modification
1464
   // Modification
1474
   // Ouverture du formulaire de modification
1465
   // Ouverture du formulaire de modification
1475
   $('a.comment_edit_link').live('click', function(){
1466
   $('a.comment_edit_link').live('click', function(){
1476
     
1467
     
1477
-    link = $(this);
1478
-    li = link.parent('li.comment');
1468
+    var link = $(this);
1469
+    var li = link.parents('li.comment');
1479
     // On garde en mémoire l'élément édité en cas d'annulation
1470
     // On garde en mémoire l'élément édité en cas d'annulation
1480
     comments_edited[li.attr('id')] = li.html();
1471
     comments_edited[li.attr('id')] = li.html();
1481
-    loader = li.find('img.comment_loader');
1472
+    var loader = li.find('img.comment_loader');
1482
     li.html(loader);
1473
     li.html(loader);
1483
     li.find('img.comment_loader').show();
1474
     li.find('img.comment_loader').show();
1484
     
1475
     
1492
       li.html(response.html);
1483
       li.html(response.html);
1493
       // On rend ce formulaire ajaxFormable
1484
       // On rend ce formulaire ajaxFormable
1494
       $('li#'+li.attr('id')+' form.edit_comment input[type="submit"]').live('click', function(){
1485
       $('li#'+li.attr('id')+' form.edit_comment input[type="submit"]').live('click', function(){
1495
-        li_current = $(this).parent('div').parent('form').parent('li');
1486
+        var li_current = $(this).parents('li.comment');
1496
         li_current.prepend(loader);
1487
         li_current.prepend(loader);
1497
         li_current.find('img.comment_loader').show();
1488
         li_current.find('img.comment_loader').show();
1498
       });
1489
       });
1515
         else if (response.status == 'error')
1506
         else if (response.status == 'error')
1516
         {
1507
         {
1517
           li.find('ul.error_list').remove();
1508
           li.find('ul.error_list').remove();
1518
-          ul_errors = $('<ul>').addClass('error_list');
1509
+          var ul_errors = $('<ul>').addClass('error_list');
1519
           
1510
           
1520
           for (i in response.errors)
1511
           for (i in response.errors)
1521
           {
1512
           {
1532
   
1523
   
1533
   // Annulation d'un formulaire de modification d'un comment
1524
   // Annulation d'un formulaire de modification d'un comment
1534
   $('form.edit_comment input.cancel').live('click', function(){
1525
   $('form.edit_comment input.cancel').live('click', function(){
1535
-    var li = $(this).parent('div').parent('form').parent('li');
1526
+    var li = $(this).parents('li.comment');
1536
     li.html(comments_edited[li.attr('id')]);
1527
     li.html(comments_edited[li.attr('id')]);
1537
     delete(comments_edited[li.attr('id')]);
1528
     delete(comments_edited[li.attr('id')]);
1538
   });
1529
   });
1578
       return false;
1569
       return false;
1579
     },
1570
     },
1580
     onOpen: function(link){
1571
     onOpen: function(link){
1581
-      li = link.parent('li.element_tag');
1572
+      var li = link.parents('li.element_tag');
1582
       li.find('a.tag_to_favorites').addClass('mustBeDisplayed');
1573
       li.find('a.tag_to_favorites').addClass('mustBeDisplayed');
1583
     },
1574
     },
1584
     onClose: function(link){
1575
     onClose: function(link){
1585
-      li = link.parent('li.element_tag');
1576
+      var li = link.parents('li.element_tag');
1586
       li.find('a.tag_to_favorites').removeClass('mustBeDisplayed');
1577
       li.find('a.tag_to_favorites').removeClass('mustBeDisplayed');
1587
       li.find('a.element_tag').removeClass('element_tag_large_for_fav');
1578
       li.find('a.element_tag').removeClass('element_tag_large_for_fav');
1588
       li.find('a.tag_to_favorites').hide();
1579
       li.find('a.tag_to_favorites').hide();
1595
   
1586
   
1596
   $('a.added_element_add_to_group').live('click', function(){
1587
   $('a.added_element_add_to_group').live('click', function(){
1597
     
1588
     
1598
-    div = $(this).parent('li').parent('ul').parent('div');
1599
-    div.find('img.loader').show();
1589
+    var loader = $('div#added_element_to_group').find('img.loader');
1590
+    loader.show();
1600
     
1591
     
1601
     $.getJSON($(this).attr('href'), function(response) {
1592
     $.getJSON($(this).attr('href'), function(response) {
1602
       
1593
       
1603
-      div.find('img.loader').hide();
1594
+      loader.hide();
1604
     
1595
     
1605
       if (response.status == 'mustbeconnected')
1596
       if (response.status == 'mustbeconnected')
1606
       {
1597
       {
1660
   
1651
   
1661
   $('li.element a.vote').live('click', function(){
1652
   $('li.element a.vote').live('click', function(){
1662
     
1653
     
1663
-    img = $(this).find('img');
1664
-    link = $(this);
1654
+    var img = $(this).find('img');
1655
+    var link = $(this);
1665
     img.attr('src', url_img_ajax_loader);
1656
     img.attr('src', url_img_ajax_loader);
1666
     
1657
     
1667
     $.getJSON(link.attr('href'), function(response){
1658
     $.getJSON(link.attr('href'), function(response){
1675
       {
1666
       {
1676
         link.attr('href', response.data.a.href);
1667
         link.attr('href', response.data.a.href);
1677
         img.attr('src', response.data.img.src);
1668
         img.attr('src', response.data.img.src);
1678
-        link.parent('li').parent('ul').find('li.score span.score').html(response.data.element.points);
1669
+        link.parents('td.right').find('li.score span.score').html(response.data.element.points);
1679
       }
1670
       }
1680
       
1671
       
1681
     });
1672
     });
1689
     
1680
     
1690
     $('img.elements_more_loader').show();
1681
     $('img.elements_more_loader').show();
1691
     $('ul.elements').html('');
1682
     $('ul.elements').html('');
1692
-    link = $(this);
1683
+    var link = $(this);
1693
     
1684
     
1694
     $.getJSON(link.attr('href'), function(response){
1685
     $.getJSON(link.attr('href'), function(response){
1695
         
1686
         
1720
  // Ouverture du formulaire de modification
1711
  // Ouverture du formulaire de modification
1721
   $('a.element_propose_tags').live('click', function(){
1712
   $('a.element_propose_tags').live('click', function(){
1722
     
1713
     
1723
-    link = $(this);
1724
-    li = link.parent('td').parent('tr').parent().parent().parent('li.element');
1714
+    var link = $(this);
1715
+    var li = link.parents('li.element');
1725
     
1716
     
1726
     li.find('img.element_loader').show();
1717
     li.find('img.element_loader').show();
1727
     
1718
     
1738
       {
1729
       {
1739
         
1730
         
1740
         // On prépare le tagBox
1731
         // On prépare le tagBox
1741
-        table = li.find('table:first');
1732
+        var table = li.find('table:first');
1742
         li.find('div.tag_proposition').remove();
1733
         li.find('div.tag_proposition').remove();
1743
         table.after(response.html);
1734
         table.after(response.html);
1744
 
1735
 
1755
       
1746
       
1756
       // On rend ce formulaire ajaxFormable
1747
       // On rend ce formulaire ajaxFormable
1757
       $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
1748
       $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
1758
-        li = $(this).parent('form').parent('div').parent('li');
1749
+        li = $(this).parents('li.element');
1759
         li.find('img.element_loader').show();
1750
         li.find('img.element_loader').show();
1760
       });
1751
       });
1761
       $('form[name="'+response.form_name+'"]').ajaxForm(function(response){
1752
       $('form[name="'+response.form_name+'"]').ajaxForm(function(response){
1776
         {
1767
         {
1777
           li.find('img.element_loader').hide();
1768
           li.find('img.element_loader').hide();
1778
           li.find('ul.error_list').remove();
1769
           li.find('ul.error_list').remove();
1779
-          ul_errors = $('<ul>').addClass('error_list');
1770
+          var ul_errors = $('<ul>').addClass('error_list');
1780
           
1771
           
1781
           for (i in response.errors)
1772
           for (i in response.errors)
1782
           {
1773
           {
1795
   
1786
   
1796
   // Annulation d'un formulaire de modification d'élément
1787
   // Annulation d'un formulaire de modification d'élément
1797
   $('div.tag_proposition input.cancel').live('click', function(){
1788
   $('div.tag_proposition input.cancel').live('click', function(){
1798
-    $(this).parent('form').parent('div').slideUp();
1789
+    $(this).parents('div.tag_proposition').slideUp();
1799
   });
1790
   });
1800
   
1791
   
1801
   $('a.element_view_propositions_link').live('click', function(){
1792
   $('a.element_view_propositions_link').live('click', function(){
1802
     
1793
     
1803
-    link = $(this);
1804
-    li = link.parent('td').parent('tr').parent().parent().parent('li.element');
1794
+    var link = $(this);
1795
+    li = link.parents('li.element');
1805
     
1796
     
1806
     li.find('img.element_loader').show();
1797
     li.find('img.element_loader').show();
1807
     
1798
     
1816
       
1807
       
1817
       if (response.status == 'success')
1808
       if (response.status == 'success')
1818
       {
1809
       {
1819
-        table = li.find('table:first');
1810
+        var table = li.find('table:first');
1820
         li.find('div.tags_proposition_view').remove();
1811
         li.find('div.tags_proposition_view').remove();
1821
         table.after(response.html);
1812
         table.after(response.html);
1822
       }
1813
       }
1827
   
1818
   
1828
   $('a.accept_tag_propotision').live('click', function(){
1819
   $('a.accept_tag_propotision').live('click', function(){
1829
     
1820
     
1830
-    link = $(this);
1831
-    li = link.parent('li.tag_proposition').parent('ul.tag_propositions')
1832
-      .parent('div.tags_proposition_view').parent('li.element');
1821
+    var link = $(this);
1822
+    var li = link.parents('li.element');
1833
     
1823
     
1834
     li.find('img.element_loader').show();
1824
     li.find('img.element_loader').show();
1835
     
1825
     
1854
   //
1844
   //
1855
   $('a.refuse_tag_propositions').live('click', function(){
1845
   $('a.refuse_tag_propositions').live('click', function(){
1856
     
1846
     
1857
-    link = $(this);
1858
-    li = link.parent('div.tags_proposition_view').parent('li.element');
1847
+    var link = $(this);
1848
+    var li = link.parents('li.element');
1859
     
1849
     
1860
     li.find('img.element_loader').show();
1850
     li.find('img.element_loader').show();
1861
     
1851