/** FONTIONS EXECUTEES AU CHARGEMENT DU DOM **/ $(document).ready(function() { /** liste de résultats **/ // $('ul.listeLogements li:not(li[class^="datePerso"])').live('click', function() // { // var id = $(this).attr('id'); // alert(id); // var tab = id.split('_'); // var blockId; // $('#resultat' + tab[0] + ' ul.listeLogements li.selected').addClass('unselected'); // $('#resultat' + tab[0] + ' ul.listeLogements li.selected').removeClass('selected'); // $(this).removeClass('unselected'); // $(this).addClass('selected'); // $('#resultat' + tab[0] + ' div.dates ul.liste_dates').each(function(){ // if($(this).css('display') != 'none') // { // blockId = $(this).attr('id'); // $('#resultat' + tab[0] + ' div.dates ul#' + blockId).hide('slide', 500, function(){ // $('#resultat' + tab[0] + ' div.dates ul#dispo_' + tab[0] + '_' + tab[1]).show('slide', 500); // }); // } // }); // if(typeof(blockId) == 'undefined') $('#resultat' + tab[0] + ' div.dates ul#dispo_' + tab[0] + '_' + tab[1]).show('slide', 500); // }); /** liste de résultats **/ $('ul.listeLogements li:not(li[class^="datePerso"])').live('click', function() { var id = $(this).attr('id'); // alert(id); var tab = id.split('_'); var blockId; $('#resultat' + tab[1] + ' ul.listeLogements li.selected').addClass('unselected'); $('#resultat' + tab[1] + ' ul.listeLogements li.selected').removeClass('selected'); $(this).removeClass('unselected'); $(this).addClass('selected'); $('#resultat' + tab[1] + ' div.dates ul.liste_dates').each(function(){ if($(this).css('display') != 'none') { blockId = $(this).attr('id'); $('#resultat' + tab[1] + ' div.dates ul#' + blockId).hide('slide', 500, function(){ $('#resultat' + tab[1] + ' div.dates ul#dispo_' + tab[1] + '_' + tab[2]).show('slide', 500); }); } }); if(typeof(blockId) == 'undefined') $('#resultat' + tab[1] + ' div.dates ul#dispo_' + tab[1] + '_' + tab[2]).show('slide', 500); }); /** liste de résultats **/ $('ul.listeLogements li[class^="datePerso"]').live('click', function() { var id = $(this).attr('id'); var tab = id.split('_'); // Met les background color en blanc et les bordures en gris $('#resultat' + tab[0] + ' li[id^="dispo_"]').css('backgroundColor', '#FFFFFF').css('borderColor', $(this).parent('div.produit').children('div.desc_produit_title').css('backgroundColor')); $('#resultat' + tab[0] + ' ul.listeLogements li.selected').toggleClass('unselected selected'); $(this).toggleClass('unselected selected'); // Met les background color et les bordures de la couleur de la typo choisie (prestige, classic, ..., etc) $('ul#dispo_' + tab[0] + '_' + tab[1] + ' li').css('backgroundColor', $(this).css('backgroundColor')).css('borderColor', $(this).css('backgroundColor')); }); /** liste de résultats thematiques **/ // $('div#liste_produits.liste_thematiques a[id^="savoir_plus_"]').live('click', function() $('div#liste_produits.liste_thematiques a[id^="savoir_plus_"]').click(function() { var tab = $(this).attr('id').split('_'); // $('form#formPageThematiques').attr('action', $('span.infosCacheesThematiques span#lien_' + tab[3]).html()); $('form#formPageThematiques').attr('action', $('div.desc_produit a#savoir_plus_date_' + tab[3]).attr('href')); $('#dateDebutChoisie').val($('#dateDebut_' + tab[3]).val()); $('#dateFinChoisie').val($('#dateFin_' + tab[3]).val()); $('#typologieCode').val($('#codeTypologie_' + tab[3]).val()); $('#typologieLibelle').val($('#libelleTypologie_' + tab[3]).val()); // On poste le form $('form#formPageThematiques').submit(); return false; }); /** liste de résultats page d'accueil **/ // $('div#liste_produits.liste_accueil a[id^="savoir_plus_"]').live('click', function() $('div#liste_produits.liste_accueil a[id^="savoir_plus_"]').click(function() { var tab = $(this).attr('id').split('_'); // var test = ''; // var max = tab.length; // for(var i = 0; i < max ; i++) // { // test += 'tab[' + i + '] = ' + tab[i] + "\n"; // } // alert('id = ' + $(this).attr('id')); // alert('max = ' + max); // alert(test); // Si on a cliquer sur un produit de zoomSur // if(tab[2] == "zoomSur") $('form#formPageAccueil').attr('action', $(this).parent().find('span[class^="infosCachees"] span#lien_' + tab[3]).html()); if(tab[2] == "zoomSur") { $('form#formPageAccueil').attr('action', $(this).attr('href')); } // Sinon on va chercher le lien correspondant à la résidence dans les bon plans else { $('form#formPageAccueil').attr('action', $('div.desc_produit a#savoir_plus_lien_' + tab[3]).attr('href')); } $('#dateDebutChoisie').val($(this).parent().find('input[name="dateDebut"]').val()); $('#dateFinChoisie').val($(this).parent().find('input[name="dateFin"]').val()); $('#typologieCode').val($(this).parent().find('input[name="codeTypologie"]').val()); $('#typologieLibelle').val($(this).parent().find('input[name="libelleTypologie"]').val()); // On poste le form $('form#formPageAccueil').submit(); return false; }); $('a.lienReserver').live('click', function() { var id = $(this).attr('id'); var tab = id.split('_'); $('form#formPageLogement').attr('action', $('#resultat' + tab[1] + ' span.infosCacheesLogements span.lien').html()); // var spanCache = '#resultat' + tab[1] + ' div.dates ul#dispo_' + tab[1] + '_' + tab[2] + ' li#dispo_' + tab[3] + ' span.infosCacheesDispos'; var spanCache = '#resultat' + tab[1] + ' div.dates ul#dispo_' + tab[1] + '_' + tab[2] + ' li[id^="dispo_' + tab[3] + '_"] span.infosCacheesDispos'; $('#typologieCodeChoisi').val($(spanCache + ' span.typologieCodeChoisi').html()); $('#typologieLibelleChoisie').val($(spanCache + ' span.typologieLibelleChoisie').html()); $('#dateDebutChoisie').val($(spanCache + ' span.dateDebutChoisie').html()); $('#dateFinChoisie').val($(spanCache + ' span.dateFinChoisie').html()); $('#prixVenteChoisi').val($(spanCache + ' span.prixventeChoisi').html()); $('#prixBaseChoisi').val($(spanCache + ' span.prixBaseChoisi').html()); $('#formuleHebergementChoisi').val($(spanCache + ' span.formuleHebergementChoisi').html()); //On poste le form $('form#formPageLogement').submit(); return false; }); function descendreScrollTypologie() { var id = $(this).attr('id'); var tab = id.split('_'); compteur = 1; var dispoDebutEnlevee = 0; var dispoFinAjoutee = 0; $('#fleche_h_' + tab[2]).unbind('click'); $('#fleche_h_' + tab[2]).click(monterScrollTypologie); $('#fleche_h_' + tab[2]).attr('src', 'site/media/liste_produits/fleche_h.png'); var nombreTypologies = $('#resultat' + tab[2] + ' ul.listeLogements li').length; $('#resultat' + tab[2] + ' ul.listeLogements li').each(function() { //On ajoute une typo en bas if(dispoDebutEnlevee == 1 && dispoFinAjoutee == 0 && $(this).hasClass('hidden') == true) { $(this).removeClass('hidden'); $(this).addClass('show'); dispoFinAjoutee = 1; //Si c'est la dernière typo, il faut désactivé la fleche du bas if(compteur == nombreTypologies) { $('#fleche_b_' + tab[2]).unbind('click'); $('#fleche_b_' + tab[2]).attr('src', 'site/media/liste_produits/fleche_b_desactivee.png'); } } //On enlève une typo en haut if( $(this).hasClass('hidden') == false && dispoDebutEnlevee == 0) { $(this).removeClass('show').addClass('hidden'); dispoDebutEnlevee = 1; } compteur++; }); } function monterScrollTypologie() { var id = $(this).attr('id'); var tab = id.split('_'); $('#fleche_b_' + tab[2]).unbind('click'); $('#fleche_b_' + tab[2]).click(descendreScrollTypologie); $('#fleche_b_' + tab[2]).attr('src', 'site/media/liste_produits/fleche_b.png'); compteur = 1; var nombreTypologies = $('#resultat' + tab[2] + ' ul.listeLogements li').length; var typoTrouvees = 0; $('#resultat' + tab[2] + ' ul.listeLogements li').each(function() { if($(this).hasClass('show') == true && typoTrouvees == 0) { typoAAffichee = compteur - 1; typoAEnlevee = compteur + 5; typoTrouvees = 1; } compteur++; }); compteur = 1; $('#resultat' + tab[2] + ' ul.listeLogements li').each(function() { //On ajoute une typo en haut if(compteur == typoAAffichee) { $(this).removeClass('hidden'); $(this).addClass('show'); } //On enlève une typo en haut if(compteur == typoAEnlevee) { $(this).removeClass('show'); $(this).addClass('hidden'); } compteur++; }); //Si c'est la première typo, il faut désactivé la fleche du haut if(typoAAffichee == 1) { $('#fleche_h_' + tab[2]).unbind('click'); $('#fleche_h_' + tab[2]).attr('src', 'site/media/liste_produits/fleche_h_desactivee.png'); } } $("img.fleche_b").click(descendreScrollTypologie); });