/**
**Optim-ActualiteScientifique
**/
/**
Change le numero de la page selectionnee par une balise non cliquable.
Cache les numeros de Page trop eloigne de celle cliquee.
**/
window.wdg.pushInit(".pagination", function () {
var offset = parseInt($('.offset').html());
var nbParPage = parseInt($('.nbParPage').html());
var offsetNeighbor = parseInt($('.offsetNeighbor').html());
if(offset && offsetNeighbor){
var pagination = $('.pagination>a');
pagination.each(function (i) {
var numPage = parseInt($(this).html());
var selectedNumPage = parseInt(offset/nbParPage) + 1;
if($(this).hasClass(selectedNumPage)){
$(this).replaceWith(''+selectedNumPage+'');
}else if(numPage<(selectedNumPage+offsetNeighbor) && numPage>(selectedNumPage-offsetNeighbor) ){
}else{
$(this).remove();
}
});
}
});
/**
* Validation widget de recherche.
*/
function validSearchMulti(form) {
// recuperation du formulaire
$elf = $(form);
$electThematic = $elf.find("select[name='thematic']");
$("input[name='thematic-name']").val($electThematic.find('option:selected').text())
return true;
}
/**
* Permet de mettre a jour le champ input des rubric-thematic.
*/
window.wdg.pushInit(".pageRubThem", function () {
if ($('.pageRubThem').data('data')) {
var rubId = $('.pageRubThem').data('data').id;
var optionToKeep = "option[value='" + rubId + "']";
// met a jour le select : wigdet recherhe
$("select[name='rubric-thematic']").find(optionToKeep).attr("selected", "selected");
// met a jour le input : widget light
$("input[name='rubric-thematic']").val($('.pageRubThem').data('data').id);
}
});
/**
Si le nom de la rubrique est affiché: cacher le nom de cette rubrique dans chaque Resume_illustre
**/
window.wdg.pushInit(".artType", function () {
var $elf = $(this);
var titreRubrik = $('.mainBoxTitle').attr('subtype');
$elf.each(function( index ) {
var nomRubrikCourante = $(this).attr('subtype');
if (titreRubrik == nomRubrikCourante) {
$elf.hide();
}
});
});
/**
Si l'id de la rubrique cliquee est la meme que celle des articles affichee: cache le nom de la rubrique dans chaque article
**/
window.wdg.pushInit(".artTopic", function () {
var $elf = $(this);
var rubId = $('.mainBoxTitle').attr('rubId');
if (!rubId) {
var $pageRubrique = $('.pageRubThem');
if ($pageRubrique && $pageRubrique.data() && $pageRubrique.data().data) {
rubId = $pageRubrique.data().data.id;
}
}
if (rubId) {
$elf.each(function( index ) {
var idRubrikCourante = $(this).find('.rubrikThem').attr('rubId');
if (rubId == idRubrikCourante) {
$elf.hide();
}
});
} else {
console.log("Impossible de trouver le rubId.");
}
});
/**
* Initalisation du widget de recherche.
*/
window.wdg.pushInit(".search", function () {
var $earchDatas = $(this).data('data'); // recuperation des donnes postees.
if ($earchDatas) { // initialisation des widgets.
// formulaire de recherche
$formSearch = $("form[name='form-search-as']");
$formSearch.find("select[name='rubric']").val($earchDatas.rubric);
$formSearch.find("select[name='period']").val($earchDatas.period);
$formSearch.find("select[name='thematic']").val($earchDatas.thematic);
}
});
/**
* Pagination recherche.
*/
window.wdg.pushInit(".wdg_form_search_link", function () {
var $elf = $(this);
$elf.click(function(){
var nopage = $elf.attr("rel");
// mise a jour de l attribut nopage
$("input[name='nopage']").val(nopage);
// validation du form
$(".wdg_form_search").submit();
});
});
/**
* Permet de positionner le mot recherche
* dans les input recherche.
*/
window.wdg.pushInit(".search-as", function () {
var $elf = $(this);
if ($elf.val() != "") {
$('#lbl-site-search').val($elf.val());
}
});
/**
* widget en bref.
*/
window.wdg.pushInit(".wdgEnBref .mainBoxFooter a", function () {
$(this).addClass('btnFooter');
});
/**
* Reset form focus
*/
window.wdg.pushInit(".wdg_reset-focus", function() {
var $elf = $(this);
$elf.focus(function(){
if ($(this).val() == this.defaultValue) $(this).val('');
});
$elf.blur(function(){
if ($.trim(this.value) == '') this.value = (this.defaultValue ? this.defaultValue : '');
});
});
window.wdg.pushInit(".wdg_ss_bottom_text", function() {
$(this).show();
});
window.wdg.pushInit(".wdg_ss_top_text", function() {
$(this).show();
});
window.wdg.pushInit(".wdg_ss_over_text", function() {
$(this).show();
});
$(window).load(function(){
function ajustImageParagraphe(){
var paragraphe = $('.highlightArticle').find('p');
if($('.highlightArticle').find('.mediaBox img')){
var imgHeight = '' ;
imgHeight = $('.highlightArticle').find('.mediaBox img').height();
if(paragraphe.height()