migrations

This commit is contained in:
2018-03-15 12:42:13 +01:00
parent 29e19deebc
commit 25001e38c9
419 changed files with 44849 additions and 2142 deletions

View File

@@ -1 +0,0 @@
window.transitionend = 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend';

View File

@@ -0,0 +1,43 @@
window.transitionend = 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend';
$(function() {
var $body = $('body');
window.enable_touch_swipe = function(selector, function_swipe_left, function_swipe_right) {
var touch_position_x = 0;
var delta = 0;
$body.on('touchstart', selector, function(event) {
touch_position_x = event.originalEvent.touches[0].pageX;
});
$body.on('touchmove', selector, function(event) {
delta = event.originalEvent.touches[0].pageX - touch_position_x;
});
$body.on('touchend', selector, function(event) {
var width_trigger = 50;
if (delta > width_trigger) {
function_swipe_left($(this))
} else if (delta < (width_trigger * -1)) {
function_swipe_right($(this));
}
delta = 0;
});
};
window.document_height = $(document).height();
window.window_height = $(window).height();
window.window_width = $(window).width();
window.scroll_top = $(window).scrollTop();
$(window).on('scroll', function(event) {
window.scroll_top = $(window).scrollTop();
});
$(window).on('resize', function(event) {
window.document_height = $(document).height();
window.window_height = $(window).height();
window.window_width = $(window).width();
});
});

View File

@@ -0,0 +1,59 @@
$(function() {
function create_reveal_elements($container) {
var $reveal_containers = $container.find('.reveal_container');
$reveal_containers.each(function() {
var reveal_container = this;
var elementWatcher = scrollMonitor.create(reveal_container);
elementWatcher.enterViewport(function() {
reveal_elements(reveal_container);
});
elementWatcher.fullyEnterViewport(function() {
reveal_elements(reveal_container);
});
});
var $reveal_selfs = $container.find('.reveal_self');
$reveal_selfs.each(function() {
var reveal_self = this;
var elementWatcher = scrollMonitor.create(reveal_self);
elementWatcher.enterViewport(function() {
reveal_element(reveal_self);
});
elementWatcher.fullyEnterViewport(function() {
reveal_element(reveal_self);
});
});
}
create_reveal_elements($('html'));
function remove_reveal_animation(event) {
if (event.target === this) {
$(this).removeClass('reveal_animation');
$(this).off(window.transitionend, remove_reveal_animation);
}
}
function reveal_elements(reveal_container) {
$(reveal_container).find('.reveal').each(function() {
reveal_element(this);
});
}
function reveal_element(element) {
window.requestAnimationFrame(function() {
$(element).on(window.transitionend, remove_reveal_animation);
$(element).removeClass('reveal');
});
}
window.create_reveal_elements = create_reveal_elements;
reveal_element($('.header'));
reveal_element($('.header__logo'));
reveal_elements($('.timetable__clock__frame'));
reveal_element($('.timetable__next'));
reveal_element($('.timetable__start__background'));
});

15
private/js/modules/animation.js Executable file
View File

@@ -0,0 +1,15 @@
$(function() {
var $body = $('body');
$body.find('.animated_icon').each(function() {
$(this).html('');
var animation_name = $(this).attr('data-icon');
var animation = bodymovin.loadAnimation({
container: this,
path: '/static/animation/' + animation_name + '.json',
renderer: 'svg',
loop: true,
autoplay: true
});
});
});

View File

