From 5bd36c66a366b67ddd34f1613759a6a0b1f6e7d0 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Sun, 9 Apr 2017 12:11:42 +0200 Subject: [PATCH] fixe autoscroll bug, limit behaviour to front page --- .../clameurs/js/dist/script.min.js | 2 +- .../figureslibres/clameurs/js/script.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sites/all/themes/figureslibres/clameurs/js/dist/script.min.js b/sites/all/themes/figureslibres/clameurs/js/dist/script.min.js index 37fcc1ca..84744019 100755 --- a/sites/all/themes/figureslibres/clameurs/js/dist/script.min.js +++ b/sites/all/themes/figureslibres/clameurs/js/dist/script.min.js @@ -1,3 +1,3 @@ (function($){Drupal.behaviors.init_theme=function(context){$('#messages-and-help > div.messages:not(.processed)').addClass('processed').each(function(){if($('a',this).size()||$(this).is('.error')||$(this).is('.warning')||$(this).text().length>100){$(this).prepend("X");$('span.close',this).click(function(){$(this).parent().slideUp('fast');});} -else{$(this).animate({opacity:1},5000,'linear',function(){$(this).slideUp('fast');});}});};function init(){console.log('Clameurs Theme');initHeaderAnime();initAutoScroll();};function initHeaderAnime(){var $header=$('#header a'),header_height=$header.height(),$slogan=$('#header h2'),fontsize=parseInt($slogan.css('font-size')),tmpfs,scrolltop,limit=300;console.log('font-size',fontsize);$(window).on('scroll',function(event){scrolltop=limit-$(this).scrollTop()*.5;scrolltop=Math.max(limit*0.35,scrolltop);alpha=scrolltop/limit;console.log('scrolltop '+scrolltop+' | allpha '+alpha);$header.height(header_height*alpha);tmpfs=fontsize*alpha;$slogan.css('font-size',tmpfs+"px");});};function initAutoScroll(){console.log('initAutoScroll');var anchor=$('a.anchor.publie',"#thematique-anchor-links").last().attr('href');console.log(anchor);(function(anchor){setTimeout(function(){console.log('Timeout');window.location.href=anchor;},1000);})(anchor);};init();})(jQuery); \ No newline at end of file +else{$(this).animate({opacity:1},5000,'linear',function(){$(this).slideUp('fast');});}});};function init(){console.log('Clameurs Theme');initHeaderAnime();initAutoScroll();};function initHeaderAnime(){var $header=$('#header a'),header_height=$header.height(),$slogan=$('#header h2'),fontsize=parseInt($slogan.css('font-size')),tmpfs,scrolltop,limit=300;console.log('font-size',fontsize);$(window).on('scroll',function(event){scrolltop=limit-$(this).scrollTop()*.5;scrolltop=Math.max(limit*0.35,scrolltop);alpha=scrolltop/limit;console.log('scrolltop '+scrolltop+' | allpha '+alpha);$header.height(header_height*alpha);tmpfs=fontsize*alpha;$slogan.css('font-size',tmpfs+"px");});};function initAutoScroll(){console.log('initAutoScroll');if($('body').is('.front')){var anchor=$('a.anchor.publie',"#thematique-anchor-links").last().attr('href');console.log(anchor);(function(anchor){setTimeout(function(){console.log('Timeout');window.location.href=anchor;},1000);})(anchor);}};init();})(jQuery); \ No newline at end of file diff --git a/sites/all/themes/figureslibres/clameurs/js/script.js b/sites/all/themes/figureslibres/clameurs/js/script.js index fd956568..051be39e 100755 --- a/sites/all/themes/figureslibres/clameurs/js/script.js +++ b/sites/all/themes/figureslibres/clameurs/js/script.js @@ -56,15 +56,16 @@ function initAutoScroll(){ console.log('initAutoScroll'); - var anchor = $('a.anchor.publie', "#thematique-anchor-links").last().attr('href'); - console.log(anchor); - (function(anchor){ - setTimeout(function(){ - console.log('Timeout'); - window.location.href = anchor; - }, 1000); - })(anchor); - + if($('body').is('.front')){ + var anchor = $('a.anchor.publie', "#thematique-anchor-links").last().attr('href'); + console.log(anchor); + (function(anchor){ + setTimeout(function(){ + console.log('Timeout'); + window.location.href = anchor; + }, 1000); + })(anchor); + } }; init();