32,67 → 32,8 |
this.htmlResume; |
this.statique = statique; |
|
// Les objets Portlet et Onglet que l'ont garde en mémoire pour pouvoir y accéder facilement |
this.portlet = module; |
this.onglet; |
|
// creerPortlet |
// Créer l'objet Portlet HTML à afficher et le stocker dans les variables de classe |
this.creerPortlet = function() { |
var objet = this; |
|
var titre = $(module).children('.titre'); |
titre.className = 'titre ui-widget-header ui-corner-all'; |
titre.id = 'titre-' + this.id; |
|
|
var contenu = $(module).children('.contenu'); |
contenu.id = 'contenu-' + this.id; |
contenu.className ='contenu'; |
|
var lienToggle = document.createElement('span'); |
lienToggle.className = 'lienToggle ui-icon ui-icon-minusthick'; |
$(titre).append(lienToggle); |
$(lienToggle).click(function() { |
objet.afficherCacherModule(); |
}); |
|
this.portlet = module; |
return module; |
} |
|
this.ongletEstAffiche = function() { |
return $(this.onglet.selector).is(':visible'); |
} |
|
// Crée l'objet Onglet HTML |
this.creerOnglet = function() { |
var objet = this; |
this.onglet = onglet; |
} |
|
// Initialisation de l'objet |
this.creerPortlet(); |
this.creerOnglet(); |
|
// Accesseurs de la classe |
this.getOnglet = function() { |
return this.onglet; |
} |
|
this.getPortlet = function() { |
return this.portlet; |
} |
|
// fonctions d'affichage et cachage (je sais pas si on dit ça comme ça) des onglets |
this.afficherCacherModule = function() { |
$(this.portlet).find(".lienToggle").toggleClass("ui-icon-plusthick"); |
$(this.portlet).find(".lienToggle").toggleClass("ui-icon-minusthick"); |
$(this.portlet).find(".titreOnglet").toggleClass("pasDeCurseur"); |
$(this.portlet).find(".contenu").toggle(); |
} |
} |
|
function getUrlVars() { |
var vars = [], hash; |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); |
104,62 → 45,7 |
return vars; |
} |
|
function afficherOngletsPourNiveau() { |
/* affiche les onglets par default selon niveau*/ |
for (indice in tableauOnglets) { |
var ongletEnCours = tableauOnglets[indice]; |
titre_onglet = ongletEnCours.titre; |
titre_onglet = $.trim(titre_onglet); |
if (!Array.indexOf) { |
Array.prototype.indexOf = function (obj, start) { |
for (var i = (start || 0); i < this.length; i++) { |
if (this[i] == obj) { |
return i; |
} |
} |
return -1; |
} |
} |
if (ongletsDefaut.indexOf(titre_onglet) == -1) { |
ongletEnCours.afficherCacherModule(); |
nbOngletsInvisibles++; |
} |
} |
} |
|
function obtenirOngletCookiePourPage() { |
var urlVars = getUrlVars(); |
var id_cookie = 'onglet_eflore'; |
if (urlVars['num_nom']) { |
id_cookie += '_'+urlVars['num_nom']; |
} |
return $.cookie(id_cookie) ? $.cookie(id_cookie) : null; |
} |
|
function enregistrerOngletCookiePourPage(valeur) { |
var urlVars = getUrlVars(); |
var id_cookie = 'onglet_eflore'; |
if(urlVars['num_nom'] && urlVars['num_nom'] != undefined) { |
id_cookie += '_'+urlVars['num_nom']; |
} |
$.cookie(id_cookie, valeur); |
} |
|
function lierModulesEtOnglets() { |
var i = 1; |
|
//Parcourir la totalité des modules générés et les lier grâce à la classe Module |
$(".module").each(function () { |
i++; |
identifiantOnglet = "#zone_onglets>ul>li:nth-child(" + i +")"; |
var module = new Module(i, this, $(identifiantOnglet)); |
var titre = $(this).children('h3').text(); |
module.titre = titre; |
|
tableauOnglets[identifiantOnglet] = module; |
}); |
} |
|
// remplace des liens directs vers les onglets par des liens permettant de ne charger |
// que le contenu de l'onglet (pour le plugin tab) |
function remplacerUrlsOnglets() { |
172,92 → 58,8 |
}); |
} |
|
ongletsInitialises = false; |
numOngletEnCours = null; |
nePasEmpilerUrl = false; |
popStateOriginal = true; |
function initialiserOnglets() { |
// replacement du chargement de toute la page par un lien vers uniquement le contenu de l'onglet |
// pour le module tab qui charge les url désignée dans les liens des tabs |
//remplacerUrlsOnglets(); |
|
// analyse de l'onglet désigné comme selectionné par défaut |
// (on peut accéder directement à un onglet précis à travers un param url) |
var tabSelectionneDefaut = $('#onglets li.ui-state-active'); |
var indexTabSelectionneDefaut = $("#onglets li").index($(tabSelectionneDefaut)); |
|
$('#zone_onglets').tabs({ |
create: function( event, ui ) { |
// par défaut, le contenu déjà chargé est dans une autre zone |
// on le déplace donc comme s'il avait été chargé par le plugin tab |
var contenuZoneFiche = $("#zone_contenu_fiche > div").detach(); |
contenuZoneFiche.appendTo('#ui-tabs-'+(indexTabSelectionneDefaut+1)); |
$("#zone_contenu_fiche").hide(); |
$('#ui-tabs-'+(indexTabSelectionneDefaut+1)).show(); |
ongletNomCode = $('#ui-tabs-'+(indexTabSelectionneDefaut+1)).children(".onglet_contenu").attr("id"); |
$(".lien_retour_synthese").toggle((ongletNomCode != "synthese")); |
}, |
active: indexTabSelectionneDefaut , |
beforeLoad: function( event, ui ) { |
// il est inutile de recharger un onglet déjà chargé (les onglets déjà chargé sont l'onglet par défaut |
// et (lors du chargement de la fiche), l'onglet déjà chargé par php |
// +1 car les tabs sont zéros indexées |
var idPanelCharge = ui.tab.index()+1; |
var panelCharge = $('#ui-tabs-'+idPanelCharge); |
|
numOngletEnCours = idPanelCharge; |
|
if(!panelCharge.is(':empty') || indexTabSelectionneDefaut+1 == idPanelCharge) { |
// si le panneau est déjà chargé on peut mettre à jour l'url immédiatement |
var ongletNomCode = panelCharge.children(".onglet_contenu").attr("id"); |
if(!nePasEmpilerUrl) { |
mettreAJourUrl(permalienNumNom+"-"+ongletNomCode, ongletNomCode); |
nePasEmpilerUrl = false; |
} |
|
$(".lien_retour_synthese").toggle((ongletNomCode != "synthese")); |
panelCharge.show(); |
return false; |
} else { |
// si l'onglet n'est pas chargé alors on affiche le message de chargement |
// pendant que le plugin s'occupe du reste |
fancyboxinitialise = false; |
var panel = $('#ui-tabs-'+idPanelCharge); |
panel.append("<div class='tab-chargement'>Chargement des informations...</div>"); |
return true; |
} |
}, |
load: function(event, ui) { |
// sur les panneaux qui ne sont pas encore chargés, on doit attendre la fin |
// du chargement pour mettre à jour l'url (à cause de la récupération de l'id sur les enfants) |
var ongletNomCode = ui.panel.children(".onglet_contenu").attr("id"); |
// stats |
if (prod) { |
var ga_json = '{"nn": "' + ga_current_nn + '", "nom_sci": "' + ga_current_ns + '"}'; |
ga('eFloreTracker.send', 'event', 'fiche', 'consultation-' + ongletNomCode, ga_json, 1); |
} |
|
$(".lien_retour_synthese").toggle((ongletNomCode != "synthese")); |
mettreAJourUrl(permalienNumNom+"-"+ongletNomCode, ongletNomCode); |
$(document).trigger('dictionnaireRechercherDefinitions', '#'+ongletNomCode); |
} |
}); |
|
$(window).bind('popstate', function(event) { |
if(!!event.originalEvent.state) { |
nePasEmpilerUrl = true; |
$("#onglets > li > a[rel='"+event.originalEvent.state+"']").click(); |
} else { |
// chrome fait un popstate au chargement de la page, ce qui la fait recharger |
// indéfiniment, ce comportement étant compréhensible, il vaut mieux s'en prévenir |
if(!popStateOriginal) { |
window.location = window.location.href; |
} |
popStateOriginal = false; |
} |
}); |
} |
|
//+----------------------------------------------------------------------------------------------------------+ |
// Wikini Flora |
var htmlWikiOriginal = ''; |
538,23 → 340,6 |
}); |
}); |
|
$(document).one('ongletSyntheseCharge', function() { |
lierModulesEtOnglets(); |
|
/* mouvement des blocs */ |
$(".colonne").sortable({ |
connectWith: ".colonne", |
handle: $(".module").children('h3') // mouvement seulement sur les titres |
}); |
|
$('.lien_ouverture_onglet_parent').live('click', function(event) { |
event.preventDefault(); |
$(this).parents(".module").find("a.titreOnglet").click(); |
}); |
|
gererClicIllustrationsFiche(); |
gererEvenementsPliage(); |
}); |
|
// À la fin du chargement de l'onglet Illustrations |
$(document).one('ongletIllustrationsCharge', function() { |
698,30 → 483,6 |
return amj[2] + ' ' + mois[parseInt(amj[1]) - 1] + ' ' + amj[0]; |
} |
|
function redimensionnerOnglets() { |
|
var largeurTotale = $('#zone_onglets').width(); |
var largeurOnglets = 0; |
var largeurDernierOnglet = 0; |
$('#onglets li').each(function() { |
largeurDernierOnglet = $(this).outerWidth(); |
largeurOnglets += $(this).outerWidth(); |
}); |
|
var espaceRestant = largeurTotale - largeurOnglets; |
if(espaceRestant < largeurDernierOnglet) { |
var pxALiberer = (largeurDernierOnglet - espaceRestant)/ $('#onglets li').size(); |
$('#onglets li').each(function() { |
$(this).width($(this).width() - (pxALiberer - 4)); |
$(this).css("font-size", "0.9em"); |
}); |
} else { |
$('#onglets li').each(function() { |
$(this).css("width", "auto"); |
$(this).css("font-size", "1em"); |
}); |
} |
} |
|
// ouvre le popup de galerie lors d'un clic sur l'illustration dans la fiche synthèse |
function gererClicIllustrationsFiche() { |