@@ -0,0 +1,114 @@
function init_map() {
var location = {lat: 47.20388, lng: 8.58176};
var center;
if ($(window).width() > 840) {
center = {lat: location.lat, lng: location.lng + 0.06};
} else {
center = {lat: location.lat - 0.06, lng: location.lng};
}
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: center,
disableDefaultUI: true,
scrollwheel: false,
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
styles: [
{
"featureType": "administrative.neighborhood",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "labels.text",
"stylers": [
{
"visibility": "off"
}
]
}
]
});
var image = {
url: '/static/img/marker.png',
size: new google.maps.Size(50, 60),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(25, 60),
scaledSize: new google.maps.Size(50, 60)
};
var marker = new google.maps.Marker({
position: location,
map: map,
icon: image
});
var input = document.getElementById('journey_calculator__input');
if (input) {
var result = input.parentNode.querySelector('.journey_calculator__result');
var autocomplete = new google.maps.places.Autocomplete(input, {
types: ['geocode'],
componentRestrictions: {country: 'ch'}
}
);
var callback_timeout;
autocomplete.addListener('place_changed', function() {
input.parentNode.classList.remove('error');
input.parentNode.classList.add('loaded');
result.classList.add('loading');
var place = autocomplete.getPlace();
if (!place.geometry) {
input.blur();
input.parentNode.classList.add('error');
}
var origin = new google.maps.LatLng(place.geometry.location.lat(), place.geometry.location.lng());
var destination = new google.maps.LatLng(location);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin],
destinations: [destination],
travelMode: 'DRIVING'
}, callback);
function callback(response, status) {
window.clearTimeout(callback_timeout);
callback_timeout = window.setTimeout(function() {
var duration = response.rows[0].elements[0].duration.value;
var minutes = Math.round(duration / 60);
result.setAttribute('data-duration', minutes);
result.classList.remove('loading');
}, 300);
}
});
}
}

View File

@@ -0,0 +1,74 @@
$(function() {
var $body = $('body');
var $content_navigation = $('.content__navigation');
var $content = $('.content');
var content_navigation_class = 'content__navigation__anchor';
if ($content_navigation.length === 0) {
return false;
}
$content.find('.section').each(function() {
var $this = $(this);
var id = $this.attr('id');
var text = $this.find('h2').text();
var content_navigation_link = '<a class="' + content_navigation_class + '" href="#' + id + '">' + text + '</a>';
$content_navigation.find('ul').append('<li>' + content_navigation_link + '</li>');
$this.find('.section__title__content').html(text);
});
if (window.location.hash) {
var hash = window.location.hash;
window.requestAnimationFrame(function() {
window.location.hash = hash;
});
}
$body.on('click', '.' + content_navigation_class, function(event) {
event.preventDefault();
var $this = $(this);
$content_navigation.find('.active').removeClass('active');
$this.addClass('active');
TweenLite.to(window, 0.5, {
scrollTo: $this.attr('href')
});
});
var $navigation_watchers = $content.find('.section');
$navigation_watchers.each(function() {
var element = this;
var elementWatcher = scrollMonitor.create(element);
elementWatcher.fullyEnterViewport(function() {
$content_navigation.find('.active').removeClass('active');
$content_navigation.find('a[href="#' + $(element).attr('id') + '"]').addClass('active');
});
});
var content_navigation_offset_top = $content_navigation.offset().top;
$(window).on('resize', function() {
content_navigation_offset_top = $content_navigation.offset().top;
});
var $content_navigation_progress_fill = $('.content__navigation__progress__fill');
function content_navigation_scroll() {
var progress = Math.round(100 / window.document_height * (window.scroll_top + window.window_height));
$content_navigation_progress_fill.height(progress + '%');
if (content_navigation_offset_top && window.scroll_top >= content_navigation_offset_top) {
$content_navigation.addClass('fixed');
} else {
$content_navigation.removeClass('fixed');
}
}
function watch_content_navigation_scroll() {
if (!window.navigation_is_open) {
content_navigation_scroll();
}
window.requestAnimationFrame(watch_content_navigation_scroll);
}
watch_content_navigation_scroll();
});

View File

@@ -0,0 +1,69 @@
$(function() {
var $body = $('body');
var $canvas = $('#canvas');
var $navigation = $('#navigation');
window.onpageshow = function(event) {
if (event.persisted) {
window.location.reload();
}
};
$body.on('click', 'a', function(event) {
var href = $(this).attr('href');
var target = $(this).attr('target');
if (href.indexOf('/') === 0 && !target && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && !$('html').hasClass('cms-ready')) {
event.preventDefault();
$body.addClass('unload loading');
window.setTimeout(function() {
window.location = href;
}, 50);
}
});
$body.on('click', '.header__button--navigation', function(event) {
event.preventDefault();
open_navigation();
});
$body.on('click', '.navigation__close', function(event) {
event.preventDefault();
close_navigation();
});
var scroll_top = 0;
function open_navigation() {
window.timetable_can_scroll = false;
window.navigation_is_open = true;
$navigation.one(window.transitionend, function() {
window.requestAnimationFrame(function() {
$navigation.css('position', 'relative');
$navigation.off(window.transitionend);
});
});
window.requestAnimationFrame(function() {
scroll_top = $(window).scrollTop();
$canvas.css({
'top': scroll_top * -1,
'position': 'fixed'
});
window.requestAnimationFrame(function() {
$body.addClass('navigation_open');
});
});
}
function close_navigation() {
$navigation.removeAttr('style');
$body.removeClass('navigation_open');
window.requestAnimationFrame(function() {
$canvas.removeAttr('style');
$(window).scrollTop(scroll_top);
window.navigation_is_open = false;
window.timetable_can_scroll = true;
});
}
});

