window.addEventListener("load", function () { if (no_header == "1") { if (!document.getElementsByTagName) return; var linkler = document.getElementsByTagName("a"); var linklerAdet = linkler.length; for (var i = 0; i < linklerAdet; i++) { var tekLink = linkler[i]; if (tekLink.getAttribute("href")) { if (tekLink.href.indexOf("haberler.com") > -1) { if (tekLink.href.indexOf("?") > -1) tekLink.href += "&no_header=1"; else tekLink.href += "?no_header=1"; } } } } getScript("/mstatic/assets/js/lazyload.js", "", function () { lazyload(); }); }); function slideSetToEnd(contenId) { if (contenId > 0) { var slide = document.querySelector('[data-imp-haberid="' + contenId + '"]'); if (slide != null) { var currentPos = Array.prototype.indexOf.call(slide.parentNode.children, slide); if (currentPos > 3) { slide.remove(); var slidesDiv = document.getElementById("slides"); slidesDiv.insertBefore(slide, slidesDiv.lastChild); var bullet = document.querySelector('[data-sid="' + currentPos + '"]'); var bullets = document.querySelectorAll('[class="bullet"]'); for (i = 0; i < bullets.length; i++) { if (i + 1 >= currentPos) bullets[i].setAttribute('data-sid', parseInt(bullets[i].getAttribute('data-sid')) - 1); } bullet.remove(); bullet.setAttribute('data-sid', 25); var bulletsDiv = document.getElementsByClassName("bullets")[0]; bulletsDiv.appendChild(bullet); } } } } function cookiePolicyWarning(text, linkText, linkUrl) { var cwh = document.createElement('div'); cwh.setAttribute('style', 'font-size:12px;z-index:999999;width:100%;padding: 15px 100px 15px 15px;box-sizing:border-box;color: #000000;background-color:#FFFBD0;position: fixed;bottom: 0px;left: 0px;box-shadow:0 -5px 30px -15px rgba(152, 191, 248, 0.5);font-weight:400;'); cwh.setAttribute('id', 'cookiePolicyw'); cwh.innerHTML = text; /*var cwh_a = document.createElement('a'); cwh_a.setAttribute('style', 'color:#404040;font-size:inherit;font-weight:800;'); cwh_a.setAttribute('href', linkUrl); cwh_a.innerHTML = linkText;*/ var cwh_cl = document.createElement('div'); cwh_cl.setAttribute('style', 'position:absolute;right: 20px;top:50%;width:26px;height:26px;margin-top:-13px;box-sizing:border-box;border-radius:13px;cursor:pointer;font-size:14px;background-color:#ff0000;line-height:26px;text-align:center;font-family:monospace;color:#fff;'); cwh_cl.setAttribute('onclick', 'document.getElementById("cookiePolicyw").style.display = \'none\';document.cookie = \'cookiePolicy=closed; expires=Sun, 14 Mar 2027 23:59:59 GMT; path=/; domain=haberler.com\';'); cwh_cl.innerHTML = 'X'; //cwh.appendChild(cwh_a); cwh.appendChild(cwh_cl); document.body.appendChild(cwh); } var cookiePolicyGetCookie = function (name) { var pair = document.cookie.match(new RegExp(name + '=([^;]+)')); return !!pair ? pair[1] : null; }; if (cookiePolicyGetCookie('cookiePolicy') !== "closed") { //cookiePolicyWarning('Sizlere daha iyi hizmet sunabilmek adına sitemizde çerez konumlandırmaktayız. Kişisel verileriniz, KVKK ve GDPR kapsamında toplanıp işlenir. Detaylı bilgi almak için Veri Politikamızı / Aydınlatma Metnimizi inceleyebilirsiniz. Sitemizi kullanarak, çerezleri kullanmamızı kabul etmiş olacaksınız.', '
Daha fazla bilgi için tıklayın', '/haberler/cerez-politikasi/'); } $(document).on("click", ".hb-click-acc", function () { var subMenu = $(this).next(".hbmLiSubScope"); subMenu.toggle(); }); $(document).on("click", ".dropScope .dropMenu", function () { parentClick = $(this).closest(".dropScope"); $(".dropDownOpenBox", parentClick).toggleClass("active"); }) $(document).on("click", ".dropScope .menuOpen", function () { parentClick = $(this).closest(".dropScope"); if (!$(this).hasClass("disabled")) { $(".menuOpen", parentClick).removeClass("active"); $("option", parentClick).removeAttr("selected"); $(this).addClass("active"); thisText = $(this).text(); $("option[value=" + thisText + "]", parentClick).attr("selected", "selected"); $(".dropMenu span", parentClick).html(thisText); $(".dropDownOpenBox", parentClick).removeClass("active"); } }) $(document).on("keyup", ".dropScope .dropDownSearchBoxInput", function () { thisParent = $(this).closest(".dropScope"); value = $(this).val().toLowerCase(); $(".menuOpen", thisParent).filter(function () { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); $(document).on("mouseleave", ".dropScope", function () { $(".dropDownOpenBox", this).removeClass("active"); }); $(".hbToggleScope").each(function () { thisToggle = $(this); checkedSwitchToggle(thisToggle); }) $(document).on("touchstart click", ".hbToggleScope", function () { thisToggle = $(this); checkedSwitchToggle(thisToggle); }); function checkedSwitchToggle(thisElement) { if ($(".onoffswitch-checkbox", thisElement).is(":checked")) { $(".onoffswitch-switch", thisElement).removeClass("open"); $(".onoffswitch-switch", thisElement).addClass("close"); $(".hbTVSlider, .openCloseText").removeClass("open"); $(".hbOpened").removeClass("redColor"); $(".hbClosed").addClass("redColor"); } else { $(".onoffswitch-switch", thisElement).removeClass("close"); $(".onoffswitch-switch", thisElement).addClass("open"); $(".hbTVSlider, .openCloseText").addClass("open"); $(".hbClosed").removeClass("redColor"); $(".hbOpened").addClass("redColor"); } } $(document).ready(function () { $(document).on("click", ".hbhdNavIcon", function () { if ($(this).hasClass("active")) { $(this).removeClass("active"); $(".hbNavMenuScope").removeClass("active"); //$("body").css({ "touch-action": "auto" }); } else { $(this).addClass("active"); $(".hbNavMenuScope").addClass("active"); //$("body").css({ "touch-action": "none" }); } }) $(document).on("click", ".hbnmBg", function () { $(".hbhdNavIcon").removeClass("active"); $(".hbNavMenuScope").removeClass("active"); }) $(document).on("click", ".ftClick", function () { ftThisParent = $(this).closest(".footerAccordion"); if ($(this).hasClass("active")) { $(this).removeClass("active"); $(ftThisParent).removeClass("active"); } else { $(this).addClass("active"); $(ftThisParent).addClass("active"); } }) $(document).on("click", ".hbhdSearch", function () { if (cihaz_mobilmi || $(window).innerWidth() <= 1024) { if ($(this).hasClass("active")) { $(this).removeClass("active"); $(".hbGeneralSearch").removeClass("active"); } else { $(this).addClass("active"); $(".hbGeneralSearch").addClass("active"); } } }) $(".hbssTexts").on("click", function () { clickFootballResult($(this), "hbssTexts", "hbssMainTab"); }) $(".hbssLeague").on("click", function () { clickFootballResult($(this), "hbssLeague", "hbssSlider"); }) $(".hbcftTabs").on("click", function () { clickFinanceTabs($(this), "hbcftTabs", "hbcftChartSectionOpen"); }) function clickFinanceTabs(thisElement, clickClass, dataClass) { dataOpen = $(thisElement).attr("dataOpen"); $("." + clickClass).removeClass("active"); $(thisElement).addClass("active"); $("." + dataClass).removeClass("active"); $("." + dataClass + "." + dataOpen).addClass("active"); } $(".hbsftTab").on("click", function () { clickFinanceTopTabs($(this), "hbsftTab", "hbsftTabOpen"); }) function clickFinanceTopTabs(thisElement, clickClass, dataClass) { dataOpen = $(thisElement).attr("dataOpen"); $("." + clickClass).removeClass("active"); $(thisElement).addClass("active"); $("." + dataClass).removeClass("active"); $("." + dataClass + "." + dataOpen).addClass("active"); } function clickFootballResult(thisElement, clickClass, dataClass) { dataOpen = $(thisElement).attr("dataOpen"); $("." + clickClass).removeClass("active"); $(thisElement).addClass("active"); $("." + dataClass).removeClass("active"); $("." + dataClass + "." + dataOpen).addClass("active"); } }) $(window).on("load", function () { videoSliderRatio(); videoPageRatio(); $(".dropDownGhost").each(function () { dropDownCreate(this); thisParent = $(this).closest(".dropScope"); $("option", this).each(function () { if ($(this).attr("selected")) { $(".dropMenu span", thisParent).html($(this).text()); } }); }) if ($(".colPage").hasClass("scrollSlide")) { scrollPosition = ($(".scrollSlide").offset().top) - ($(window).height() / 2); var body = $("html, body"); body.stop().animate({ scrollTop: scrollPosition }, 300, 'swing'); } }) $(window).on("resize", function () { videoSliderRatio(); videoPageRatio(); }) function videoSliderRatio() { vsrWidth = parseInt($(".hbtvsSlider .swiper-slide").width()); vsrRatio = 210.6 / 375; /*console.log(vsrWidth + "-" + vsrRatio);*/ vsrHeight = vsrWidth * vsrRatio; /*console.log(vsrHeight);*/ $(".hbtvsSlider video").css("height", vsrHeight + "px"); } function videoPageRatio() { vsrWidth = parseInt($(".hbptMainImage").width()); vsrRatio = 199 / 365; /*console.log(vsrWidth + "-" + vsrRatio);*/ vsrHeight = vsrWidth * vsrRatio; /*console.log(vsrHeight);*/ $(".hbptMainImage video").css("height", vsrHeight + "px"); } $(window).on("load", function () { if (typeof Swiper != 'undefined') { $(".vsldYzr").each(function (index, value) { $(this).parent().addClass("vsldYzr" + index); new Swiper(this, { direction: 'horizontal', slidesPerColumn: 2, touchStartPreventDefault: false, pagination: { el: '.vsldYzr' + index + ' .swiper-pagination', }, navigation: { nextEl: '.vsldYzr' + index + ' .swiper-button-next', prevEl: '.vsldYzr' + index + ' .swiper-button-prev', } }); }); $(".hbglqz").each(function (index, value) { $(this).parent().parent().addClass("hbglqz" + index); new Swiper(this, { loop: true, touchStartPreventDefault: false, pagination: { el: '.hbglqz' + index + ' .swiper-pagination', clickable: true, renderBullet: function (index, className) { return '' + (index + 1) + ''; } }, navigation: { nextEl: '.hbglqz' + index + ' .swiper-button-next', prevEl: '.hbglqz' + index + ' .swiper-button-prev', } }); }); } $(".generalHeader:not(.gamegarhd)").addClass("active"); }); $(window).on("scroll", function () { var scrollpx = (location.pathname == '/' || location.pathname.substring(location.pathname.length - 8) == '-haberi/' ? 0 : 18); scrollTop = $(this).scrollTop(); if (scrollTop >= scrollpx) { $(".generalHeader:not(.gamegarhd)").addClass("active"); } else { $(".generalHeader:not(.gamegarhd)").removeClass("active"); } if (scrollTop >= 95) { $(".otherHeader").addClass("active"); $(".hbMain:not(.gamegarmain)").addClass("stickypadding"); } else { $(".otherHeader").removeClass("active"); $(".hbMain:not(.gamegarmain)").removeClass("stickypadding"); } if (scrollTop >= 148) { $(".generalHeader.gamegarhd").addClass("active"); $(".gamegarmain").addClass("stickypadding"); } else { $(".generalHeader.gamegarhd").removeClass("active"); $(".gamegarmain").removeClass("stickypadding"); } }); function manset_adv_aktivite(id, tur) { var req = new XMLHttpRequest(); if (req) { req.open('GET', 'https://worker.haberler.com/SaveAdvImpression?advId=' + id + '&isClick=' + tur, true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-9'); req.send(); } } const sliderContainer = document.querySelector('.new3slider-container'); const slider = document.querySelector('.new3slider'); let slides = Array.from(document.querySelectorAll('.new3slide')); let currentIndex = 1; const visibleBullets = 25; let isSwiping = false, startX = 0, startY = 0; let isTransitioning = false; function setupSlider() { currentIndex = 1; const existingClones = slider.querySelectorAll('.new3slide.cloned'); existingClones.forEach(clone => clone.remove()); slides = Array.from(document.querySelectorAll('.new3slider > .new3slide')); const firstSlide = slides[0].cloneNode(true); firstSlide.classList.add('cloned'); const lastSlide = slides[slides.length - 1].cloneNode(true); lastSlide.classList.add('cloned'); slider.appendChild(firstSlide); slider.insertBefore(lastSlide, slides[0]); slides = Array.from(document.querySelectorAll('.new3slide')); slider.style.transition = 'none'; slider.style.transform = `translateX(-${currentIndex * 100}%)`; const images = slider.querySelectorAll('img'); const promises = Array.from(images).map(image => new Promise(resolve => { if (image.complete) { resolve(); } else { image.onload = resolve; image.onerror = resolve; } })); Promise.all(promises).then(() => { updateBullets(); updateActiveBullet(); }); } function updateBullets() { let bulletsContainer = document.querySelector('.new3bullets'); if (!bulletsContainer) { bulletsContainer = document.createElement('div'); bulletsContainer.className = 'new3bullets'; sliderContainer.appendChild(bulletsContainer); } else { bulletsContainer.innerHTML = ''; } const realSlideCount = slides.length - 2; const bulletCount = Math.min(visibleBullets, realSlideCount); if (realSlideCount <= 0) { bulletsContainer.style.display = 'none'; return; } else { bulletsContainer.style.display = ''; } for (let i = 0; i < bulletCount; i++) { const bullet = document.createElement('span'); bullet.className = 'new3bullet'; bullet.dataset.slide = i + 1; bullet.textContent = window.innerWidth >= 768 ? i + 1 : ''; bulletsContainer.appendChild(bullet); } bulletsContainer.removeEventListener('click', handleBulletClick); bulletsContainer.addEventListener('click', handleBulletClick); bulletsContainer.removeEventListener('mouseover', handleBulletMouseover); bulletsContainer.addEventListener('mouseover', handleBulletMouseover); updateActiveBullet(); } function handleBulletClick(e) { const bullet = e.target.closest('.new3bullet'); if (bullet) { const index = parseInt(bullet.dataset.slide, 10); moveToSlide(index); } } const handleBulletMouseover = debounce((e) => { if (window.innerWidth >= 768) { const bullet = e.target.closest('.new3bullet'); if (bullet) { moveToSlide(parseInt(bullet.dataset.slide, 10)); } } }, 100); function updateActiveBullet() { const bullets = document.querySelectorAll('.new3bullet'); let realSlideIndex; // Check if currentIndex is pointing to a cloned slide and adjust accordingly if (currentIndex === 0) { // If it's the cloned last slide realSlideIndex = slides.length - 2 - 1; // Corresponds to the last real slide (0-indexed) } else if (currentIndex === slides.length - 1) { // If it's the cloned first slide realSlideIndex = 1 - 1; // Corresponds to the first real slide (0-indexed) } else { realSlideIndex = currentIndex - 1; // For real slides } bullets.forEach((bullet, index) => { bullet.classList.toggle('active', index === realSlideIndex); }); } function updateSliderPosition() { if (isTransitioning) return; isTransitioning = true; requestAnimationFrame(() => { slider.style.transition = 'transform 0.2s ease-out'; slider.style.transform = `translateX(-${currentIndex * 100}%)`; slides.forEach(slide => slide.classList.remove('active')); if (slides[currentIndex]) slides[currentIndex].classList.add('active'); updateActiveBullet(); const onTransitionEnd = () => { slider.removeEventListener('transitionend', onTransitionEnd); isTransitioning = false; if (currentIndex === slides.length - 1) { slider.style.transition = 'none'; currentIndex = 1; slider.style.transform = `translateX(-${currentIndex * 100}%)`; requestAnimationFrame(() => { slider.offsetHeight; slider.style.transition = 'transform 0.2s ease-out'; }); } else if (currentIndex === 0) { slider.style.transition = 'none'; currentIndex = slides.length - 2; slider.style.transform = `translateX(-${currentIndex * 100}%)`; requestAnimationFrame(() => { slider.offsetHeight; slider.style.transition = 'transform 0.2s ease-out'; }); } }; slider.addEventListener('transitionend', onTransitionEnd); }); } function moveToNextSlide() { if (isTransitioning) return; currentIndex++; updateSliderPosition(); } function moveToPrevSlide() { if (isTransitioning) return; currentIndex--; updateSliderPosition(); } function moveToSlide(slideIndex) { if (isTransitioning || currentIndex === slideIndex) return; currentIndex = slideIndex; updateSliderPosition(); } document.addEventListener("visibilitychange", function () { if (document.visibilityState === "visible") { setupSlider(); } }); window.addEventListener('DOMContentLoaded', () => { removeNew3Container(); setupSlider(); document.querySelector('.next').addEventListener('click', moveToNextSlide); document.querySelector('.prev').addEventListener('click', moveToPrevSlide); if (isMobileDevice()) { addTouchEvents(); } }); function isMobileDevice() { return 'ontouchstart' in window || navigator.maxTouchPoints > 0; } function addTouchEvents() { let startX = 0; let moveX = 0; let threshold = 50; slider.addEventListener('touchstart', (e) => { if (e.touches.length === 1) { startX = e.touches[0].clientX; moveX = 0; } }, { passive: true }); slider.addEventListener('touchmove', (e) => { if (e.touches.length === 1) { moveX = e.touches[0].clientX - startX; if (Math.abs(moveX) > 10 && Math.abs(e.touches[0].clientY - startY) < Math.abs(moveX)) { e.preventDefault(); } } }, { passive: false }); slider.addEventListener('touchend', () => { if (Math.abs(moveX) > threshold) { if (moveX < 0) { moveToNextSlide(); } else { moveToPrevSlide(); } } moveX = 0; }); } function removeNew3Container() { document.querySelectorAll(".new3slide a[class*='rekkklam'] .new3container").forEach(el => el.remove()); } function debounce(func, delay) { let timeout; return function (...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), delay); }; } window.addEventListener('resize', debounce(updateBullets, 200)); /* anasayfa manşet slider */ const loadAdJsText = function (ur, ps, ce = {}) { var xexport = { elm: '', addatt: function (elm, ky) { if (0 !== Object.keys(ky).length) for (const [k, v] of Object.entries(ky)) elm.setAttribute(k, v); return elm; }, capp: function (c) { var dv = document.createElement('div'); dv.innerHTML = c; dv = dv.firstChild; const attrs = Object.values(dv.attributes).reduce((acc, b) => { return { ...acc, [b.name]: b.value }; }, {}); var nv = document.createElement(dv.nodeName); nv = xexport.addatt(nv, attrs); nv.innerHTML = dv.innerHTML; xexport.elm.insertAdjacentElement('afterbegin', nv); } } var req = new XMLHttpRequest(); req.open('GET', ur, true); req.onload = () => { var cwh = document.createElement('div'); cwh = xexport.addatt(cwh, ce); xexport.elm = cwh; var reqText = req.responseText; reqText = reqText.replace(/document.write/g, 'ldadMastHead.capp'); var adScript = document.createElement('script'); adScript.type = 'text/javascript'; adScript.text = reqText; cwh.insertAdjacentElement('afterbegin', adScript); document.getElementById(ps).insertAdjacentElement('afterbegin', cwh); }; req.send(); return xexport; };