Форма онлайн-бронирования
(function () {
const travelLineInit = (w) => {
var selectHotel = (function () {
var hotel = '';
switch (window.location.host) {
case 'krasnodar.olympia-hotel.ru': hotel = 'krasnodar'; break;
case 'sochi.olympia-hotel.ru': hotel = 'sochi'; break;
case 'mountain.olympia-hotel.ru': hotel = 'mountain'; break;
case 'red.olympia-hotel.ru': hotel = 'red'; break;
case 'lasarevskoye.olympia-hotel.ru': hotel = 'lasarevskoye'; break;
case 'adler-home.olympia-hotel.ru': hotel = 'adler-home'; break;
default: hotel = ''; break;
}
return hotel !== '' ? '.' + hotel : '';
}());
var q = [['setContext', 'TL-INT-olympia-hotel' + selectHotel, 'ru'], ['embed', 'booking-form', { container: 'tl-booking-form' }]];
var h = ["ru-ibe.tlintegration.ru", "ibe.tlintegration.ru", "ibe.tlintegration.com"];
var t = w.travelline = (w.travelline || {}), ti = t.integration = (t.integration || {});
ti.__cq = ti.__cq ? ti.__cq.concat(q) : q;
if (!ti.__loader) {
ti.__loader = true;
var d = w.document, c = d.getElementsByTagName("head")[0] || d.getElementsByTagName("body")[0];
function e(s, f) { return function () { w.TL || (c.removeChild(s), f()) } }
(function l(h) {
if (0 === h.length) return; var s = d.createElement("script");
s.type = "text/javascript"; s.async = !0; s.src = "https://" + h[0] + "/integration/loader.js";
s.onerror = s.onload = e(s, function () { l(h.slice(1, h.length)) }); c.appendChild(s)
})(h);
}
};
let isInitialScroll = true;
function smoothScrollTo(target, duration, callback) {
const start = window.pageYOffset || document.documentElement.scrollTop;
const distance = target - start;
const startTime = performance.now();
const ease = t => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
function animate(now) {
const progress = Math.min((now - startTime) / duration, 1);
window.scrollTo(0, start + distance * ease(progress));
if (progress < 1) {
requestAnimationFrame(animate);
} else if (callback) {
callback();
}
}
requestAnimationFrame(animate);
}
function initHeaderAndScroll() {
const header = document.querySelector('.main-header');
const blockMain = document.querySelector('.block-main');
if (!blockMain || !header) return;
header.style.transition = 'transform 0.4s ease-in-out';
const updateHeader = () => {
const isDesktop = window.innerWidth > 1024;
const scrollY = window.pageYOffset || document.documentElement.scrollTop;
const hHeight = header.offsetHeight;
const bRect = blockMain.getBoundingClientRect();
const bTopAbsolute = bRect.top + scrollY;
const bBottomAbsolute = bTopAbsolute + blockMain.scrollHeight;
const threshold = bTopAbsolute - hHeight;
if (isDesktop) {
if (scrollY + hHeight > bBottomAbsolute) {
const diff = bBottomAbsolute - (scrollY + hHeight);
header.style.transform = `translateY(${diff}px)`;
} else {
header.style.transform = 'translateY(0px)';
}
return;
}
if (isInitialScroll) {
header.style.transform = 'translateY(0px)';
return;
}
if (scrollY > threshold + 2) {
header.style.transform = 'translateY(-100%)';
} else {
header.style.transform = 'translateY(0px)';
}
};
setTimeout(() => {
const bTop = blockMain.getBoundingClientRect().top + window.pageYOffset;
const hHeight = header.offsetHeight;
smoothScrollTo(bTop - hHeight, 1000, () => {
setTimeout(() => {
isInitialScroll = false;
updateHeader();
}, 100);
});
}, 500);
window.addEventListener('scroll', updateHeader, { passive: true });
window.addEventListener('resize', updateHeader);
travelLineInit(window);
}
initHeaderAndScroll();
})();