This commit is contained in:
Loïc Guibert
2022-09-30 20:06:40 +01:00
commit 0637652909
47 changed files with 10294 additions and 0 deletions

50
js/index.js Normal file
View File

@@ -0,0 +1,50 @@
/**
* Main JS file for Casper behaviours
*/
/*globals jQuery, document */
(function ($) {
"use strict";
$(document).ready(function(){
$(".post-content").fitVids();
// Creates Captions from Alt tags
$(".post-content img").each(function() {
// Let's put a caption if there is one
if($(this).attr("alt"))
$(this).wrap('<figure class="image"></figure>')
.after('<figcaption>'+$(this).attr("alt")+'</figcaption>');
});
var $window = $(window),
$image = $('.post-image-image, .teaserimage-image');
$window.on('scroll', function() {
var top = $window.scrollTop();
if (top < 0 || top > 1500) { return; }
$image
.css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
.css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');
var height = $('.article-image').height();
$('.post-content').css('padding-top', height + 'px');
$('a[href*=\\#]:not([href=\\#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({ scrollTop: target.offset().top }, 500);
return false;
}
}
});
});
}(jQuery));