Bladeren bron

Evolution #115: Ajax sur tag et filtre

bastien 12 jaren geleden
bovenliggende
commit
a58d24c6db

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

@@ -100,7 +100,7 @@
100 100
       <ul class="element_tags">
101 101
         {% for tag in element.tags %} 
102 102
           <li class="element_tag">
103
-            {{ tag.name }}
103
+            <a href="#{{ tag.id }}" class="element_tag button">{{ tag.name }}</a>
104 104
           </li>
105 105
         {% endfor %} 
106 106
       </ul>

+ 8 - 3
web/bundles/muzichcore/css/main.css Bestand weergeven

@@ -537,9 +537,8 @@ ul.elements li.even
537 537
 
538 538
 .elements ul.element_tags
539 539
 {
540
-  margin-left: 10px;
541
-  margin-top: 0px;
542
-  margin-bottom: 0px;
540
+  margin-top: 3px;
541
+  margin-left: 0px;
543 542
 }
544 543
   
545 544
 .elements ul.element_tags li
@@ -548,6 +547,12 @@ ul.elements li.even
548 547
   font-size: 90%;
549 548
 }
550 549
 
550
+ul.element_tags .button
551
+{
552
+  padding: 2px 4px 2px 4px;
553
+  font-size: 95%;
554
+}
555
+
551 556
 
552 557
 /* FIN CSS pour elements */
553 558
 

+ 46 - 8
web/bundles/muzichcore/js/muzich.js Bestand weergeven

@@ -242,6 +242,7 @@ $(document).ready(function(){
242 242
   }
243 243
   
244 244
   // Bouton de personalisation du filtre
245
+  // Aucun tags
245 246
   $('.tags_prompt input.clear, a.filter_clear_url').live("click", function(){
246 247
     $('img.elements_more_loader').show();
247 248
     $('ul.elements').html('');
@@ -249,6 +250,8 @@ $(document).ready(function(){
249 250
     remove_tags(form.attr('name'));
250 251
     form.submit();
251 252
   });
253
+  
254
+  // tags préférés
252 255
   $('.tags_prompt input.mytags').live("click", function(){
253 256
     
254 257
     $('img.elements_more_loader').show();
@@ -280,6 +283,31 @@ $(document).ready(function(){
280 283
       
281 284
     });
282 285
   });
286
+  
287
+  // Tag cliqué dans la liste d'éléments
288
+  $('ul.element_tags li a.element_tag').live('click', function(){
289
+    // Si il y a une liste de tags (comme sur la page favoris, profil)
290
+    if ($('ul#favorite_tags').length)
291
+    {
292
+      id = str_replace('#', '', $(this).attr('href'));
293
+      link = $('ul#favorite_tags li a[href="#'+id+'"]');
294
+      list_tag_clicked(link, true);
295
+    }
296
+    
297
+    if ($('form[name="search"]').length)
298
+    {
299
+      $('img.elements_more_loader').show();
300
+      $('ul.elements').html('');
301
+      form = $('form[name="search"]');
302
+      id = str_replace('#', '', $(this).attr('href'));
303
+      remove_tags('search');
304
+      inputTag = $("div#tags_prompt_search input.form-default-value-processed");
305
+      $('input#tags_selected_tag_search').val(id);
306
+      inputTag.val($(this).html());
307
+      inputTag.trigger("selectTag");
308
+      form.submit();
309
+    }
310
+  });
283 311
 
284 312
   // Affichage un/des embed
285 313
   // 1328283150_media-playback-start.png
@@ -911,22 +939,28 @@ $(document).ready(function(){
911 939
     
912 940
     return false;
913 941
   }
914
-   
915
-  $('ul#favorite_tags a.tag').click(function(){
916
-    // Ensuite on l'active ou le désactive'
917
-    if ($(this).hasClass('active'))
942
+  
943
+  function list_tag_clicked(link, erease)
944
+  {
945
+    if (erease)
946
+    {
947
+      $('ul#favorite_tags a.tag').removeClass('active');
948
+    }
949
+    
950
+    // Ensuite on l'active ou le désactive
951
+    if (link.hasClass('active'))
918 952
     {
919
-      $(this).removeClass('active');
953
+      link.removeClass('active');
920 954
     }
921 955
     else
922 956
     {
923
-      $(this).addClass('active');
957
+      link.addClass('active');
924 958
     }
925 959
     
926 960
     // On construit notre liste de tags
927 961
     tags_ids = new Array();
928 962
     $('ul#favorite_tags a.tag.active').each(function(index){
929
-      id = str_replace('#', '', $(this).attr('href'));
963
+      id = str_replace('#', '', link.attr('href'));
930 964
       tags_ids[id] = id;
931 965
     });
932 966
     
@@ -934,7 +968,11 @@ $(document).ready(function(){
934 968
     a_more = $('a.elements_more');
935 969
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids));
936 970
     
937
-    return check_timelaps_and_find_with_tags($(this), new Date().getTime(), false);
971
+    return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
972
+  }
973
+   
974
+  $('ul#favorite_tags a.tag').click(function(){
975
+    list_tag_clicked();
938 976
   });
939 977
   
940 978
   last_keypress = 0;