View File

@@ -0,0 +1,24 @@
$(function() {
var $body = $('body');
$body.on('submit', '.form', function(event) {
event.preventDefault();
var $form = $(this);
var id = $form.attr('id');
$form.addClass('loading');
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
success: function(data) {
var $new = $(data).find('#' + id);
$new.find('.reveal').each(function() {
$(this).removeClass('reveal reveal_animation');
});
$form.replaceWith($new);
}
});
});
});

View File

@@ -0,0 +1,29 @@
$(function() {
var $body = $('body');
$body.on('click', '.reference_list__item', function(event) {
event.preventDefault();
var $this = $(this);
var $reference_list = $this.parents('.reference_list');
var active = $reference_list.attr('data-active');
var id = $this.parents('.reference_list__item__frame').attr('data-id');
var iframe;
var player;
if (active) {
iframe = $reference_list.find('.reference_list__video__item.data_id_' + active).find('iframe').get(0);
player = new Vimeo.Player(iframe);
player.pause();
}
if (id === 'x') {
$reference_list.removeAttr('data-active');
} else {
$reference_list.attr('data-active', id);
iframe = $reference_list.find('.reference_list__video__item.data_id_' + id).find('iframe').get(0);
player = new Vimeo.Player(iframe);
player.play();
}
});
});

View File

@@ -0,0 +1,40 @@
$(function() {
var $body = $('body');
function slider_prev_item($slider) {
var active = parseInt($slider.attr('data-active'));
if (active > 0) {
window.requestAnimationFrame(function() {
$slider.attr('data-active', active - 1);
});
}
}
function slider_next_item($slider) {
var active = parseInt($slider.attr('data-active'));
var last = parseInt($slider.attr('data-last'));
if (active < last) {
window.requestAnimationFrame(function() {
$slider.attr('data-active', active + 1);
});
}
}
$body.on('click', '.slider__navigation', function(event) {
event.preventDefault();
var $this = $(this);
var $slider = $this.parents('.slider');
if ($slider.length === 0) {
$slider = $this.parents('.text_slider');
}
var prev = $this.hasClass('slider__navigation--prev');
if (prev) {
slider_prev_item($slider);
} else {
slider_next_item($slider);
}
});
window.enable_touch_swipe('.slider', slider_prev_item, slider_next_item);
window.enable_touch_swipe('.text_slider', slider_prev_item, slider_next_item);
});

View File

