www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

recherche.js (1370B)


      1 function uiRechercher() { 
      2     log("Recherche…");
      3     rechercher($('#nom-bloc').val(), uiEditer);
      4 }
      5 
      6 function arreterRecherche() {
      7     $('#resultats-recherche').hide();
      8     $('#edition-blocs').show();
      9 }
     10 
     11 function demarrerRecherche() {
     12     $('#resultats-recherche tbody').empty();
     13     $('#resultats-recherche').show();
     14     $('#edition-blocs').hide();
     15 }
     16 
     17 function rechercher(terme, action) {
     18     action = action || function() {return true;}
     19     demarrerRecherche();
     20     
     21     $(
     22         $.grep($w.blocs, function (b) {
     23             return b.nom.indexOf(terme) >= 0;
     24         })
     25     )
     26     
     27     .map(function(idx, elem) {
     28         return $('#modele-resultat-recherche')
     29             .jqote(elem)
     30             .toDom()
     31             .addClass(elem.uid == $w.blocActif ? 'actif' : '')
     32             .data("uid", elem.uid)
     33             .click(function () {
     34                 action(elem.uid);
     35             })
     36             
     37             .find('.editer')
     38             .click(function() {
     39                 arreterRecherche();
     40                 uiEditer(elem.uid);
     41                 return false;
     42             })
     43             .end()
     44         
     45             .find('.utiliser')
     46             .click(function() {
     47                 arreterRecherche();
     48                 uiUtiliser(elem.uid);
     49                 return false;
     50             })
     51             .end();
     52     })
     53     
     54     .appendTo('#resultats-recherche tbody');
     55 }