script.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. (function($) {
  2. Drupal.behaviors.init_theme = function (context) {
  3. // Growl-style system messages
  4. $('#messages-and-help > div.messages:not(.processed)')
  5. .addClass('processed')
  6. .each(function() {
  7. // If a message meets these criteria, we don't autoclose
  8. // - contains a link
  9. // - is an error or warning
  10. // - contains a lenghthy amount of text
  11. if ($('a', this).size() || $(this).is('.error') || $(this).is('.warning') || $(this).text().length > 100) {
  12. $(this).prepend("<span class='close'>X</span>");
  13. $('span.close', this).click(function() {
  14. $(this).parent().slideUp('fast');
  15. });
  16. }
  17. else {
  18. // This essentially adds a 3 second pause before hiding the message.
  19. $(this).animate({opacity:1}, 5000, 'linear', function() {
  20. $(this).slideUp('fast');
  21. });
  22. }
  23. });
  24. };
  25. function init(){
  26. console.log('Clameurs Theme');
  27. initHeaderAnime();
  28. initAutoScroll();
  29. };
  30. function initHeaderAnime(){
  31. var $header = $('#header a'),
  32. header_height = $header.height(),
  33. $slogan = $('#header h2'),
  34. fontsize = parseInt($slogan.css('font-size')), tmpfs,
  35. scrolltop, limit = 300;
  36. console.log('font-size', fontsize);
  37. $(window).on('scroll', function(event) {
  38. scrolltop = limit - $(this).scrollTop() * .5;
  39. scrolltop = Math.max(limit*0.35,scrolltop);
  40. // console.log('scrolltop', scrolltop);
  41. alpha = scrolltop/limit;
  42. console.log('scrolltop '+scrolltop+' | allpha '+alpha);
  43. $header.height(header_height*alpha);
  44. tmpfs = fontsize*alpha;
  45. $slogan.css('font-size', tmpfs+"px");
  46. });
  47. };
  48. function initAutoScroll(){
  49. console.log('initAutoScroll');
  50. var anchor = $('a.anchor.publie', "#thematique-anchor-links").last().attr('href');
  51. console.log(anchor);
  52. (function(anchor){
  53. setTimeout(function(){
  54. console.log('Timeout');
  55. window.location.href = anchor;
  56. }, 1000);
  57. })(anchor);
  58. };
  59. init();
  60. })(jQuery);