$(document).ready(function(){
document.documentElement.className += " has-js";
if (window !== window.parent) document.documentElement.className += " iframed";
/* ====== E-Mail Defuscate 2.0 ===== */
var realEmail = $('.rewrite').text().replace(" 'at' ", "@").replace(" 'punkt' ", "."); // Kodierte E-Mail Adresse in echte E-Mail Adresse umwandeln
$('.rewrite').replaceWith( '' + realEmail + '' ); // Kodierte E-Mail Adresse durch echte E-Mail Adresse ersetzen
/* ====== Accordion ===== */
/* Akkordeons visuell zu Akkordeons machen */
$('.no-accordion').removeClass('no-accordion').addClass('accordion');
/* Alle Accordions via Script initial schließen */
$('.acc-item .title').addClass('closed');
$('.acc-item .acc-content').hide();
$('.acc-item .title').click(function(){
if($(this).hasClass('closed')) {
thehash = '#' + $(this).find('h3').attr('id');
// Attribut als + in Url übergeben mittels History API, da ansonsten beim Klick direct zum Hash gesprungen wird
if(history.pushState) {
history.pushState(null, null, thehash);
}
else {
location.hash = thehash; // Fallback für ältere Browser
}
$( '.acc-item .title' ).each(function( index ) {
// Funktion welche offene Accordeons zuklappt
/*
if ($(this).hasClass("open")) {
$(this).addClass('closed').removeClass('open');
$(this).siblings('.acc-content').slideUp(200);
}
*/
});
$(this).addClass('open').removeClass('closed');
$(this).siblings('.acc-content').slideDown(200);
} else {
history.pushState("", document.title, window.location.pathname + window.location.search); // Hash wieder entfernen beim Schließen
$(this).addClass('closed').removeClass('open');
$(this).siblings('.acc-content').slideUp(200);
}
});
/* Sprungmarken auf Akkordeons setzen */
$( ".acc-item h3" ).each( function() {
/* Text der Überschrift in Variable speichern */
var value = $( this ).text();
value = value.toLowerCase();
/* Variable von Leerzeichen und ungewünschten Sonderzeichen befreien */
value = value.replace(/ /g, "-");
value = value.replace("(", "");
value = value.replace(")", "");
value = value.replace(/\?/g, "");
value = value.replace(/\!/g, "");
value = value.replace(/\,/g, "");
value = value.replace(/\./g, "");
value = value.replace(/\–/g, "");
value = value.replace("----", "-");
value = value.replace("---", "-");
value = value.replace("--", "-");
value = value.replace(/ä/g, "ae");
value = value.replace(/ü/g, "ue");
value = value.replace(/ö/g, "oe");
value = value.replace(/ß/g, "ss");
// Inhalt der Überschrift als Anker setzen
$(this).attr('id', value);
});
/* Beim Seitenaufruf wenn ein Hash in der URL ist, entsprechendes Akkordeon öffnen */
function handleAccordion() {
if(window.location.hash && location.hash != "#alerts") {
/* Hole Hash aus URL ab */
hashvalue = window.location.hash.substr(1);
/* Hash Jump des Browsers deaktivieren */
/* setTimeout(function() {
window.scrollTo(0, 0);
}, 1); */
/* Entsprechendes FAQ Element aufklappen */
$('h3#' + hashvalue).parent().addClass('open').removeClass('closed').siblings('.acc-content').slideDown(200);
}
}
handleAccordion();
/* Hash Links innerhalb von Accordeons fixen */
$('.acc-content a[href*="#"]').click(function(event){
if ($(this).parents().siblings().hasClass("open")) {
$('.title.open').siblings('.acc-content').hide();
$('.title.open').addClass('closed').removeClass('open');
}
$(window).on('hashchange',function(){
handleAccordion();
});
});
/* ====== Slider Swiper ===== */
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'horizontal',
loop: true,
grabCursor: true,
paginationClickable: true,
// If we need pagination
pagination: '.swiper-pagination',
// Navigation arrows
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
keyboardControl: true,
// setWrapperSize: true,
autoHeight: true
})
/* ====== Clickable box ===== */
$(".clickbox").each(function() {
var thisClickbox = $(this),
link = $("a:first", thisClickbox);
// kein Link vorhanden, dann clickbox nicht aktivieren
if (!link.length) return;
thisClickbox.bind("click", function(e) {
// Klick-Ziel herausfinden
var target;
if (!e) var e = window.event;
if (e.target) target = e.target;
else if (e.srcElement) target = e.srcElement;
if (target.nodeType == 3) // defeat Safari bug
target = target.parentNode;
//console.log(".clickbox => clicked target:", target);
// wenn das Klick-Ziel der Link selbst (oder ein Element innerhalb des Links) ist,
// dann abbrechen, da der click-Befehl schon getriggert wurde und es sonst eine
// rekursive Endlos-Schleife geben würde
while (target) {
if (target == link.get(0)) {
// der Link wurde geklickt oder ein click-Event getriggert
// im letzteren Fall MUSS manuell auf die nächste Seite weitergeleitet werden
// eine ggf. dazwischengreifende colorbox würde einen click auf den Link nicht bubbeln lassen
// deswegen kann man hier ruhigen Gewissens auf die neue URL weiterleiten
window.location.href = target.href;
return true;
}
target = target.parentNode;
if (target == this) break;
}
//console.log(".clickbox => trigger click on:", link);
// trigger Klick-Event auf dem eigentlichen Link
link.trigger("click");
}).hover(function() {
$(this).addClass("hover");
}, function() {
$(this).removeClass("hover");
});
});
/* ====== ImageLightbox ===== */
var activityIndicatorOn = function() {
$('
').appendTo("body");
};
var activityIndicatorOff = function() {
$("#imagelightbox-loading").remove();
};
var overlayOn = function() {
$('').appendTo("body");
};
var overlayOff = function() {
$("#imagelightbox-overlay").remove();
};
var closeButtonOn = function(t) {
$('').appendTo("body").on("click touchend", function() {
return $(this).remove(), t.quitImageLightbox(), !1;
})
};
var closeButtonOff = function() {
$("#imagelightbox-close").remove();
};
var captionOn = function() {
var t = $.trim($('a[href="' + $("#imagelightbox").attr("src") + '"] img').attr("alt") || '');
t.length > 0 && $('
' + t + "
").appendTo("body");
};
var captionOff = function() {
$("#imagelightbox-caption").remove();
};
var navigationOn = function(t, i) {
var o = $(i);
if (o.length) {
for (var n = $(''), e = 0; e < o.length; e++) n.append('');
n.appendTo("body"), n.on("click touchend", function() {
return !1;
});
var a = n.find("button");
a.on("click touchend", function() {
var i = $(this);
return o.eq(i.index()).attr("href") != $("#imagelightbox").attr("src") && t.switchImageLightbox(i.index()), a.removeClass("active"), a.eq(i.index()).addClass("active"), !1;
}).on("touchend", function() {
return !1;
})
}
};
var navigationUpdate = function(t) {
var i = $("#imagelightbox-nav button");
i.removeClass("active"), i.eq($(t).filter('[href="' + $("#imagelightbox").attr("src") + '"]').index(t)).addClass("active");
};
var navigationOff = function() {
$("#imagelightbox-nav").remove();
};
var arrowsOn = function(t, i) {
// TR 2015-07-17: Only show arrows if there are more than one item within the currrent group
var $elements = $(i);
if ($elements.size() > 1) {
var o = $('');
o.appendTo("body"), o.on("click touchend", function(o) {
o.preventDefault();
var n = $(this),
e = $(i + '[href="' + $("#imagelightbox").attr("src") + '"]'),
a = e.index(i);
return n.hasClass("imagelightbox-arrow-left") ? (a -= 1, $(i).eq(a).length || (a = $(i).length)) : (a += 1, $(i).eq(a).length || (a = 0)), t.switchImageLightbox(a), !1;
})
}
};
var arrowsOff = function() {
$(".imagelightbox-arrow").remove();
};
var unique = function(array) {
return $.grep(array, function(item, index) {
return index === $.inArray(item, array);
});
};
// TR 2015-07-17: Cheap hack to implement grouping
var groups = unique($('a.imagelightbox').map(function(index) {
var $this = $(this);
var rel = $this.attr('rel') || '';
if (rel.length === 0) {
rel = 'groupless' + index;
$this.attr('rel', rel);
}
return rel;
}));
$.each(groups, function(index, group) {
var selector = 'a.imagelightbox[rel="' + group + '"]';
var instance = $(selector).imageLightbox({
allowedTypes: 'png|jpg|jpeg|gif|svg',
onStart: function() {
overlayOn();
closeButtonOn(instance);
arrowsOn(instance, selector);
},
onEnd: function() {
overlayOff();
captionOff();
closeButtonOff();
arrowsOff();
activityIndicatorOff();
},
onLoadStart: function() {
captionOff();
activityIndicatorOn();
},
onLoadEnd: function() {
captionOn();
activityIndicatorOff();
$('.imagelightbox-arrow').css('display', 'block');
},
});
});
$(window).scroll(function() {
if ($(this).scrollTop() > 260){
$('header').addClass("sticky");
}
else{
$('header').removeClass("sticky");
}
});
/* ====== Scroll Animation ===== */
//$('article > section:not(:first-of-type)').animate({'opacity':'.2'},0);
// $('article img').addClass('shrink');
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('article > section').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight() * 0.25;
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object && $(this).css('opacity') != 1){
$(this).animate({'opacity':'1'},500);
//console.log(' section fade in');
}
});
/* Check the location of each desired element */
$('article img').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object && $(this).hasClass("shrink")){
$(this).removeClass('shrink');
//console.log(' section fade in');
}
});
});
/* ====== Hook Für Lity welcher nach öffnen der Lightbox eine Klasse an den Body innerhalb des iFrames hängt über den dann Inhalte wie Header und Footer ausgeblendet werden ===== */
$(document).on('lity:ready', function(event, instance) {
$("iframe").hide();
$("iframe").load(function() {
$("iframe").contents().find("html").addClass("withinLity");
$("iframe").fadeIn();
});
});
/* ====== Mmenu ===== */
/* ====== Desktop Dropdown auf Klick ===== */
$(window).click(function() {
$('nav.mainnav ul li.dropdown-arrow').removeClass('active');
$('article').removeClass('blurred');
$('section.content').removeClass('blurred');
$('.keyvisual').removeClass('blurred');
});
$('nav.mainnav').click(function(event){
//event.stopPropagation();
});
// Pfeilchen für Dropdown anhängen
$( "nav.mainnav ul li.dropdown-arrow > a" ).after('');
$( "nav.mainnav ul li.dropdown-arrow .arrow" ).on('click', function(event) {
// event.preventDefault();
// event.stopPropagation();
if($(this).parent().hasClass('active') ) {
$('article').removeClass('blurred');
$('section.content').removeClass('blurred');
$('.keyvisual').removeClass('blurred');
} else {
$('article').addClass('blurred');
$('section.content').addClass('blurred');
$('.keyvisual').addClass('blurred');
}
$(this).parent().siblings().removeClass('active');
$(this).parent().toggleClass('active');
});
// Escape abfangen
$(document).keyup(function(e) {
if (e.keyCode === 27) $('nav.mainnav ul li.dropdown-arrow').removeClass('active'); // esc
if (e.keyCode === 27) $('article').removeClass('blurred'); // esc
if (e.keyCode === 27) $('section.content').removeClass('blurred'); // esc
if (e.keyCode === 27) $('.keyvisual').removeClass('blurred'); // esc
});
$(".confirm-external").submit(function(e){
if (!this.reportValidity || !this.reportValidity()) return;
if (window !== window.parent) {
window.open($("input[name='url']", this).val(), '_blank');
// TODO: iframe/overlay schließen
e.preventDefault();
return false;
}
});
}); // end document.ready