Subversion Repositories Sites.tela-botanica.org

Compare Revisions

Ignore whitespace Rev 1111 → Rev 1112

/trunk/sites/commun/generique/scripts/commun.js
1,174 → 1,174
/**
* Script JQuery du site
*
* @author Grégoire Duché <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright 2009
*/
 
var url_service_jrest = "http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/TelaUtilisateurs/";
$(document).ready(function() {
/**
* Ajout de contenus : inscrits, connectés, et boutons précédents et suivants
* */
// On ajoute les champs Inscrits et connectés uniquement si JS obtient une réponse du service
$.getJSON(url_service_jrest,
function(data) {
if (data != null) {
//R�ponse du service OK
var nbInscrits = data[0];
var nbVisiteurs = data[1];
 
$("#zone-menu-haut ul #connectes span").prepend(nbVisiteurs);
$("#zone-menu-haut ul #inscrits span").prepend(nbInscrits);
 
// les div de classe infoInscrits se voient automatiquement concaténées le nombre d'inscrits
if($(".infosInscrits a") != null) {
$(".infosInscrits a").html(nbInscrits+$(".infosInscrits a").html());
}
} else {
$("#zone-menu-haut").prepend('<span class="spacer125 hidden">&nbsp</span>');
}
});
$("#bandeauProjets").css("overflow", "hidden");
$("#bandeauProjets").css("height", "100px");
$("#bandeauProjets ul").css("overflow", "hidden");
$("#bandeauProjets ul").css("width", "9000px");
 
/********************************************************************************
* Gestion des projets - menu defilant
********************************************************************************/
/* Ajout à la volée des boutons suivants et précédent pour le menu défilant
* Attention : le contenu des projets doit être une liste d'éléments <li>.
* Ex :
* <li><img src="" / ><h3>Projet 1</h3></li>
* <li><img src="" / ><h3>Deuxieme projet</h3></li>
* */
/***
* ORDRE ALEATOIRE POUR LES PROJETS DEFILANTS
* **/
(function($){
 
$.fn.shuffle = function() {
 
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
 
this.each(function(i){
$(this).replaceWith($(shuffled[i]));
});
 
return $(shuffled);
 
};
 
})(jQuery);
$('#bandeauProjets li').shuffle();
$("#bandeauProjets").append("<div id='boutonPrecedent'>&nbsp;</div>");
$("#bandeauProjets").append("<div id='boutonSuivant'>&nbsp;</div>");
 
/* Variables pour le défilement*/
var position = 0;
var increment = 269;
$("#boutonSuivant").click(function() {
//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
var ul = $(this).parent().children("ul");
var nbLi = ($(ul).children("li").size())-3;
if (position/increment < nbLi) {
position += increment;
$(ul).animate({marginLeft: '-' + position}, 400, function() {});
}
});
 
$("#boutonPrecedent").click(function() {
//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
if (position > 0) {
position -= increment;
var ul = $(this).parent().children("ul");
$(ul).animate({marginLeft: '-' + position}, 400, function() {});
}
});
if (navigator.appName == 'Microsoft Internet Explorer') {
$("#zone-titre").css("font-family", "optima2");
$(".motsclefs").css("font-family", "Helveticaneue2");
}
});
 
 
/**
* Vidage de valeurs par défaut du champ d'identification
*/
$(document).ready(function() {
if($('input#username') != null) {
var valeur_defaut_champ_id = $('input#username').val();
$('input#username').click(function() {
if($('input#username').val() == valeur_defaut_champ_id) {
$('input#username').val("");
$('input#username').unbind("click");
}
});
}
if($('input#password') != null) {
var valeur_defaut_champ_pass = $('input#password').val();
$('input#password').click(function() {
if($('input#password').val() == valeur_defaut_champ_pass) {
$('input#password').val("");
$('input#password').unbind("click");
}
});
}
});
 
/* Vider le champ recherche : prend en compte la valeur par défaut (multilingue)*/
function nettoyerChamp(objetId, valeurDefaut) {
objet = document.getElementById(objetId);
if (objet.value == valeurDefaut) {
objet.value = "";
}
}
 
/**
* Crée des liens de pliage/dépliage à partir de certains styles
*/
$(document).ready(function() {
$('.lien_pliage').parent().contents().filter(function() {
return (this.nodeType == 3) && (jQuery.trim($(this).text()) != "");
}).wrap("<span></span>");
$('.lien_pliage').addClass("plie");
$('.lien_pliage').siblings().hide();
$(".lien_pliage").click(function() {
$(this).siblings().toggle('slow', function() {
});
$(this).toggleClass("plie");
});
});
 
var url_service_jrest_lien = "http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/MiniLienProfil/";
$(document).ready(function() {
 
$.getJSON(url_service_jrest_lien, function(data) {
$("#inscrits").after('<li class="mini_lien_profil">'+data+'</li>');
});
});
/**
* Script JQuery du site
*
* @author Grégoire Duché <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright 2009
*/
 