@@ -0,0 +1,144 @@
$(function() {
var $body = $('body');
var $timetable = $('#timetable');
if ($timetable.length === 0) {
return false;
}
$(window).scrollTop(0);
window.timetable_can_scroll = false;
window.setTimeout(function() {
window.timetable_can_scroll = true;
}, 2500);
var activated = false;
function test_scroll() {
if (activated) {
if ($(window).scrollTop() < $(window).height() * 0.05 && window.timetable_can_scroll) {
window.prevent_scroll_calc = true;
$timetable.attr('data-active', 0);
$timetable.removeClass('active');
activated = false;
}
} else {
if ($(window).scrollTop() > $(window).height() * 0.05 && window.timetable_can_scroll) {
init_timetable_items();
}
}
window.requestAnimationFrame(test_scroll);
}
function init_timetable_items() {
$timetable.attr('data-active', 1);
$timetable.find('.timetable__item').each(function() {
$(this).addClass('reveal_container')
});
window.setTimeout(function() {
$timetable.addClass('active');
window.requestAnimationFrame(function() {
$timetable.find('.timetable__item').each(function() {
var index = parseInt($(this).attr('data-id'));
var elementWatcher = scrollMonitor.create(this);
elementWatcher.enterViewport(function() {
set_timetable_item(index);
});
});
window.create_reveal_elements($timetable);
window.prevent_scroll_calc = false;
window.calc_scrolls();
activated = true;
});
}, 1500);
}
window.requestAnimationFrame(test_scroll);
var current_index = 0;
var last_index = parseInt($timetable.attr('data-last'));
var elements = document.getElementsByClassName('timetable__item');
var $timetable_next = $('.timetable__next');
var $timetable_clock_digital_time = $('#timetable__clock__digital__time');
var $timetable_progress = $('#timetable__clock__progress');
var timetable_clock_progress_max = parseFloat($timetable_progress.attr('stroke-dasharray'));
$body.on('click', '.timetable__next', function(event) {
event.preventDefault();
if (!activated) {
$(window).scrollTop($(window).height());
init_timetable_items();
}
});
// var handle_scroll = function(evt) {
// if (!can_scroll) {
// return false;
// }
// if (!evt) evt = event;
// var delta = event.wheelDelta;
// if (event.webkitDirectionInvertedFromDevice) delta = -delta;
// if (Math.abs(delta) > 20) {
// if (delta < 0) {
// prev_timetable_item();
// } else {
// next_timetable_item();
// }
// }
// };
// document.addEventListener('DOMMouseScroll', handle_scroll, false); // for Firefox
// document.addEventListener('mousewheel', handle_scroll, false);
function next_timetable_item() {
set_timetable_item(current_index + 1);
}
//
// function prev_timetable_item() {
// set_timetable_item(current_index - 1);
// }
//
function set_timetable_item(index) {
if (index <= last_index && index >= 0) {
current_index = index;
$timetable.attr('data-active', current_index);
if (current_index === last_index) {
$timetable_next.addClass('hidden');
} else {
$timetable_next.removeClass('hidden');
}
update_time_progess();
}
}
function update_time_progess() {
var $to = $(elements[current_index - 1]);
var to_minutes = parseInt($to.attr('data-hour')) * 60 + parseInt($to.attr('data-minute'));
var to_minutes_with_offset = to_minutes - (6 * 60);
var total_progress = (1 / (12 * 60)) * to_minutes_with_offset;
var start = $timetable_clock_digital_time.text();
var start_time = start.split(':');
var start_minutes = parseInt(start_time[0]) * 60 + parseInt(start_time[1]);
var count_up = new CountUp('timetable__clock__digital__time', start_minutes, to_minutes, 0, 1.5, {
useEasing: true,
separator: ''
});
count_up.start();
if (to_minutes) {
$timetable_progress.attr('stroke-dashoffset', timetable_clock_progress_max * Math.abs(total_progress - 1));
}
}
});

View File

@@ -0,0 +1,40 @@
$(function() {
var $body = $('body');
$body.find('.video').each(function() {
var $video = $(this);
var iframe = this.querySelector('iframe');
var player = new Vimeo.Player(iframe);
var is_playing = false;
$video.on('click', '.video__thumbnail', function(event) {
event.preventDefault();
if (is_playing) {
player.pause();
} else {
player.play();
}
});
player.on('play', function() {
is_playing = true;
window.requestAnimationFrame(function() {
$video.addClass('playing');
});
});
player.on('pause', function() {
is_playing = false;
window.requestAnimationFrame(function() {
$video.removeClass('playing');
});
});
player.on('ended', function() {
is_playing = false;
window.requestAnimationFrame(function() {
$video.removeClass('playing');
});
});
});
});

View File

