(function($) { var requestTimer = null; var requestPool = []; var teaserURL = 'https://cct.check24.de/api'; var datainterfaceURL = 'https://cct.check24.de/datainterface'; var timeout = 5500; var haveIframe = false; var debugLog = []; var JSON = window.JSON; if (JSON === undefined) { JSON = { stringify: function (vContent) { if (vContent instanceof Object) { var sOutput = ""; if (vContent.constructor === Array) { for (var nId = 0; nId < vContent.length; sOutput += this.stringify(vContent[nId]) + ",", nId++); return "[" + sOutput.substr(0, sOutput.length - 1) + "]"; } if (vContent.toString !== Object.prototype.toString) { return "\"" + vContent.toString().replace(/"/g, "\\$&") + "\""; } for (var sProp in vContent) { sOutput += "\"" + sProp.replace(/"/g, "\\$&") + "\":" + this.stringify(vContent[sProp]) + ","; } return "{" + sOutput.substr(0, sOutput.length - 1) + "}"; } return typeof vContent === "string" ? "\"" + vContent.replace(/"/g, "\\$&") + "\"" : String(vContent); } }; } function Spinner(element) { var self = this; var cSpeed = 9; var cWidth = 50; var cHeight = 50; var cTotalFrames = 18; var cFrameWidth = 50; var cImageSrc = 'https://cct.check24.de/images/main/loading.png'; var cIndex = 0; var cXpos = 0; var cPreloaderTimeout = false; var SECONDS_BETWEEN_FRAMES = 0; this.startAnimation = function() { element.style.backgroundImage='url('+cImageSrc+')'; element.style.width=cWidth+'px'; element.style.height=cHeight+'px'; var FPS = Math.round(100/cSpeed); SECONDS_BETWEEN_FRAMES = 1 / FPS; cPreloaderTimeout=setTimeout(function() { self.continueAnimation(); }, SECONDS_BETWEEN_FRAMES/1000); }; this.continueAnimation = function() { cXpos += cFrameWidth; cIndex += 1; if (cIndex >= cTotalFrames) { cXpos =0; cIndex=0; } element.style.backgroundPosition = (-cXpos)+'px 0'; cPreloaderTimeout = setTimeout(function() { self.continueAnimation(); }, SECONDS_BETWEEN_FRAMES*1000); }; this.stopAnimation = function() { clearTimeout(cPreloaderTimeout); cPreloaderTimeout=false; }; } $.fn.cctSpinner = function(start) { for (var id = 0; id < this.length; id++) { var element = this[id]; if (element.spinner === undefined && start === true) { element.spinner = new Spinner(element); element.spinner.startAnimation(); } if (typeof element.spinner === 'object' && start === false) { element.spinner.stopAnimation(); element.spinner = undefined; } } return this; }; (function() { $.fn.cctClickTip = function(displayClass) { displayClass = displayClass === undefined ? 'clicktip-trigger' : displayClass; if ($('#c24cct-clicktip').length === 0) { $(document.body).append($('
', { id: 'c24cct-clicktip', style: 'display: none; position: absolute;' })); $(document.body).on('click', function() { hide(); }); } for (var id = 0; id < this.length; id++) { (function(that) { that.cctClickTipContent = $(that).html(); $(that).html(''); $(that).addClass(displayClass); $(that).on('click', function(e) { e.stopPropagation(); if (currentOwner === that) { hide(); } else { show(that); } }); }(this[id])); } }; var currentOwner = null; var getOverlayPosition = function($owner, $clicktip) { var $window = $(window); var position = $owner.offset(); var toLeft = position.left + $clicktip.outerWidth() >= $window.width() ? true : false; var toTop = position.top + $clicktip.outerHeight() - $window.scrollTop() >= $window.height() ? true : false; var x = toLeft ? position.left - $clicktip.outerWidth() : position.left + $owner.outerWidth(); var y = toTop ? position.top - $clicktip.outerHeight() + $owner.outerHeight() : position.top; return { x: x, y: y, toTop: toTop, toLeft: toLeft }; }; var show = function(owner) { var $clickTip = $('#c24cct-clicktip'); var $owner = $(owner); currentOwner = owner; var prefix = $owner.prop('class').match(/(c[a-zA-Z0-9]+\-)clicktip/); prefix = prefix instanceof Array ? prefix[1] : 'c24cct-'; $clickTip.prop('class', $clickTip.prop('class').replace(/\s*c[a-zA-Z0-9]+\-clicktip\-overlay/, '')); $clickTip.addClass(prefix + 'clicktip-overlay'); $clickTip.html(owner.cctClickTipContent); $clickTip.show(); var position = getOverlayPosition($owner, $clickTip); $clickTip.css({ left: position.x, top: position.y }); }; var hide = function() { var $clickTip = $('#c24cct-clicktip'); currentOwner = null; $clickTip.hide(); }; })(); $.fn.cctFade = function(type, duration) { duration = duration !== undefined ? duration : 250; type = type === 'in' ? 'in' : 'out'; for (var id = 0; id < this.length; id++) { var element = this[id]; var $element = $(element); if (element.cctFadeTimer === undefined) { $element.css({ transition: 'opacity ' + duration + 'ms', opacity: 0, display: 'none' }); } if (type === 'out') { $element.css('opacity', 0); clearTimeout(element.cctFadeTimer); element.cctFadeTimer = setTimeout(function() { $element.css('display', 'none'); }, duration); } else { $element.css('display', 'block'); setTimeout(function() { $element.css('opacity', 1); }, 0); clearTimeout(element.cctFadeTimer); element.cctFadeTimer = setTimeout(function() { $element.css('display', 'block'); }, duration); } } }; $.fn.cctOverlay = function(overlaySelector, watchTriggerOnly, duration) { duration = duration !== undefined ? duration : 250; watchTriggerOnly = watchTriggerOnly !== undefined ? watchTriggerOnly : false; var trigger = this[0]; var $overlay = $($(overlaySelector).get(0)); var $watch = watchTriggerOnly ? $(trigger) : $([ this[0], $(overlaySelector).get(0) ]); var lastTarget = ''; $watch.on('mouseenter mouseleave', function(e) { var type = e.type; var target = e.target === trigger ? 'trigger' : 'overlay'; if (type === 'mouseleave') { $overlay.cctFade('out', duration); } else { if (target !== 'overlay' || lastTarget !== 'overlay') { $overlay.cctFade('in', duration); } } lastTarget = target; }); }; $.fn.cctToolTip = function(html, className, watchTriggerOnly, duration) { duration = duration !== undefined ? duration : 250; for (var id = 0; id < this.length; id++) { var $element = $(this[id]); var $tip = $('
', { 'class': className }); $tip.css({ 'display': 'none', 'position': 'absolute' }); $tip.html('
' + html + '
'); $tip.insertAfter($element); $element.cctOverlay($tip, watchTriggerOnly, duration); } }; $.fn.cctFill = function(options, valueIsKey, elementType, indexAttribute) { elementType = (elementType === undefined ? 'option' : elementType); indexAttribute = (indexAttribute === undefined ? 'value' : indexAttribute); valueIsKey = (valueIsKey === undefined ? false : valueIsKey); for (var id = 0; id < this.length; id++) { var $element = $(this[id]); $element.empty(); for (var index in options) { if (options.hasOwnProperty(index)) { var $option = $('<' + elementType + ' />'); $option.text(options[index]); if (indexAttribute !== null) { $option.attr(indexAttribute, valueIsKey ? options[index] : index); } $element.append($option); } } } return this; }; $.fn.cctFormData = function() { var result = { }; for (var id = 0; id < this.length; id++) { $.each($(this).serializeArray(), function(_, kv) { result[kv.name] = kv.value; }); } return result; }; (function() { $.fn.cctFormValidate = function(definition) { var fields = definition.fields; var handler = definition.handler || formValidateHandler; var data = $.fn.cctFormData.call(this); var $this = $(this); var errors = []; for (var key in fields) { var field = fields[key]; var isError = field.test(data[key]) !== true; handler($this.find('[name="' + key + '"]').get(0), isError, key, definition); if (isError) { errors.push(key); } } return errors; }; var formValidateHandler = function(element, error, key, definition) { var errorClass = definition.errorClass || 'form-error'; $(element).toggleClass(errorClass, error); }; })(); function receiveMessage(event) { if (typeof event.data === 'string') { var message = event.data.split(":"); var eventName = message[0]; var iframes, len, i = 0; if (event.origin === "null" && eventName === "cct.resize") { iframes = document.getElementsByTagName("iframe"); len = iframes.length; for (; i < len; i++) { if ((iframes[i].contentWindow || iframes[i].documentWindow) == event.source) { iframes[i].style.height = message[1] + "px"; return; } } } } } function registerResizer() { if ( window.addEventListener ) { window.addEventListener("message", receiveMessage, false); } else if (window.attachEvent) { window.attachEvent("onmessage", receiveMessage); } } var applyHost = function(html) { if (typeof html !== 'string') { return html; } var current; var regex = /([\S\s]+?)/; while ((current = html.match(regex))) { var $target = $(current[1]); if ($target.html().indexOf(current[2]) === -1) { $target.append(current[2]); } html = html.replace(regex, ''); } return html; }; var versionDefaults = { v2: { frameContent: true }, v3: { frameContent: true, numItems: 4 } }; var defaults = { filterLoader: '.c24-teaser-loader', filterDefault: '.c24-teaser', loaderDelay: 150, autoCall: true, useDefaultLoader: true, hideUnused: false, hideOnError: false, frameContent: false, version: 1, numItems: 1, kind: 'teaser', showTeaser: function(html, unique) { this.hideLoader(); var teaser = $(this.element).find(this.filterDefault); if (this.frameContent) { html = applyHost(html); html = '\n