77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
jQuery(function($) {
|
|
article_precedent_suivant();
|
|
gotop_scroll();
|
|
//onAjaxLoad(gotop_scroll);
|
|
|
|
function article_precedent_suivant(){
|
|
$('.parent_prev_next').on('click', 'svg.cursor', function(){
|
|
var id_article = $(this).data('id_article');
|
|
var bloc_recharger = $(this).data('bloc_recharger');
|
|
ajaxReload(bloc_recharger, {
|
|
args:{
|
|
id_article:id_article,
|
|
},
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
// afficher/masquer les mots-clés dans les blocs
|
|
function affmasq() {
|
|
$('.affmasq').on('click', function() {
|
|
var le_parent = $(this).parent();
|
|
le_parent.children('i').toggleClass('hidden');
|
|
var les_mots = $(this).parents('.mots');
|
|
les_mots.children('.am_mots, .am_tags').toggleClass('une_ligne');
|
|
});
|
|
}
|
|
|
|
/* retour top pas trop brutal */
|
|
function gotop_scroll(){
|
|
$('a.page-scroll').bind('click', function(event) {
|
|
var $anchor = $(this);
|
|
$("html, body").animate({ scrollTop: 0 }, "slow");
|
|
event.preventDefault();
|
|
});
|
|
}
|
|
|
|
|
|
// les modifs déclenchées au scroll:
|
|
// afficher la flêche gotop
|
|
// passer en fixed sur le petits écrans
|
|
//var barnavOffset = $('#top_contenu').offset().top;
|
|
// sale patch pour compenser les pages où le offset est à 0
|
|
/*if (barnavOffset === 0){
|
|
barnavOffset = 26.5;
|
|
}*/
|
|
var barnavOffset = 0;
|
|
$(window).on('scroll', function () {
|
|
if ( $(window).scrollTop() > barnavOffset ) {
|
|
$('#menu-principal').addClass('reduit');
|
|
//$('button.burgermenu, #barnav ul.js-sous-menu').addClass('fixed-top');
|
|
}
|
|
else {
|
|
$('#menu-principal').removeClass('reduit');
|
|
//$('button.burgermenu, #barnav ul.js-sous-menu').removeClass('fixed-top');
|
|
}
|
|
});
|
|
|
|
// Fonction exécutée au redimensionnement: afficher la barrenav en fixed ou pas
|
|
function redimensionnement() {
|
|
var result = document.getElementById('result');
|
|
if("matchMedia" in window) { // Détection
|
|
if (window.matchMedia("(min-width:768px)").matches) {
|
|
$('#header').removeClass('navbar-fixed-top');
|
|
$('button.burgermenu, #barnav ul.js-sous-menu').removeClass('fixed-top');
|
|
}
|
|
else {
|
|
$('#header').addClass('navbar-fixed-top');
|
|
$('button.burgermenu, #barnav ul.js-sous-menu').addClass('fixed-top');
|
|
}
|
|
}
|
|
}
|
|
// On lie l'événement resize à la fonction
|
|
window.addEventListener('resize', redimensionnement, false);
|
|
|
|
|
|
});
|