script.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. if($('body').is('.front')){
  51. var anchor = $('a.anchor.publie', "#thematique-anchor-links").last().attr('href');
  52. console.log(anchor);
  53. (function(anchor){
  54. setTimeout(function(){
  55. console.log('Timeout');
  56. window.location.href = anchor;
  57. }, 1000);
  58. })(anchor);
  59. }
  60. };
  61. init();
  62. })(jQuery);