");
var iAnzBanner = RenderBannerImage(context, bannerData, $wrapper);
if (iAnzBanner > 0) {
bReturn = true;
if (iAnzBanner === 2) //BUG in Slider: mit 2 Slides kein Loop
{
RenderBannerImage(context, bannerData, $wrapper);
}
}
if (bReturn) {
jQuery($wrapper).insertAfter(jQuery(".config" + bannerData.cssClass));
}
}
return bReturn;
}
function RenderBannerImage(context, bannerData, $wrapper) {
var iCount = 0;
bannerData.Images.forEach(function (bannerImage) {
var strSrc = null;
switch (context.Device) {
case EDevice.M:
strSrc = bannerImage.Tablet;
break;
case EDevice.S:
case EDevice.XS:
strSrc = bannerImage.Mobile;
break;
default:
strSrc = bannerImage.Desktop;
break;
};
if (strSrc && strSrc.length > 0) {
var $divBanner = jQuery("
").appendTo($wrapper);
var $image;
if (bannerImage.Url && bannerImage.Url.length > 0) {
$image = jQuery("
", {
class: "rsImg rsImgBanner rsImgBannerHidden rsImgBannerLink",
src: strSrc,
alt: bannerImage.Title,
title: bannerImage.Title,
onclick: "mch.mchSlider.bannerclick('" + bannerImage.Url + "', '" + bannerImage.Target + "')"
});
} else {
$image = jQuery("
", {
class: "rsImg rsImgBanner rsImgBannerHidden",
src: strSrc,
alt: bannerImage.Title,
title: bannerImage.Title
});
}
$image.appendTo($divBanner);
iCount = ++iCount;
}
});
return iCount;
}
prototype.bannerclick = function (strUrl, strTarget) {
if (strUrl && strUrl.length > 0) {
MCHWebtrekk.SendWebtrekkInfo('BannerClick', strUrl);
setTimeout(function () { //Warten bis Webtrekk gesendet
if (strTarget === "_blank") {
try { console.log("target:" + strTarget); window.open(strUrl, strTarget); }
catch (err) { document.location = strUrl; }
} else { document.location = strUrl; }
}, 500);
}
return true;
}
function onBreakpointPrepareBanner(context) {
context.BannerList.forEach(function (bannerData) {
var strSlector = "." + bannerData.cssClass;
var $slider = jQuery(strSlector).data('royalSlider');
if ($slider != null && typeof $slider == "object") {
$slider.destroy(); //aktiven Slider stoppen, zerstören und das HTML entfernen
}
jQuery(strSlector).remove();
if (renderBanner(context, bannerData)) {
eval("init" + bannerData.cssClass + "()");
SetBannerEvents(context, bannerData);
}
});
}
function SetBannerEvents(context, bannerData) {
var $slider = jQuery('.' + bannerData.cssClass);
var $sliderData = $slider.data("royalSlider");
if (typeof $sliderData != "object" || typeof $slider != "object" || $slider.length == 0) {
return;
}
////1. Slide einblenden //Bug im IE Slide werden auch im overflow ganz kurz angezeigt
$sliderData.slides[0].content.find(".rsImgBannerHidden").removeClass("rsImgBannerHidden");
////nächsten Slide bei Bedarf einblenden //Bug im IE Slide werden auch im overflow ganz kurz angezeigt
$sliderData.ev.on('rsBeforeAnimStart', function (e, slideObject) {
$sliderData.currSlide.holder.find(".rsImgBannerHidden").removeClass("rsImgBannerHidden");
});
}
//#endregion Banner
//#region Video und Helper
//Click auf Button Video starten
prototype.playclick = function (sliderId) {
try {
var objKeyVisualRotator = null;
if (this.KeyVisualRotatorList) {
this.KeyVisualRotatorList.forEach(function (obj) {
if (obj.cssClass && obj.cssClass === sliderId) {
objKeyVisualRotator = obj;
}
});
}
var $sliderData = jQuery('.' + sliderId).data("royalSlider");
var $holder = $sliderData.currSlide.holder;
if (typeof $holder == "object") {
ShowHtml5Video(this, objKeyVisualRotator, $sliderData, $holder, true);
}
}
catch (exept) { console.log("Error Slider playclick(): " + exept.message); }
return true;
}
function StopAndHideHtml5Video(objKeyVisualRotator, $holder) {
//console.log("HideVideo. " + $holder.find("div").attr("class"));
var video = $holder.find("video"); //Video-Tag
var html4Video = $holder.find(".rsHtml4Video");
var bVideoAutoplay = false;
if (video != null && video.length === 1) {
//console.log("PauseVideo : " + objKeyVisualRotator.Animation);
video[0].pause();
//video[0].currentTime = 0;
}
if (html4Video && html4Video.length === 1 && jQuery(html4Video).attr("data-autoplay") === "autoplay") {
bVideoAutoplay = true;
}
if (objKeyVisualRotator.Animation != "fade" || bVideoAutoplay == false) {
//console.log("RemoveVideo : " + objKeyVisualRotator.Animation);
$holder.find(".rsMainSlideImage").show();
$holder.find(".rsBtnCenterer").show();
$holder.find(".rsContentBox").show();
var video = $holder.find("video"); //Video-Tag
if (video != null && video.length === 1) {
video[0].pause();
video.hide();
video.remove();
//console.log("RemoveVideo" + video.html());
}
}
}
//bStart -> Video sofort starten
function ShowHtml5Video(context, objKeyVisualRotator, $sliderData, $holder, bStart) {
//console.log("ShowHtml5Video. " + $sliderData.currSlide.holder.find("div").attr("class"));
var html4Video = $holder.find(".rsHtml4Video");
var video = $holder.find("video");
//Video-Config ist vorhanden
if (html4Video && html4Video.length === 1) {
//Manuel Start mit Button-Click oder Video ist im autoplay
if (bStart || jQuery(html4Video).attr("data-autoplay") === "autoplay") { //Video autostart
//Videos im Breakpoint S nur bei PortletVideos starten
if (jQuery(html4Video).attr("data-type") === "VideoPortletSlider"
|| context === null || IsDeviceMobile(context) === false) {
if (video === null || video.length === 0) {
//noch kein Video-Tag vorhanden, ein neues erstellen
RenderVideoTag(context, objKeyVisualRotator, $sliderData, $holder, bStart, html4Video);
}
else {
//video[0].currentTime = 0;
video[0].play();
}
}
}
}
}
function RenderVideoTag(context, objKeyVisualRotator, $sliderData, $holder, bStart, html4Video) {
var strSupport = jQuery(html4Video).attr("data-error");
var strConf = " ";
//console.log("IS iOS: " + mch.mchSlider.IOS);
if ((jQuery(html4Video).attr("data-controls") === "controls") || mch.mchSlider.IOS) {
strConf = "controls ";
}
if (bStart) { //Ton ein wenn manuel Start mit Button
strConf += (jQuery(html4Video).attr("data-muted") === "muted") ? " muted " : "";
}
else { //Video immer ohne Ton -> preload Video//Video wird noch ausgeblendet
strConf += " muted style=\"display:none;\" ";
}
//loop=\"loop\"
html4Video.after("
"
+ " "
+ ""
+ "
"
+ "
" + strSupport + " "
+ " ");
if (bStart) { //Click Button Start Bilder ausblenden -> Video läuft schon
$holder.find(".rsBtnCenterer").fadeOut(mch.mchSlider.FadeTime);
$holder.find(".rsMainSlideImage").fadeOut(mch.mchSlider.FadeTime);
$holder.find(".rsContentBox").fadeOut(mch.mchSlider.FadeTime);
var video = $holder.find("video"); //Video-Tag
video[0].addEventListener("ended", function () {
StartHtml5Video($sliderData, objKeyVisualRotator, video[0]);
});
}
else { //Autostart -> Video einblenden und auf Position 0 stellen
var iDelay = parseInt(jQuery(html4Video).attr("data-delayautoplay"));
if (iDelay === "NaN" || iDelay < 0) { iDelay = 0; }
setTimeout(function () {
var video = $holder.find("video"); //Video-Tag
if (video != null && video.length === 1) {
StartVideo(objKeyVisualRotator, $sliderData, $holder, html4Video, video);
}
}, iDelay);
}
}
function StartVideo(objKeyVisualRotator, $sliderData, $holder, html4Video, video) {
try {
if (video != null) {
var buffer = video[0].buffered;
if (buffer && buffer.length > 0 && buffer.end(0) > 0) {
//console.log("start video buffer: " + buffer.end(0));
$holder.find(".rsPreloader").remove();
$holder.find(".rsMainSlideImage").fadeOut(mch.mchSlider.VideoDelayAutoplayFadeTime);
$holder.find(".rsContentBox").fadeOut(mch.mchSlider.VideoDelayAutoplayFadeTime);
if (video[0].currentTime > 0) { video[0].currentTime = 0; } //Achtung IE
if (jQuery(html4Video).attr("data-muted") != "muted") {
video.prop("muted", false); //mute
}
video.fadeIn(mch.mchSlider.VideoDelayAutoplayFadeTime);
video[0].addEventListener("ended", function () {
StartHtml5Video($sliderData, objKeyVisualRotator, video[0]);
});
}
else {
html4Video.after("
");
//console.log("wait video buffer. Type:" + typeof buffer); console.log("wait video buffer. length:" + typeof buffer.length);
setTimeout(StartVideo, 1000, objKeyVisualRotator, $sliderData, $holder, html4Video, video);
}
}
}
catch (exept) {
console.log("Error Slider StartVideo():" + exept.message);
}
};
function StartHtml5Video($sliderData, objKeyVisualRotator, video) {
if (video && typeof video === "object") {
if ($sliderData.numSlides === 1) {
video.currentTime = 0;
video.play();
}
else if ($sliderData.numSlides === $sliderData.currSlideId + 1) {
$sliderData.goTo(0)
}
else {
$sliderData.next();
}
}
}
function IsDeviceMobile(context) {
return (context.Device === EDevice.XS || context.Device === EDevice.S) ? true : false;
}
function getCurrentDevice() {
if (mch.currentDevice === "xs")
return EDevice.XS;
else if (mch.currentDevice === "s")
return EDevice.S;
else if (mch.currentDevice === "m")
return EDevice.M;
else
return EDevice.L;
}
function changeVideoImgUrl(context, strVideoItemId, strVideoUrl) {
if (strVideoItemId && strVideoUrl) {
if (strVideoUrl.match(/(\/\/youtu\.be\/)|(\/\/www\.youtube\.com\/watch)/)) {
var strVideoId = null;
var strYoutubeUrl = strVideoUrl.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
if (strYoutubeUrl[2] !== undefined) {
var aryValue = strYoutubeUrl[2].split(/[^0-9a-z_]/i);
strVideoId = aryValue[0];
}
else {
strVideoId = strYoutubeUrl;
}
setVideoImg(strVideoItemId, strVideoUrl, "//i2.ytimg.com/vi/" + strVideoId + "/hqdefault.jpg");
}
else if (strVideoUrl.match(/.vimeo.com\/(\d+)($|\/)/)) {
var aryValue = strVideoUrl.split('/');
if (aryValue.length > 2) {
setVimeoImgUrl(context, strVideoItemId, strVideoUrl, strVideoUrl.split('/')[aryValue.length - 1]);
}
} else if (strVideoUrl.match(/.vimeo.com\/channels\/\d+/)) {
var aryValue = strVideoUrl.split('/');
if (aryValue.length > 3) {
setVimeoImgUrl(context, strVideoItemId, strVideoUrl, strVideoUrl.split('/')[aryValue.length - 1]);
}
} else if (strVideoUrl.match(/.vimeo.com\/channels\/staffpicks\/\d+/)) {
var aryValue = strVideoUrl.split('/');
if (aryValue.length > 4) {
setVimeoImgUrl(context, strVideoItemId, strVideoUrl, strVideoUrl.split('/')[aryValue.length - 1]);
}
}
}
}
function setVimeoImgUrl(context, strVideoItemId, strVideoUrl, strVideoId) {
if (strVideoId) {
var strUrl = "http://vimeo.com/api/v2/video/" + strVideoId + ".json?callback=?";
jQuery.getJSON(strUrl, {
format: "json"
}, function (data) {
})
.success(function (data, status, xmlHttp) {
setVideoImg(strVideoItemId, strVideoUrl, data[0].thumbnail_medium)
})
.error(function (xmlHttp, status, error) {
if (context.DebugMode) {
console.log("Error vimeo thumbnail: Status" + status + ",\n\nErrorText:\n\n " + xmlHttp.responseText);
}
})
.complete(function (xmlHttp, status) {
//alert(data[0].thumbnail_medium);
});
}
}
function setVideoImg(strVideoItemId, strVideoUrl, strImageUrl) {
jQuery("." + strVideoItemId).find("img").attr("src", strImageUrl);
}
//#endregion Video und Helper
})(mchSlider.prototype);
mch.addWidget(new mchSlider())
})(jQuery);
/* end widget mchSlider*/
/* start widget responsiveTables*/
(function ($) {
// object ctor
function responsiveTables(el, config) {
/* taken from zurb-foundation */
this.switched = false;
}
// declare methods
(function (prototype) {
// called by MCH on dom load
prototype.init = function () {
this.updateTables();
}
// called by MCH on resize
prototype.onResize = function () {
this.updateTables();
}
prototype.updateTables = function () {
if ((mch.currentDevice === "s" || mch.currentDevice === "m") && !this.switched) {
this.switched = true;
var context = this;
$("table.responsive").each(function (i, element) {
context.splitTable($(element));
});
return true;
}
else if (this.switched && !(mch.currentDevice === "s" || mch.currentDevice === "m")) {
this.switched = false;
var context = this;
$("table.responsive").each(function (i, element) {
context.unsplitTable($(element));
});
}
}
prototype.splitTable = function (original) {
original.wrap("
");
var copy = original.clone();
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
copy.removeClass("responsive");
original.closest(".table-wrapper").append(copy);
copy.wrap("
");
original.wrap("
");
this.setCellHeights(original, copy);
}
prototype.unsplitTable = function (original) {
original.closest(".table-wrapper").find(".pinned").remove();
original.unwrap();
original.unwrap();
}
prototype.setCellHeights = function (original, copy) {
var tr = original.find('tr');
var tr_copy = copy.find('tr');
var heights = [];
tr.each(function (index) {
var self = $(this);
var tx = self.find('th, td');
tx.each(function () {
var height = $(this).outerHeight(true);
heights[index] = heights[index] || 0;
if (height > heights[index]) heights[index] = height;
});
});
tr_copy.each(function (index) {
$(this).height(heights[index]);
});
}
})(responsiveTables.prototype);
// no need to wrap inside dom load event
// since ctor does not access anything and
// we always will only have one instance
// wait for init event to setup everything
mch.addWidget(new responsiveTables())
})(jQuery);
/* end widget responsiveTables*/
/* start widget collapsible*/
(function ($) {
// object ctor
function collapsible(el, config) {
}
// declare methods
(function (prototype) {
// called by MCH on dom load
prototype.init = function () {
$(document).on("click", ".expand", function () {
$(this).nextAll(".expandablecontent").slideToggle();
return false;
});
$(document).on("click", ".switch > a", function () {
mch.util.log("click on switch");
if ($(this).is(".open")) {
mch.util.log("switch is .open => slideup all and removeclass open");
$(this).parent().parent().find(".expandablecontent").slideUp();
}
else {
mch.util.log("switch is NOT .open => slidedown all and addclass open");
$(this).parent().parent().find(".expandablecontent").slideDown();
}
return false;
});
}
})(collapsible.prototype);
// no need to wrap inside dom load event
// since ctor does not access anything and
// we always will only have one instance
// wait for init event to setup everything
mch.addWidget(new collapsible())
})(jQuery);
/* end widget collapsible*/
/* start widget mchAnythingSliderCollection */
(function (jQuery) {
// object ctor
function mchAnythingSliderCollection(el, config) {
this.sliders = [];
}
// declare methods
(function (prototype) {
// called by MCH on dom load
prototype.init = function () {
this.initMchAnythingSliderHelper();
// only init once
this.inited = true;
}
prototype.addSlider = function (anythingSlider) {
this.sliders.push(anythingSlider);
// trigger init for late widgets
if (this.inited)
this.initMchAnythingSliderHelper();
}
prototype.initMchAnythingSliderHelper = function () {
if (this.sliders.length == 0) {
return;
}
if (typeof mchAnythingSliderHelper != 'object') {
jQuery.getLocalScript('/Sites/javascripts/Common/mchAnythingSlider.js', function () {
mch.mchAnythingSliderHelper.initAnythingSliders();
});
}
else {
mch.mchAnythingSliderHelper.initAnythingSliders();
}
}
})(mchAnythingSliderCollection.prototype);
// no need to wrap inside dom load event
// since ctor does not access anything and
// we always will only have one instance
// wait for init event to setup everything
mch.addWidget(new mchAnythingSliderCollection())
})(jQuery);
/* end widget mchAnythingSliderCollection*/
/* end widgets */
/*
* code stored in "~/Sites/javascripts/Common/jquery.mch.referrer.js"
* used for appending the referrer to the links theat requets the dataprotection form.
*/
(function ($) {
function referrer() {
}
(function (prototype) {
prototype.init = function () {
var dataProtectionLinks = $("a.mch-dataprotection");
if (dataProtectionLinks.length > 0) {
if (typeof URLSearchParams !== 'undefined') {
var searchParams = new URLSearchParams(window.location.search);
var isMobile = searchParams.get("co") === "1";
}
var referrer = document.referrer || location.host;
if (referrer) {
var query = {
"host": referrer
};
if (isMobile) {
$.extend(query, { "co": "1" });
}
$.each(dataProtectionLinks, function (index, protectionLink) {
protectionLink.href += "?" + $.param(query);
});
}
}
};
})(referrer.prototype);
mch.addWidget(new referrer());
})(jQuery);