Browse Source

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

bastien 13 years ago
parent
commit
811bb80750

+ 14 - 7
src/Muzich/CoreBundle/Controller/SearchController.php View File

236
    */
236
    */
237
   private function sort_search_tags($tags, $search)
237
   private function sort_search_tags($tags, $search)
238
   {
238
   {
239
+    $same_found = false;
239
     $canonicalizer = new StrictCanonicalizer();
240
     $canonicalizer = new StrictCanonicalizer();
240
     $tag_sorted = array();
241
     $tag_sorted = array();
241
     
242
     
273
         {
274
         {
274
           if (strtoupper($canonicalizer->canonicalize($word)) == strtoupper($tag['slug']))
275
           if (strtoupper($canonicalizer->canonicalize($word)) == strtoupper($tag['slug']))
275
           {
276
           {
277
+            $same_found = true;
276
             $tag_sorted = $this->sort_addtop_if_isnt_in($tag_sorted, $tag);
278
             $tag_sorted = $this->sort_addtop_if_isnt_in($tag_sorted, $tag);
277
           }
279
           }
278
         }
280
         }
284
       $tag_sorted = $this->sort_addbottom_if_isnt_in($tag_sorted, $tag);
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
           );
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
         $status = 'success';
362
         $status = 'success';
358
         $error  = '';
363
         $error  = '';
359
       }
364
       }
360
       else
365
       else
361
       {
366
       {
362
         $status = 'error';
367
         $status = 'error';
363
-        $tags_response = array();
368
+        $sort_response = array('tags' => array(), 'same_found' => false);
364
         $error = 'Vous devez saisir au moins deux caractères';
369
         $error = 'Vous devez saisir au moins deux caractères';
365
       }
370
       }
366
       
371
       
367
       $return_array = array(
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
       $response = new Response(json_encode($return_array));
381
       $response = new Response(json_encode($return_array));

+ 3 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsPrompt.html.twig View File

20
        <img id="tag_loader_{{ form_name }}" class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
20
        <img id="tag_loader_{{ form_name }}" class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
21
      </div>
21
      </div>
22
      <ul class="search_tag_list"></ul>
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
    </div>
26
    </div>
25
 </div>
27
 </div>
26
 
28
 

+ 5 - 0
web/bundles/muzichcore/css/main.css View File

790
   margin-left: 2px;
790
   margin-left: 2px;
791
   margin-top: 2px;
791
   margin-top: 2px;
792
   float:left; /*pour IE*/
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 View File

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
     event.stopPropagation();
644
     event.stopPropagation();
645
+    $("div.search_tag_list").show();
645
   });
646
   });
646
 
647
 
647
   function autocomplete_tag(input, form_name)
648
   function autocomplete_tag(input, form_name)
846
     jQuery.each( $(this).parent('div').find('ul.search_tag_list li') , function(){
847
     jQuery.each( $(this).parent('div').find('ul.search_tag_list li') , function(){
847
       $(this).show();
848
       $(this).show();
848
     });
849
     });
850
+    $(this).hide();
849
     return false;
851
     return false;
850
   });
852
   });
851
   
853