gcg-website/assets/js/script.js

139 lines
4.3 KiB
JavaScript
Raw Normal View History

2024-01-21 14:18:25 +01:00
(($) => {
2022-03-18 13:35:57 +01:00
'use strict';
2023-04-23 14:14:40 +02:00
// adapt header to height
2023-02-09 12:29:38 +01:00
function adaptHeight () {
var height = $('.top-header').innerHeight();
2023-02-01 20:24:20 +01:00
if ($('header').offset().top > 10) {
$('.top-header').addClass('hide');
$('.navigation').addClass('nav-bg');
$('.navigation').css('margin-top','-'+height+'px');
} else {
$('.top-header').removeClass('hide');
2023-02-09 12:29:38 +01:00
if ( !$('#top-banner').length) {
2023-02-01 20:24:20 +01:00
$('.navigation').removeClass('nav-bg');
}
$('.navigation').css('margin-top','-'+0+'px');
}
2023-02-09 12:29:38 +01:00
}
2023-04-23 14:14:40 +02:00
// load scripts
2024-01-26 09:22:35 +01:00
$(window).on('load', function() {
2023-02-09 12:29:38 +01:00
$('.preloader').fadeOut(100);
adaptHeight();
2023-02-01 20:24:20 +01:00
if ($('#top-banner').length) {
$('.navigation').addClass('nav-bg');
$('.hero-section').addClass('hs-banner');
$('.page-title-section').addClass('pts-banner');
} else {
$('.hero-section').removeClass('hs-banner');
$('.page-title-section').removeClass('pts-banner');
}
2022-03-18 13:35:57 +01:00
});
2023-04-23 14:14:40 +02:00
// sticky menu
2023-02-09 12:29:38 +01:00
$(window).scroll(adaptHeight);
2022-03-18 13:35:57 +01:00
2023-04-23 14:14:40 +02:00
// hero slider
$('.hero-slider').slick({
2022-03-18 13:35:57 +01:00
autoplay: true,
2023-02-01 20:24:20 +01:00
autoplaySpeed: 5000,
2022-03-18 13:35:57 +01:00
pauseOnFocus: false,
2023-04-04 15:28:15 +02:00
pauseOnHover: true,
2022-03-18 13:35:57 +01:00
infinite: true,
arrows: true,
2024-01-20 20:09:43 +01:00
prevArrow: '<button type=\'button\' class=\'prevArrow\'><svg xmlns="http://www.w3.org/2000/svg" id="mdi-chevron-left" class="arrowIcon" viewBox="0 0 24 24" height="1em" width="1em" fill="currentColor"><path d="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z" /></svg></button>',
nextArrow: '<button type=\'button\' class=\'nextArrow\'><svg xmlns="http://www.w3.org/2000/svg" id="mdi-chevron-left" class="arrowIcon" viewBox="0 0 24 24" height="1em" width="1em" fill="currentColor"><path xmlns="http://www.w3.org/2000/svg" d="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"/></svg></button>',
2022-03-18 13:35:57 +01:00
dots: true
});
// venobox popup
2024-01-26 09:22:35 +01:00
$(document).ready(function() {
2024-02-04 22:55:35 +01:00
new VenoBox({
selector: '.vb-video',
spinner: 'grid'
});
new VenoBox({
selector: '.vb-gallery',
numeration: true,
infinigall: true,
share: true,
shareStyle: 'block',
2024-02-04 23:04:45 +01:00
spinner: 'grid',
fitView: true,
navTouch: true,
});
2022-03-18 13:35:57 +01:00
});
// filter
2024-01-26 09:22:35 +01:00
$(document).ready(function() {
2024-01-21 14:18:25 +01:00
if ($('.filter-container').length != 0) {
const shuffleInstance = new Shuffle($('.filter-container'), {
itemSelector: '.filter-item',
sizer: '.filter-sizer',
delimiter: ','
});
2024-01-26 09:22:35 +01:00
$('.filter-controls li').on('click', function() {
2024-01-21 14:18:25 +01:00
$('.filter-controls li').removeClass('active');
$(this).addClass('active');
shuffleInstance.filter($(this).data('filter'))
});
}
2022-03-18 13:35:57 +01:00
});
2024-01-21 14:18:25 +01:00
// counter
2024-01-26 09:22:35 +01:00
$(window).on('scroll', function() {
2022-03-18 13:35:57 +01:00
var oTop;
if ($('.count').length !== 0) {
oTop = $('.count').offset().top - window.innerHeight;
}
if ($(window).scrollTop() > oTop) {
2024-01-26 09:22:35 +01:00
$('.count').each(function() {
2024-01-21 14:18:25 +01:00
var $this = $(this), countTo = $this.attr('data-count');
$({ countNum: $this.text() }).animate(
{ countNum: countTo },
{
duration: 1000,
easing: 'swing',
2024-01-26 09:22:35 +01:00
step: function() { return $this.text(Math.floor(this.countNum)) },
complete: function() { return $this.text(this.countNum) },
2024-01-21 14:18:25 +01:00
});
2022-03-18 13:35:57 +01:00
});
}
});
2024-01-21 14:18:25 +01:00
2024-01-26 09:22:35 +01:00
$(window).on('DOMContentLoaded', function() {
2024-01-21 14:18:25 +01:00
if (window.PagefindUI != undefined) {
new window.PagefindUI({
element: "#search",
translations: {
placeholder: "Suchen...",
zero_results: "Leider konnten keine Ergebnisse zu [SEARCH_TERM] gefunden werden",
clear_search: "Löschen"
}
});
2024-01-26 09:22:35 +01:00
$('#pagefind-search').on('shown.bs.modal', function() {
2024-01-21 14:18:25 +01:00
$('.pagefind-ui__search-input').focus();
});
}
});
// enable matomo analytics
var _paq = window._paq = window._paq || [];
_paq.push(["setDoNotTrack", true]);
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
2024-01-26 09:22:35 +01:00
(function() {
2024-01-21 14:18:25 +01:00
var u="https://analytics.cantorgymnasium.de/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
new LazyLoad();
2023-04-04 15:28:15 +02:00
2022-03-18 13:35:57 +01:00
})(jQuery);