navigation frame

This commit is contained in:
2018-03-15 19:32:03 +01:00
parent 2a6091ee3f
commit eaa888cfa5
17 changed files with 410 additions and 188 deletions

View File

@@ -12,7 +12,8 @@ $(function() {
$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')) {
var is_event = $(this).hasClass('event');
if (href.indexOf('/') === 0 && !target && !is_event && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && !$('html').hasClass('cms-ready')) {
event.preventDefault();
$body.addClass('unload loading');
window.setTimeout(function() {
@@ -22,13 +23,21 @@ $(function() {
});
$body.on('click', '.header__button--navigation', function(event) {
event.preventDefault();
open_navigation();
});
$body.on('click', '.navigation__close', function(event) {
event.preventDefault();
close_navigation();
if ($body.hasClass('search_open')) {
if (!$body.hasClass('_search') && !$body.hasClass('search_results')) {
event.preventDefault();
window.close_search();
} else {
$(this).removeClass('event');
$(this).click();
}
} else if ($body.hasClass('navigation_open')) {
event.preventDefault();
close_navigation();
} else {
event.preventDefault();
open_navigation();
}
});
var scroll_top = 0;

View File

@@ -16,19 +16,22 @@ $(function() {
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();
if (!window.navigation_is_open) {
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() {

View File

@@ -7,13 +7,6 @@ $(function() {
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;
@@ -47,6 +40,7 @@ $(function() {
window.timetable_can_scroll = true;
});
}
window.close_search = close_search;
$body.on('submit', '.search__form', function(event) {
event.preventDefault();
@@ -59,9 +53,8 @@ $(function() {
history.pushState({}, 'search', form_url + '?' + serialized_form);
if (serialized_form !== 'q=') {
if ($body.hasClass('search_results')) {
$body.find('.search__results').addClass('loading');
}
var $search_content_main = $body.find('.search__content__main');
$search_content_main.addClass('loading');
$.ajax({
type: $form.attr('method'),
@@ -70,6 +63,7 @@ $(function() {
success: function(data) {
$body.find('#canvas').remove();
$body.addClass('_search');
$search_content_main.removeClass('loading');
$body.find('.search__results').replaceWith($(data).find('.search__results'));
window.requestAnimationFrame(function() {
$body.addClass('search_results');