script.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. };
  29. function initHeaderAnime(){
  30. var $header = $('#header a'),
  31. header_height = $header.height(),
  32. $slogan = $('#header h2'),
  33. fontsize = parseInt($slogan.css('font-size')), tmpfs,
  34. scrolltop, limit = 300;
  35. console.log('font-size', fontsize);
  36. $(window).on('scroll', function(event) {
  37. scrolltop = limit - $(this).scrollTop() * .5;
  38. scrolltop = Math.max(limit*0.35,scrolltop);
  39. // console.log('scrolltop', scrolltop);
  40. alpha = scrolltop/limit;
  41. console.log('scrolltop '+scrolltop+' | allpha '+alpha);
  42. $header.height(header_height*alpha);
  43. tmpfs = fontsize*alpha;
  44. $slogan.css('font-size', tmpfs+"px");
  45. });
  46. };
  47. init();
  48. })(jQuery);