@@ -0,0 +1,102 @@
$(function() {
var scrolls = [];
window.prevent_scroll_calc = false;
var $timetable = $('#timetable');
if ($timetable.length > 0) {
window.prevent_scroll_calc = true;
}
function calc_scrolls() {
scrolls = [];
var i;
var scroll_elements = document.querySelectorAll('.scroll');
for (i = 0; i < scroll_elements.length; i++) {
var element = scroll_elements[i];
var height = element.offsetHeight;
var offset_top = $(element).offset().top;
var center_offset = offset_top + (height / 2);
var ease_multiplier = parseFloat(element.getAttribute('data-ease-multiplier'));
if (!ease_multiplier) {
ease_multiplier = 1;
}
scrolls.push({
offset: center_offset,
element: element,
mod: element.getAttribute('data-scroll-mod'),
ease_multiplier: ease_multiplier
});
}
}
if (!window.prevent_scroll_calc) {
calc_scrolls();
}
window.calc_scrolls = calc_scrolls;
var scroll_top = 0;
function change_scrolls() {
// if (window.is_scroll_animating) {
// return false;
// }
var window_height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var half_window_height = window_height / 2;
var window_scroll_top = document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop;
scroll_top = window_scroll_top + half_window_height;
for (var i = 0; i < scrolls.length; i++) {
var item = scrolls[i];
var relative_offset = item.offset - scroll_top;
relative_offset = relative_offset * 0.05;
var css_value = 'translateY';
var css_unit = 'px';
var appling_offset = relative_offset * item.ease_multiplier;
if (item.mod === 'rotate') {
css_value = 'rotate';
css_unit = 'deg';
}
if (item.mod === 'horizontal') {
css_value = 'translateX';
}
item.element.style.transform = "" +
css_value + "(" + appling_offset + css_unit + ")";
item.element.style.webkitTransform = "" +
css_value + "(" + appling_offset + css_unit + ")";
item.element.style.MozTransform = "" +
css_value + "(" + appling_offset + css_unit + ")";
item.element.style.msTransform = "" +
css_value + "(" + appling_offset + css_unit + ")";
item.element.style.OTransform = "" +
css_value + "(" + appling_offset + css_unit + ")";
}
}
function watch_scrolls() {
if (!window.navigation_is_open) {
change_scrolls();
}
window.requestAnimationFrame(watch_scrolls);
}
window.requestAnimationFrame(watch_scrolls);
var resize_window_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
window.addEventListener('resize', function(event) {
var window_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
if (document.querySelector('html').classList.contains('touchevents') && resize_window_width === window_width) {
return false;
}
resize_window_width = window_width;
if (!window.prevent_scroll_calc) {
calc_scrolls();
}
window.requestAnimationFrame(function() {
change_scrolls();
});
}, false);
});

View File

@@ -0,0 +1,83 @@
$(function() {
var $body = $('body');
var $canvas = $('#canvas');
$body.on('click', '.header__button--search', function(event) {
event.preventDefault();
open_search();
});
$body.on('click', '.search__close', function(event) {
if (!$body.hasClass('_search') && !$body.hasClass('search_results')) {
event.preventDefault();
close_search();
}
});
var scroll_top = 0;
var search_input_timeout;
function open_search() {
window.timetable_can_scroll = false;
window.navigation_is_open = true;
window.requestAnimationFrame(function() {
scroll_top = $(window).scrollTop();
$canvas.css({
'top': scroll_top * -1,
'position': 'fixed'
});
window.requestAnimationFrame(function() {
$body.addClass('search_open');
window.clearTimeout(search_input_timeout);
search_input_timeout = window.setTimeout(function() {
$body.find('#search__query').focus();
}, 800);
});
});
}
function close_search() {
window.clearTimeout(search_input_timeout);
$body.find('#search__query').blur();
window.requestAnimationFrame(function() {
$body.removeClass('search_open');
$canvas.removeAttr('style');
$(window).scrollTop(scroll_top);
window.navigation_is_open = false;
window.timetable_can_scroll = true;
});
}
$body.on('submit', '.search__form', function(event) {
event.preventDefault();
var $form = $(this);
$body.find('#search__query').blur();
var form_url = $form.attr('action');
var serialized_form = $form.serialize();
history.pushState({}, 'search', form_url + '?' + serialized_form);
if (serialized_form !== 'q=') {
if ($body.hasClass('search_results')) {
$body.find('.search__results').addClass('loading');
}
$.ajax({
type: $form.attr('method'),
url: form_url,
data: serialized_form,
success: function(data) {
$body.find('#canvas').remove();
$body.addClass('_search');
$body.find('.search__results').replaceWith($(data).find('.search__results'));
window.requestAnimationFrame(function() {
$body.addClass('search_results');
})
}
});
} else {
$body.removeClass('search_results');
}
});
});