Parcourir la source

Remise en fo,ction de "afficher plus de tags" dans la recherche de tags.

bastien il y a 13 ans
Parent
révision
811bb80750

+ 14 - 7
src/Muzich/CoreBundle/Controller/SearchController.php Voir le fichier

@@ -236,6 +236,7 @@ class SearchController extends Controller
236 236
    */
237 237
   private function sort_search_tags($tags, $search)
238 238
   {
239
+    $same_found = false;
239 240
     $canonicalizer = new StrictCanonicalizer();
240 241
     $tag_sorted = array();
241 242
     
@@ -273,6 +274,7 @@ class SearchController extends Controller
273 274
         {
274 275
           if (strtoupper($canonicalizer->canonicalize($word)) == strtoupper($tag['slug']))
275 276
           {
277
+            $same_found = true;
276 278
             $tag_sorted = $this->sort_addtop_if_isnt_in($tag_sorted, $tag);
277 279
           }
278 280
         }
@@ -284,7 +286,10 @@ class SearchController extends Controller
284 286
       $tag_sorted = $this->sort_addbottom_if_isnt_in($tag_sorted, $tag);
285 287
     }
286 288
     
287
-    return $tag_sorted;
289
+    return array(
290
+      'tags'       => $tag_sorted,
291
+      'same_found' => $same_found
292
+    );
288 293
   }
289 294
   
290 295
   /**
@@ -353,22 +358,24 @@ class SearchController extends Controller
353 358
           );
354 359
         }
355 360
         
356
-        $tags_response = $this->sort_search_tags($tags_response, $string_search);
361
+        $sort_response = $this->sort_search_tags($tags_response, $string_search);
357 362
         $status = 'success';
358 363
         $error  = '';
359 364
       }
360 365
       else
361 366
       {
362 367
         $status = 'error';
363
-        $tags_response = array();
368
+        $sort_response = array('tags' => array(), 'same_found' => false);
364 369
         $error = 'Vous devez saisir au moins deux caractères';
365 370
       }
366 371
       
367 372
       $return_array = array(
368
-        'status'    => $status,
369
-        'timestamp' => $timestamp,
370
-        'error'     => $error,
371
-        'data'      => $tags_response
373
+        'status'     => $status,
374
+        'timestamp'  => $timestamp,
375
+        'error'      => $error,
376
+        'same_found' => $sort_response['same_found'],
377
+        'data'       => $sort_response['tags']
378
+        
372 379
       );
373 380
       
374 381
       $response = new Response(json_encode($return_array));

+ 3 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsPrompt.html.twig Voir le fichier

@@ -20,7 +20,9 @@
20 20
        <img id="tag_loader_{{ form_name }}" class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
21 21
      </div>
22 22
      <ul class="search_tag_list"></ul>
23
-     <a class="more" href="#" style="display: none;">Afficher les autres tags correspondant a la recherche</a>
23
+     <a class="more button" href="#" style="display: none;">
24
+       Afficher les autres tags correspondant a la recherche
25
+     </a>
24 26
    </div>
25 27
 </div>
26 28
 

+ 5 - 0
web/bundles/muzichcore/css/main.css Voir le fichier

@@ -790,4 +790,9 @@ ul#favorite_tags li
790 790
   margin-left: 2px;
791 791
   margin-top: 2px;
792 792
   float:left; /*pour IE*/
793
+}
794
+
795
+a.more
796
+{
797
+  margin-top: 5px;
793 798
 }

+ 3 - 1
web/bundles/muzichcore/js/muzich.js Voir le fichier

@@ -640,8 +640,9 @@ $(document).ready(function(){
640 640
     }
641 641
   });
642 642
 
643
-  $("div.search_tag_list").live('click', function(event){
643
+  $("div.search_tag_list, div.search_tag_list a.more").live('click', function(event){
644 644
     event.stopPropagation();
645
+    $("div.search_tag_list").show();
645 646
   });
646 647
 
647 648
   function autocomplete_tag(input, form_name)
@@ -846,6 +847,7 @@ $(document).ready(function(){
846 847
     jQuery.each( $(this).parent('div').find('ul.search_tag_list li') , function(){
847 848
       $(this).show();
848 849
     });
850
+    $(this).hide();
849 851
     return false;
850 852
   });
851 853