Files
Clameurs/sites/all/themes/figureslibres/clameurs/js/script.js
T

59 lines
1.7 KiB
JavaScript
Executable File

(function($) {
Drupal.behaviors.init_theme = function (context) {
// Growl-style system messages
$('#messages-and-help > div.messages:not(.processed)')
.addClass('processed')
.each(function() {
// If a message meets these criteria, we don't autoclose
// - contains a link
// - is an error or warning
// - contains a lenghthy amount of text
if ($('a', this).size() || $(this).is('.error') || $(this).is('.warning') || $(this).text().length > 100) {
$(this).prepend("<span class='close'>X</span>");
$('span.close', this).click(function() {
$(this).parent().slideUp('fast');
});
}
else {
// This essentially adds a 3 second pause before hiding the message.
$(this).animate({opacity:1}, 5000, 'linear', function() {
$(this).slideUp('fast');
});
}
});
};
function init(){
console.log('Clameurs Theme');
initHeaderAnime();
};
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);
// console.log('scrolltop', scrolltop);
alpha = scrolltop/limit;
console.log('scrolltop '+scrolltop+' | allpha '+alpha);
$header.height(header_height*alpha);
tmpfs = fontsize*alpha;
$slogan.css('font-size', tmpfs+"px");
});
};
init();
})(jQuery);