var url_service_jrest = "http://www.tela-botanica.org/service:annuaire:TelaUtilisateurs/";
$(document).ready(function() {
/**
* Ajout de contenus : inscrits, connectés, et boutons précédents et suivants
* */
// On ajoute les champs Inscrits et connectés uniquement si JS obtient une réponse du service
$.getJSON(url_service_jrest,
function(data) {
if (data != null) {
//R�ponse du service OK
var nbInscrits = data[0];
var nbVisiteurs = data[1];
 
$("#zone-menu-haut ul #connectes span").prepend(nbVisiteurs);
$("#zone-menu-haut ul #inscrits span").prepend(nbInscrits);
 
// les div de classe infoInscrits se voient automatiquement concaténées le nombre d'inscrits
if($(".infosInscrits a") != null) {
$(".infosInscrits a").html(nbInscrits+$(".infosInscrits a").html());
}
} else {
$("#zone-menu-haut").prepend('<span class="spacer125 hidden">&nbsp</span>');
}
});
$("#bandeauProjets").css("overflow", "hidden");
$("#bandeauProjets").css("height", "100px");
$("#bandeauProjets ul").css("overflow", "hidden");
$("#bandeauProjets ul").css("width", "9000px");
 
/********************************************************************************
* Gestion des projets - menu defilant
********************************************************************************/
/* Ajout à la volée des boutons suivants et précédent pour le menu défilant
* Attention : le contenu des projets doit être une liste d'éléments <li>.
* Ex :
* <li><img src="" / ><h3>Projet 1</h3></li>
* <li><img src="" / ><h3>Deuxieme projet</h3></li>
* */
/***
* ORDRE ALEATOIRE POUR LES PROJETS DEFILANTS
* **/
(function($){
 
$.fn.shuffle = function() {
 
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
 
this.each(function(i){
$(this).replaceWith($(shuffled[i]));
});
 
return $(shuffled);
 
};
 
})(jQuery);
$('#bandeauProjets li').shuffle();
$("#bandeauProjets").append("<div id='boutonPrecedent'>&nbsp;</div>");
$("#bandeauProjets").append("<div id='boutonSuivant'>&nbsp;</div>");
 
/* Variables pour le défilement*/
var position = 0;
var increment = 269;
$("#boutonSuivant").click(function() {
//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
var ul = $(this).parent().children("ul");
var nbLi = ($(ul).children("li").size())-3;
if (position/increment < nbLi) {
position += increment;
$(ul).animate({marginLeft: '-' + position}, 400, function() {});
}
});
 
$("#boutonPrecedent").click(function() {
//Un clic sur le bouton "Projet suivant" doit défiler la liste des projets
if (position > 0) {
position -= increment;
var ul = $(this).parent().children("ul");
$(ul).animate({marginLeft: '-' + position}, 400, function() {});
}
});
if (navigator.appName == 'Microsoft Internet Explorer') {
$("#zone-titre").css("font-family", "optima2");
$(".motsclefs").css("font-family", "Helveticaneue2");
}
});
 
 
/**
* Vidage de valeurs par défaut du champ d'identification
*/
$(document).ready(function() {
if($('input#username') != null) {
var valeur_defaut_champ_id = $('input#username').val();
$('input#username').click(function() {
if($('input#username').val() == valeur_defaut_champ_id) {
$('input#username').val("");
$('input#username').unbind("click");
}
});
}
if($('input#password') != null) {
var valeur_defaut_champ_pass = $('input#password').val();
$('input#password').click(function() {
if($('input#password').val() == valeur_defaut_champ_pass) {
$('input#password').val("");
$('input#password').unbind("click");
}
});
}
});
 
/* Vider le champ recherche : prend en compte la valeur par défaut (multilingue)*/
function nettoyerChamp(objetId, valeurDefaut) {
objet = document.getElementById(objetId);
if (objet.value == valeurDefaut) {
objet.value = "";
}
}
 
/**
* Crée des liens de pliage/dépliage à partir de certains styles
*/
$(document).ready(function() {
$('.lien_pliage').parent().contents().filter(function() {
return (this.nodeType == 3) && (jQuery.trim($(this).text()) != "");
}).wrap("<span></span>");
$('.lien_pliage').addClass("plie");
$('.lien_pliage').siblings().hide();
$(".lien_pliage").click(function() {
$(this).siblings().toggle('slow', function() {
});
$(this).toggleClass("plie");
});
});
 
var url_service_jrest_lien = "http://www.tela-botanica.org/client/annuaire_nouveau/actuelle/jrest/MiniLienProfil/";
$(document).ready(function() {
 
$.getJSON(url_service_jrest_lien, function(data) {
$("#inscrits").after('<li class="mini_lien_profil">'+data+'</li>');
});
});