Subversion Repositories Sites.tela-botanica.org

Rev

Rev 1038 | Rev 1074 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
715 jpm 1
/**
2
 * Script JQuery du site
3
 *
1040 aurelien 4
 * @author Grégoire Duché <jpm@tela-botanica.org>
715 jpm 5
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
6
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
7
 * @version $Id$
8
 * @copyright 2009
9
 */
10
 
11
var url_service_jrest = "http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/TelaUtilisateurs/";
12
$(document).ready(function() {
13
	/**
1040 aurelien 14
	 * Ajout de contenus : inscrits, connectés, et boutons précédents et suivants
715 jpm 15
	 * */
1040 aurelien 16
	// On ajoute les champs Inscrits et connectés uniquement si JS obtient une réponse du service
715 jpm 17
	$.getJSON(url_service_jrest,
18
		function(data) {
19
			if (data != null) {
787 gduche 20
				//R�ponse du service OK
715 jpm 21
				var nbInscrits = data[0];
22
				var nbVisiteurs = data[1];
23
 
24
				$("#zone-menu-haut ul #connectes span").prepend(nbVisiteurs);
25
				$("#zone-menu-haut ul #inscrits span").prepend(nbInscrits);
26
 
1040 aurelien 27
				// les div de classe infoInscrits se voient automatiquement concaténées le nombre d'inscrits
842 aurelien 28
				if($(".infosInscrits a") != null) {
29
					$(".infosInscrits a").html(nbInscrits+$(".infosInscrits a").html());
715 jpm 30
				}
31
			} else {
32
				$("#zone-menu-haut").prepend('<span class="spacer125 hidden">&nbsp</span>');
33
			}
34
		});
35
 
944 gduche 36
	$("#bandeauProjets").css("overflow", "hidden");
715 jpm 37
	$("#bandeauProjets").css("height", "100px");
944 gduche 38
	$("#bandeauProjets ul").css("overflow", "hidden");
715 jpm 39
	$("#bandeauProjets ul").css("width", "9000px");
40
 
41
	/********************************************************************************
42
	 * Gestion des projets - menu defilant
43
	 ********************************************************************************/
1040 aurelien 44
	/* Ajout à la volée des boutons suivants et précédent pour le menu défilant
45
	 * Attention : le contenu des projets doit être une liste d'éléments <li>.
715 jpm 46
	 * Ex :
47
	 * <li><img src="" / ><h3>Projet 1</h3></li>
48
	 * <li><img src="" / ><h3>Deuxieme projet</h3></li>
49
	 * */
50
 
51
	$("#bandeauProjets").append("<div id='boutonPrecedent'>&nbsp;</div>");
52
	$("#bandeauProjets").append("<div id='boutonSuivant'>&nbsp;</div>");
53
 
944 gduche 54
	/* Variables pour le défilement*/
715 jpm 55
	var position = 0;
56
	var increment = 269;
57
 
58
	$("#boutonSuivant").click(function()	{
1040 aurelien 59
		//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
715 jpm 60
		var ul = $(this).parent().children("ul");
61
		var nbLi = ($(ul).children("li").size())-3;
62
		if (position/increment < nbLi) {
63
			position += increment;
64
			$(ul).animate({marginLeft: '-' + position}, 400, function() {});
65
		}
66
	});
67
 
68
	$("#boutonPrecedent").click(function() {
1040 aurelien 69
		//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
715 jpm 70
		if (position > 0) {
71
			position -= increment;
72
			var ul = $(this).parent().children("ul");
73
			$(ul).animate({marginLeft: '-' + position}, 400, function() {});
74
		}
75
	});
76
 
77
	if (navigator.appName == 'Microsoft Internet Explorer') {
78
		$("#zone-titre").css("font-family", "optima2");
79
		$(".motsclefs").css("font-family", "Helveticaneue2");
80
	}
81
});
82
 
787 gduche 83
 
1040 aurelien 84
/**
85
* Vidage de valeurs par défaut du champ d'identification
86
*/
87
$(document).ready(function() {
88
 
89
    if($('input#username') != null) {
90
      var valeur_defaut_champ_id = $('input#username').val();
91
      $('input#username').click(function() {
92
 
93
	  if($('input#username').val() == valeur_defaut_champ_id) {
94
	    $('input#username').val("");
95
	    $('input#username').unbind("click");
96
	  }
97
      });
98
    }
99
 
100
    if($('input#password') != null) {
101
      var valeur_defaut_champ_pass = $('input#password').val();
102
      $('input#password').click(function() {
103
 
104
	  if($('input#password').val() == valeur_defaut_champ_pass) {
105
	    $('input#password').val("");
106
	    $('input#password').unbind("click");
107
	  }
108
      });
109
    }
110
});
111
 
112
/* Vider le champ recherche : prend en compte la valeur par défaut (multilingue)*/
867 gduche 113
function nettoyerChamp(objetId, valeurDefaut)	{
114
	objet = document.getElementById(objetId);
787 gduche 115
	if (objet.value == valeurDefaut)	{
715 jpm 116
		objet.value = "";
117
	}
787 gduche 118
}
1038 aurelien 119
 
120
/**
121
* Crée des liens de pliage/dépliage à partir de certains styles
122
*/
123
$(document).ready(function() {
124
	$('.lien_pliage').parent().contents().filter(function() {
125
		  return (this.nodeType == 3) && (jQuery.trim($(this).text()) != "");
126
	}).wrap("<span></span>");
127
 
128
	$('.lien_pliage').addClass("plie");
129
	$('.lien_pliage').siblings().hide();
130
 
131
	$(".lien_pliage").click(function() {
132
		$(this).siblings().toggle('slow', function() {
133
		});
134
 
1040 aurelien 135
		$(this).toggleClass("plie");
1038 aurelien 136
	});
137
});
1040 aurelien 138
 
139
var url_service_jrest_lien = "http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/MiniLienProfil/";
140
$(document).ready(function() {
141
 
142
	$.getJSON(url_service_jrest_lien, function(data) {
143
	    $("#inscrits").after('<li class="mini_lien_profil">'+data+'</li>');
144
	});
145
});