1function selectAndScroll(selektor) { 2 var element = document.querySelector(selektor); 3 4 if (element) { 5 // Zastosowanie czerwonego obramowania 6 element.style.border = "2px solid red"; 7 8 // PrzewiniÄcie do elementu 9 element.scrollIntoView({ behavior: "smooth", block: "center" }); 10 } else { 11 console.log("Element nie zostaÅ znaleziony."); 12 } 13} 14 15// Zwraca kontener treÅci artykuÅu uwzglÄdniajÄ c wrapper TTS 16function getEntryContentContainer() { 17 return document.querySelector(".entry-content .tts_content_wrapper_1") || document.querySelector(".entry-content"); 18} 19 20function generateSelectorFromElement(elem) { 21 // W tym przypadku tworzymy selektor na podstawie tagu i klas elementu. 22 // To może nie byÄ idealne dla wszystkich przypadków, ale powinno dziaÅaÄ w wielu sytuacjach. 23 return `${elem.tagName.toLowerCase()}${elem.className ? "." + Array.from(elem.classList).join(".") : "" 24 }`; 25} 26 27function reorganizeRelatedTeasers() { 28 // Create empty array for articles 29 var allArticles = []; 30 var promos = []; 31 32 // Find all .post-teaser-group 33 var postTeaserGroups = document.querySelectorAll( 34 ".entry-related-teasers .post-teaser-group" 35 ); 36 37 // Loop through all .post-teaser-group 38 for (var i = 0; i < postTeaserGroups.length; i++) { 39 // Find all article 40 var articles = postTeaserGroups[i].querySelectorAll("article"); 41 42 // Loop through all articles 43 for (var j = 0; j < articles.length; j++) { 44 if (articles[j].classList.contains("is-promo")) { 45 promos.push(articles[j]); 46 } else { 47 allArticles.push(articles[j]); 48 } 49 } 50 } 51 52 // console.log("allArticles", allArticles); 53 // console.log("promos", promos); 54 55 // Znajdź kontener, do którego chcesz przenieÅÄ pierwszy element z klasÄ .is-promo 56 var targetContainer = document.querySelector( 57 ".entry-most-viewed .post-teaser-group .row" 58 ); 59 60 // Jeżeli kontener i promos istniejÄ , przenieÅ pierwszy element z klasÄ .is-promo 61 if (targetContainer && promos.length > 0) { 62 var firstPromo = promos.shift(); // UsuÅ pierwszy element z tablicy promos 63 64 // Otocz firstPromo elementem div z klasÄ "col-xs-12 col-sm-6 col-md-4" 65 var column = document.createElement("div"); 66 column.className = "col-xs-12 col-sm-6 col-md-4"; 67 column.appendChild(firstPromo); 68 69 // JeÅli w targetContainer jest 3 lub wiÄcej dzieci, usuÅ ostatnie 70 while (targetContainer.children.length >= 3) { 71 targetContainer.removeChild(targetContainer.lastElementChild); 72 } 73 74 // Dodaj firstPromo na poczÄ tek targetContainer 75 targetContainer.insertBefore(column, targetContainer.firstChild); 76 } 77 78 if (isMobile()) { 79 // Wstaw promos za co drugi paragraph w entry-content 80 var contentContainer = getEntryContentContainer(); 81 var entryContentParagraphs = contentContainer.querySelectorAll(":scope > p"); 82 83 if (entryContentParagraphs.length && promos.length) { 84 var promoIndex = 0; 85 for ( 86 var i = 1; 87 i < entryContentParagraphs.length && promoIndex < promos.length; 88 i += 2 89 ) { 90 var promo = promos[promoIndex]; 91 var destinationSelector = generateSelectorFromElement( 92 entryContentParagraphs[i] 93 ); 94 moveElement( 95 generateSelectorFromElement(promo), 96 destinationSelector, 97 "after" 98 ); 99 promoIndex++; 100 } 101 } 102 } else { 103 const insertPositions = [1, 3, 4, 6, 8]; 104 // Wstaw pozostaÅe elementy z tablicy promos na pozycje zdefiniowane w insertPositions 105 for (var i = 0; i < insertPositions.length; i++) { 106 if (promos[i]) { 107 allArticles.splice(insertPositions[i], 0, promos[i]); 108 } 109 } 110 111 var container = document.querySelector(".entry-related-teasers"); 112 113 // Empty container 114 container.innerHTML = ""; 115 116 var groupSize = 4; // Number of articles in each group 117 for (var i = 0; i < allArticles.length; i += groupSize) { 118 var group = document.createElement("div"); 119 group.className = "post-teaser-group"; 120 var row = document.createElement("div"); 121 row.className = "row"; 122 123 for (var j = i; j < i + groupSize && j < allArticles.length; j++) { 124 if (!allArticles[j]) { 125 j++; 126 if (!allArticles[j]) { 127 continue; 128 } 129 } 130 var column = document.createElement("div"); 131 column.className = "col-xs-12 col-sm-6 col-md-6 col-lg-3"; 132 column.appendChild(allArticles[j]); 133 row.appendChild(column); 134 } 135 136 group.appendChild(row); 137 container.appendChild(group); 138 } 139 } 140} 141 142function filterArticlesInSection(section, indicesToKeep) { 143 if (section) { 144 let articles = section.querySelectorAll("article.post-teaser"); 145
146 articles.forEach((article, index) => { 147 if (!indicesToKeep.includes(index)) { 148 article.remove(); 149 } 150 }); 151 } 152} 153 154function onResize() { 155 /** Mobile devices */ 156 if (isMobile()) { 157 let previousMenuPositionLeft = 0; 158 let currentClickPosition = 0; 159 160 $(".subcategories-menu").on("touchmove", function (event) { 161 let maximum = 0; 162 163 let menuItemsWidth = 0; 164 165 $(".subcategories-menu > *").each(function () { 166 menuItemsWidth += $(this).width(); 167 }); 168 169 let subcategoriesAmount = $(".subcategories-menu .subcategory").length; 170 let minimum = 171 (menuItemsWidth - 172 $(".subcategories-menu").width() + 173 subcategoriesAmount * 10 + 174 20) * 175 -1; 176 177 let positionLeft = Math.max( 178 Math.min( 179 event.touches[0].clientX - 180 currentClickPosition + 181 previousMenuPositionLeft, 182 maximum 183 ), 184 minimum 185 ); 186 187 $(".subcategories-menu").css("left", positionLeft); 188 }); 189 190 $(".subcategories-menu").on("touchstart", function (event) { 191 previousMenuPositionLeft = parseInt($(".subcategories-menu").css("left")); 192 currentClickPosition = event.touches[0].clientX; 193 }); 194 195 /** Mobile Home Page */ 196 if (isHomePage()) { 197 // Multi content box container (direct ancestor of col-aside) 198 const multiContentBox = document.querySelector(".multi-content-box"); 199 200 // Section "Latest Articles" 201 const latestArticles = document.querySelector("#latest-articles"); 202 203 // Billboard content 204 const billboardContent = document.querySelector( 205 ".promo-area.billboard_content" 206 ); 207 208 // Section "Parallax" 209 const parallaxSection = document.querySelector("#parallax-section"); 210 211 // Medium rectangle sidebar top 212 const mediumRectangleSidebarTop = 213 document.querySelector(".mrst_homepage"); 214 215 // Hero section 216 const heroSection = document.querySelector(".site-section--hero"); 217 218 // Category sections 219 const categorySections = document.querySelectorAll( 220 "#main > .site-section--category" 221 ); 222 223 // Declare array with indices of articles to keep in each section 224 const indicesForSections = [ 225 [0, 1, 4], 226 [0, 1], 227 [0, 1], 228 [0, 1, 2], 229 [0, 1, 2], 230 [0, 1, 2], 231 [0, 1, 2], 232 [0, 1, 2], 233 [0, 1, 2], 234 ]; 235 236 categorySections.forEach((section, index) => { 237 // data-cash-mh: Block wurde schon beim Parsen umgebaut (inc/hooks/cls-stabilisierung.php) 238 if (index < indicesForSections.length && !section.dataset.cashMh) { 239 filterArticlesInSection(section, indicesForSections[index]); 240 } 241 }); 242 243 // Latest articles it's always after 4th category 244 if (latestArticles) { 245 moveElement(latestArticles, categorySections[3], "after"); 246 } 247 248 let secondArticleInFirstCategory = null; 249 250 // Check if categorySections[0] exists and has at least 2 articles 251 if ( 252 categorySections.length > 0 && 253 categorySections[0].querySelectorAll("article").length >= 2 254 ) { 255 secondArticleInFirstCategory = 256 categorySections[0].querySelectorAll("article")[1]; 257 } 258 259 if (secondArticleInFirstCategory && billboardContent) { 260 moveElement(billboardContent, secondArticleInFirstCategory, "before"); 261 } 262 263 // Move #parallax-section before 2nd category 264 if (parallaxSection && categorySections[1]) { 265 moveElement(parallaxSection, categorySections[1], "before"); 266 } 267 268 // Move .mrst_homepage ater hero section 269 if (mediumRectangleSidebarTop && heroSection) { 270 moveElement(mediumRectangleSidebarTop, heroSection, "after"); 271 } 272 273 // Remove margin-bottom from .medium_rectangle_sidebar_top inside mediumRectangleSidebarTop 274 const mediumRectangleSidebarTopInside = mediumRectangleSidebarTop 275 ? mediumRectangleSidebarTop.querySelector( 276 ".medium_rectangle_sidebar_top" 277 ) 278 : null; 279 if (mediumRectangleSidebarTopInside) { 280 mediumRectangleSidebarTopInside.style.marginBottom = "8px"; 281 } 282 } 283 284 if (isArchivePage()) { 285 // Umbau steht in assets/scripts/mobil-umbau.js und läuft schon beim Parsen 286 // (inc/hooks/cls-stabilisierung.php); hier nur noch aufrufen â idempotent. 287 if (window.cashArchivUmbau) { 288 window.cashArchivUmbau(); 289 } 290 } 291 292 if (isArticlePage()) { 293 // Find all paragraphs and filter empty ones 294 let contentContainer = getEntryContentContainer(); 295 let paragraphs = contentContainer.querySelectorAll(":scope > p"); 296 297 paragraphs.forEach((paragraph) => { 298 if (paragraph.textContent.trim() === "") { 299 paragraph.remove(); 300 } 301 }); 302 303 paragraphs = Array.from(paragraphs).filter( 304 (p) => p.textContent.trim() !== "" 305 ); 306 307 // Count how many paragraphs are in article 308 const paragraphsCount = paragraphs.length; 309 const parallaxMobile = document.querySelector(".parallax_mobile"); 310 const mediumRectangleSidebarTop = document.querySelector( 311 ".medium_rectangle_sidebar_top" 312 ); 313 const entryTitle = document.querySelector(".entry-title"); 314 const entryExcerpt = document.querySelector(".entry-excerpt"); 315 const entryContent = document.querySelector(".entry-content"); 316 const siteFooter = document.querySelector(".site-footer"); 317 const candyTabsPostlist = document.querySelector(".candy_tabs-postlist"); 318 const multiContentBox = document.querySelector(".multi-content-box"); 319 const authorShareBox = document.querySelector(".author-share-box"); 320 const mehrDazuLesen = document.querySelector(".entry-most-viewed"); 321 const mehrDazuLesenContent = document.querySelector( 322 ".entry-most-viewed .post-teaser-group .row div" 323 ); 324 const mehrDazuLesenRow = document.querySelector( 325 ".entry-most-viewed .post-teaser-group .row" 326 ); 327 const entryFooter = document.querySelector(".entry-footer"); 328 const mediumRectangleContentTop = document.querySelector( 329 ".medium_rectangle_content_top" 330 ); 331 const mediumRectangleSidebarBottom = document.querySelector( 332 ".medium_rectangle_sidebar_bottom" 333 ); 334 335 // Find first ancestor with class 'col--aside' for '.newest_issue' 336 const asideNewestIssue = document.querySelector(".newest_issue"); 337 const asideIssueAndAward = asideNewestIssue 338 ? asideNewestIssue.closest(".col--aside") 339 : null; 340 341 const weitereArtikelGroups = document.querySelectorAll( 342 ".entry-related-teasers .post-teaser-group" 343 ); 344 345 // Find first ancestor with class 'container' for '.billboard_content' 346 const billboardElement = document.querySelector(".billboard_content"); 347 const billboardContent = billboardElement 348 ? billboardElement.closest(".container") 349 : null; 350 351 // commentSection is first ancestor with class 'container' for '#comments' 352 const commentElement = document.querySelector("#comments"); 353 const commentSection = commentElement.closest(".container"); 354 355 const teaserUif = document.querySelector(".teaser-uif"); 356 357 // Remove margins from commentElement 358 commentElement.style.margin = "0"; 359 360 // Set margin-bottom of #wpdcom to 0 361 const wpdcom = document.querySelector("#wpdcom"); 362 if (wpdcom) { 363 wpdcom.style.marginBottom = "0"; 364 } 365 366 // Set padding-bottom of .wpd-thread-list to 0 367 const wpdThreadList = document.querySelector(".wpd-thread-list"); 368 if (wpdThreadList) { 369 wpdThreadList.style.paddingBottom = "0"; 370 } 371 372 let arePromosAfterCommentButton = false;
373 let billboardContentMovedToContentTop = false; 374 375 // Find all promo articles 376 let promoArticles = document.querySelectorAll( 377 "#main article.post-teaser.is-promo" 378 ); 379 380 // Find all paragraphs 381 // let paragraphs = document.querySelectorAll(".entry-content > p"); 382 // Already defined and filtered above 383 384 // Remove from promoArticles articles with ancestor with class 'candy_ajax-postlist' 385 promoArticles = Array.from(promoArticles).filter( 386 (article) => !article.closest(".candy_ajax-postlist") 387 ); 388 389 // Sort promoArticles by their position on the page 390 promoArticles.sort( 391 (a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top 392 ); 393 394 let lastPromoArticle = null; 395 396 // W elemencie mehrDazuLesenContent powinien znajdowaÄ siÄ tylko jeden artykuÅ, usuÅ wszystkie pozostale 397 if (mehrDazuLesenRow) { 398 while (mehrDazuLesenRow.children.length > 1) { 399 mehrDazuLesenRow.removeChild(mehrDazuLesenRow.lastElementChild); 400 } 401 } 402 403 // Put promoArticles after every second paragraph 404 for (let i = 0; i < paragraphs.length - 1; i += 2) { 405 if (promoArticles.length > 0) { 406 const promo = promoArticles.shift(); 407 408 // Insert hr at beginning and end of promo 409 const hrBefore = document.createElement("hr"); 410 const hrAfter = document.createElement("hr"); 411 412 // Position absolute for hr 413 hrBefore.style.position = "absolute"; 414 hrAfter.style.position = "absolute"; 415 416 // top -20px 417 hrBefore.style.top = "-30px"; 418 hrAfter.style.bottom = "-26px"; 419 420 // width 100% 421 hrBefore.style.width = "100%"; 422 hrAfter.style.width = "100%"; 423 424 // add 'entry-most-viewed__hr' class 425 hrBefore.classList.add("entry-most-viewed__hr"); 426 hrAfter.classList.add("entry-most-viewed__hr"); 427 428 promo.insertBefore(hrBefore, promo.firstChild); 429 promo.appendChild(hrAfter); 430 431 paragraphs[i + 1].parentNode.insertBefore( 432 promo, 433 paragraphs[i + 1].nextSibling 434 ); 435 436 // If body element has class 'paged-2' 437 // Sprawdź, czy body ma klasÄ pasujÄ cÄ do wzorca "single-paged-" z dowolnÄ liczbÄ na koÅcu 438 const hasSinglePagedClass = Array.from(document.body.classList).some( 439 (className) => /^single-paged-\d+$/.test(className) 440 ); 441 442 if (hasSinglePagedClass) { 443 // entry-page-links 444 const entryPageLinks = document.querySelector(".entry-page-links"); 445 446 // Move entryPageLinks after last p element 447 if (entryPageLinks) { 448 const lastParagraph = paragraphs[paragraphs.length - 1]; 449 console.log("lastParagraph", lastParagraph); 450 moveElement(entryPageLinks, lastParagraph, "after"); 451 } 452 } 453 } 454 } 455 456 // Put rest of promoArticles after entryFooter 457 while (promoArticles.length > 0) { 458 const promo = promoArticles.shift(); 459 entryFooter.parentNode.insertBefore(promo, entryFooter.nextSibling); 460 461 // if it's first iteration then save promo as lastPromoArticle 462 if (!lastPromoArticle) { 463 lastPromoArticle = promo; 464 } 465 466 arePromosAfterCommentButton = true; 467 } 468 469 // // Move .entry-excerpt after .entry-title 470 // moveElement(entryExcerpt, entryTitle, "after"); 471 472 // Move .candy_tabs-postlist before #colophon 473 moveElement(candyTabsPostlist, siteFooter, "before"); 474 475 if (!authorShareBox) { 476 moveElement(multiContentBox, entryContent, "before"); 477 } else { 478 // Move .multi-content-box before .author-share-box 479 moveElement(multiContentBox, authorShareBox, "before"); 480 } 481 482 // Set padding to 0 for .entry-content 483 if (candyTabsPostlist) { 484 candyTabsPostlist.style.padding = "0 16px"; 485 } 486 487 // Set margin-bottom to 32px for .entry-footer 488 if (entryFooter) { 489 entryFooter.style.marginBottom = "32px"; 490 } 491 492 // Keep FLB below the teaser text on mobile article pages and move CAD1 into the text. 493 if (mediumRectangleSidebarTop) { 494 mediumRectangleSidebarTop.style.marginTop = "24px"; 495 mediumRectangleSidebarTop.style.marginBottom = "24px"; 496 497 if (paragraphs[2]) { 498 moveElement(mediumRectangleSidebarTop, paragraphs[2], "before"); 499 } else if (paragraphs[1]) { 500 if (paragraphs[1].nextElementSibling) { 501 moveElement(mediumRectangleSidebarTop, paragraphs[1].nextElementSibling, "before"); 502 } else { 503 moveElement(mediumRectangleSidebarTop, entryFooter, "before"); 504 } 505 } else { 506 moveElement(mediumRectangleSidebarTop, entryFooter, "before"); 507 } 508 } 509 510 // On mobile article pages, use FLB2 in the medium_rectangle_content_top slot position 511 // and reserve the maximum configured slot height for the current breakpoint. 512 if (billboardContent && mediumRectangleContentTop) { 513 const billboardContentReservedHeight = getBusinessAdReservedHeight( 514 "FLB2", 515 300 516 ); 517 518 billboardContentMovedToContentTop = true; 519 billboardContent.style.setProperty("display", "block", "important"); 520 billboardContent.style.marginTop = "24px"; 521 billboardContent.style.marginBottom = "24px"; 522 523 if (billboardElement) { 524 billboardElement.style.setProperty("display", "block", "important"); 525 } 526
527 const billboardContentContainer = billboardContent.querySelector( 528 ".promo-area__container" 529 ); 530 if (billboardContentContainer) { 531 billboardContentContainer.style.minHeight = `${billboardContentReservedHeight}px`; 532 } 533 534 const billboardContentSlot = billboardContent.querySelector("#Ads_BA_FLB2"); 535 if (billboardContentSlot) { 536 billboardContentSlot.style.minHeight = `${billboardContentReservedHeight}px`; 537 } 538 539 mediumRectangleContentTop.parentNode.insertBefore( 540 billboardContent, 541 mediumRectangleContentTop 542 ); 543 mediumRectangleContentTop.remove(); 544 } 545 546 547 // Check if .parallax_mobile is booked - REMOVED 548 // if (hasChildren(parallaxMobile)) { 549 // // Move .medium_rectangle_content_top 2 paragraphs after .parallax_mobile 550 551 // // If there is less 4 paragraphs in article 552 // if (paragraphsCount < 4) { 553 // moveElement(mediumRectangleContentTop, entryFooter, "before"); 554 // } else { 555 // moveElement( 556 // mediumRectangleContentTop, 557 // parallaxMobile, 558 // "after", 559 // "p", 560 // 2 561 // ); 562 // } 563 // } else { 564 // // Move .medium_rectangle_content_top before 3rd paragraph 565 // if (paragraphs[2]) { 566 // moveElement(mediumRectangleContentTop, paragraphs[2], "before"); 567 // } else { 568 // moveElement(mediumRectangleContentTop, entryFooter, "before"); 569 // } 570 // } 571 572 if (mehrDazuLesen && parallaxMobile) { 573 moveElement(mehrDazuLesen, parallaxMobile, "after"); 574 } else if (mehrDazuLesen && !parallaxMobile) { 575 // Move mehrDazuLesen before 3rd paragraph 576 moveElement(mehrDazuLesen, paragraphs[2], "before"); 577 } 578 579 if (arePromosAfterCommentButton) { 580 // Put commentSection after last promoArticle 581 moveElement(commentSection, lastPromoArticle, "after"); 582 } else { 583 // Put commentSection after entryFooter 584 moveElement(commentSection, entryFooter, "after"); 585 } 586 587 // Move billboardContent after commentSection 588 if (billboardContent && !billboardContentMovedToContentTop) { 589 moveElement(billboardContent, commentSection, "after"); 590 } 591 592 if (mediumRectangleSidebarBottom) { 593 if (billboardContent && !billboardContentMovedToContentTop) { 594 moveElement(mediumRectangleSidebarBottom, billboardContent, "after"); 595 } else { 596 moveElement(mediumRectangleSidebarBottom, commentSection, "after"); 597 } 598 } 599 600 // Check if weitereArtikelGroups exist and if contain 3 or more elements 601 if (weitereArtikelGroups && weitereArtikelGroups.length === 3) { 602 // Move teaserUif after 1st weitereArtikelGroup 603 if (teaserUif) { 604 moveElement(teaserUif, weitereArtikelGroups[0], "after"); 605 } 606 607 // Move asideIssueAndAward after 2nd weitereArtikelGroup 608 if (asideIssueAndAward) { 609 moveElement(asideIssueAndAward, weitereArtikelGroups[1], "after"); 610 } 611 } 612 613 // If body element has class 'paged-2' 614 const hasSinglePagedClass = Array.from(document.body.classList).some( 615 (className) => /^single-paged-\d+$/.test(className) 616 ); 617 if (hasSinglePagedClass) { 618 const entryPageLinks = document.querySelector(".entry-page-links"); 619 const entryFooter = document.querySelector(".entry-footer"); 620 const mediumRectangleContentTop = document.querySelector( 621 ".medium_rectangle_content_top" 622 ); 623 // multi-content-box 624 const multiContentBox = document.querySelector(".multi-content-box"); 625 const parallaxDesktop = document.querySelector(".parallax_desktop"); 626 627 if (mediumRectangleContentTop) { 628 // move medium_rectangle_content_top before entryFooter 629 moveElement(mediumRectangleContentTop, entryFooter, "before"); 630 } 631 632 if (multiContentBox) { 633 // Move multi-content-box before entryFooter 634 moveElement(multiContentBox, entryFooter, "before"); 635 } 636 637 if (mediumRectangleSidebarTop) { 638 // Move medium_rectangle_sidebar_top before entryFooter 639 moveElement(mediumRectangleSidebarTop, entryFooter, "before"); 640 } 641 642 // Move entryPageLinks after last p element 643 if (entryPageLinks) { 644 let lastParagraph; 645 if (paragraphs.length > 1) { 646 lastParagraph = paragraphs[paragraphs.length - 1]; 647 } else if (paragraphs.length === 1) { 648 lastParagraph = paragraphs[0]; 649 } 650 651 // change padding top to 0 of '.entry-page-links__title' 652 const entryPageLinksTitle = document.querySelector( 653 ".entry-page-links__title" 654 ); 655 if (entryPageLinksTitle) { 656 entryPageLinksTitle.style.paddingTop = "0"; 657 } 658 659 // entryPageLinks.style.padding = "12px 0"; 660 661 // console.log("lastParagraph", lastParagraph); 662 console.log("lastParagraph", lastParagraph); 663 moveElement(entryPageLinks, lastParagraph, "after"); 664 } 665 } 666 667 const promoArticle = document.querySelectorAll( 668 "article.post-teaser.is-promo" 669 ); 670 671 if (promoArticle.length > 0) { 672 for (let i = 0; i < promoArticle.length; i++) { 673 const promoNextSibling = promoArticle[i].nextElementSibling; 674 if ( 675 promoNextSibling && 676 promoNextSibling.classList.contains("entry-most-viewed") 677 ) { 678 console.log("promoArticle[i]", promoArticle[i]); 679 // Remove last hr element inside promo 680 promoArticle[i].querySelector("hr:last-of-type").remove();
681 promoArticle[i].style.paddingBottom = "0px"; 682 } 683 } 684 } 685 } else { 686 /** Desktop devices */ 687 688 if (isArticlePage()) { 689 let contentContainer = getEntryContentContainer(); 690 let paragraphs = contentContainer.querySelectorAll(":scope > p"); 691 692 // Remove empty paragraphs 693 paragraphs.forEach((paragraph) => { 694 if (paragraph.textContent.trim() === "") { 695 paragraph.remove(); 696 } 697 }); 698 699 // Remove empty paragraphs from paragraphs array 700 paragraphs = Array.from(paragraphs).filter( 701 (p) => p.textContent.trim() !== "" 702 ); 703 704 changeNewsletterBanerToUnternehmen(); 705 reorganizeRelatedTeasers(); 706 // If body element has class 'paged-2' 707 const hasSinglePagedClass = Array.from(document.body.classList).some( 708 (className) => /^single-paged-\d+$/.test(className) 709 ); 710 if (hasSinglePagedClass) { 711 const entryPageLinks = document.querySelector(".entry-page-links"); 712 const entryFooter = document.querySelector(".entry-footer"); 713 const mediumRectangleContentTop = document.querySelector( 714 ".medium_rectangle_content_top" 715 ); 716 const parallaxDesktop = document.querySelector(".parallax_desktop"); 717 718 if (mediumRectangleContentTop) { 719 // move medium_rectangle_content_top before entryFooter 720 moveElement(mediumRectangleContentTop, entryFooter, "before"); 721 } 722 723 // Move entryPageLinks after last p element 724 if (entryPageLinks) { 725 let lastParagraph; 726 if (paragraphs.length > 1) { 727 lastParagraph = paragraphs[paragraphs.length - 1]; 728 } else if (paragraphs.length === 1) { 729 lastParagraph = paragraphs[0]; 730 } 731 732 // console.log("lastParagraph", lastParagraph); 733 console.log("lastParagraph", lastParagraph); 734 moveElement(entryPageLinks, lastParagraph, "after"); 735 } 736 } 737 } 738 739 if (isArchivePage()) { 740 removePaddingIfNoChildren( 741 ".col-xs-12.col-md-4.col--aside", 742 "0 10px 2rem 10px" 743 ); 744 // Get .multi-content-box and change margin-top to 0 745 const multiContentBox = document.querySelector(".multi-content-box"); 746 if (multiContentBox) { 747 multiContentBox.style.marginTop = "12px"; 748 } 749 } 750 751 const billboardHeader = document.querySelector(".billboard_header"); 752 if (billboardHeader && billboardHeader.clientHeight > 0) { 753 billboardHeader.style.marginTop = "0"; 754 } 755 } 756 removePaddingIfNoChildren(".col-xs-12.col-md-4.col--aside"); 757 } 758} 759 760function changeNewsletterBanerToUnternehmen() { 761 // Znajdź rodzica a elementu '.candy_newsletter_teaser' 762 const newsletterBaner = document.querySelector( 763 ".candy_newsletter_teaser" 764 ).parentNode; 765 const unternehmenBaner = document.querySelector(".teaser-uif"); 766 767 if (newsletterBaner && unternehmenBaner) { 768 // W miejsce newsletterBaner wstaw unternehmenBaner 769 newsletterBaner.parentNode.replaceChild(unternehmenBaner, newsletterBaner); 770 } 771} 772 773function isArticlePage() { 774 return document.body.classList.contains("single-post"); 775} 776 777function removePaddingIfNoChildren(elementSelector, padding = "0") { 778 // Find element col-xs-12 col-md-4 col--aside 779 const colAside = document.querySelector(elementSelector); 780 781 // Check if colAside exists and has children 782 if (colAside && colAside.children.length == 0) { 783 colAside.style.padding = "0"; 784 } else if (colAside && colAside.children.length > 0) { 785 colAside.style.padding = padding; 786 } 787} 788 789function isHomePage() { 790 return document.body.classList.contains("home"); 791} 792 793function isArchivePage() { 794 return document.body.classList.contains("archive"); 795} 796 797function isPageWithId(id) { 798 return document.body.classList.contains("page-id-" + id); 799} 800 801function isCategoryPage() { 802 return document.body.classList.contains("category"); 803} 804 805// Funkcja pomocnicza do sprawdzania dzieci elementu 806function hasChildren(target) { 807 // Sprawdzenie i przypisanie dla target 808 if (typeof target === "string") { 809 if (target.trim() === "") { 810 console.log("Pusty selektor dla 'target'. Operacja nieudana."); 811 return; 812 } 813 targetElement = document.querySelector(target); 814 } else { 815 targetElement = target; 816 } 817 818 return targetElement && targetElement.children.length > 0; 819} 820 821function isMobile() { 822 return screen.width < 800; 823} 824 825function getBusinessAdReservedHeight(slotName, fallbackHeight) { 826 const slotConfigs = window.__ba?.config?.slots?.[slotName];
827 if (!Array.isArray(slotConfigs) || slotConfigs.length === 0) { 828 return fallbackHeight; 829 } 830 831 const viewportWidth = 832 window.innerWidth || document.documentElement.clientWidth || 0; 833 const activeConfig = slotConfigs 834 .filter((slotConfig) => viewportWidth >= Number(slotConfig?.minWidth || 0)) 835 .sort( 836 (leftConfig, rightConfig) => 837 Number(rightConfig?.minWidth || 0) - Number(leftConfig?.minWidth || 0) 838 )[0]; 839 840 if (!activeConfig || !Array.isArray(activeConfig.sizes)) { 841 return fallbackHeight; 842 } 843 844 const heights = activeConfig.sizes 845 .map((size) => { 846 if (typeof size !== "string") { 847 return 0; 848 } 849 850 const [, height] = size.split("x"); 851 return Number(height || 0); 852 }) 853 .filter((height) => Number.isFinite(height) && height > 0); 854 855 return heights.length > 0 ? Math.max(...heights) : fallbackHeight; 856} 857 858function initMediumRectangleContentTopAdSlots() { 859 if (!document.body.classList.contains("single-post")) { 860 return; 861 } 862 863 const slotConfigByElementId = { 864 Ads_BA_CAD5: { slotName: "CAD5", fallbackHeight: 250 }, 865 Ads_BA_FLB: { slotName: "FLB", fallbackHeight: 300 }, 866 }; 867 868 document 869 .querySelectorAll(".entry-content .medium_rectangle_content_top") 870 .forEach((promoArea) => { 871 const slot = promoArea.querySelector("#Ads_BA_CAD5, #Ads_BA_FLB"); 872 if (!slot) { 873 return; 874 } 875 876 const slotConfig = slotConfigByElementId[slot.id]; 877 if (!slotConfig) { 878 return; 879 } 880 881 const container = promoArea.querySelector(".promo-area__container"); 882 883 const getReservedHeight = () => 884 getBusinessAdReservedHeight( 885 slotConfig.slotName, 886 slotConfig.fallbackHeight 887 ); 888 889 const reserveHeight = () => { 890 const reservedHeight = 250; 891 promoArea.style.minHeight = `${reservedHeight}px`; 892 if (container) { 893 container.style.minHeight = `${reservedHeight}px`; 894 } 895 slot.style.minHeight = `${reservedHeight}px`; 896 }; 897 898 const markFilled = () => { 899 promoArea.classList.add("has-ad"); 900 promoArea.classList.remove("is-ad-empty"); 901 reserveHeight(); 902 }; 903 904 const markEmpty = () => { 905 promoArea.classList.remove("has-ad"); 906 promoArea.classList.add("is-ad-empty"); 907 reserveHeight(); 908 }; 909 910 reserveHeight(); 911 912 slot.addEventListener("__baSlotIsRendered", reserveHeight); 913 slot.addEventListener("__baSlotIsFilled", markFilled); 914 slot.addEventListener("__baSlotIsEmpty", markEmpty); 915 916 const observer = new MutationObserver(() => { 917 if (promoArea.classList.contains("is-ad-empty")) { 918 return; 919 } 920 921 if ( 922 slot.querySelector("iframe, img") || 923 slot.textContent.trim().length > 0 924 ) { 925 markFilled(); 926 } 927 }); 928 929 observer.observe(slot, { 930 childList: true, 931 subtree: true, 932 characterData: true, 933 }); 934 }); 935} 936 937function initMediumRectangleSidebarTopAdSlots() { 938 if (!document.body.classList.contains("single-post") || isMobile()) { 939 return; 940 } 941 942 const reservedHeight = getBusinessAdReservedHeight("CAD", 600); 943 944 document 945 .querySelectorAll(".col--aside .medium_rectangle_sidebar_top") 946 .forEach((promoArea) => { 947 const slot = promoArea.querySelector("#Ads_BA_CAD"); 948 if (!slot) { 949 return; 950 } 951 952 const container = promoArea.querySelector(".promo-area__container"); 953 954 const reserveHeight = () => { 955 promoArea.style.minHeight = `${reservedHeight}px`; 956 if (container) { 957 container.style.minHeight = `${reservedHeight}px`; 958 } 959 slot.style.minHeight = `${reservedHeight}px`; 960 }; 961 962 reserveHeight(); 963 964 slot.addEventListener("__baSlotIsRendered", reserveHeight); 965 slot.addEventListener("__baSlotIsFilled", reserveHeight); 966 slot.addEventListener("__baSlotIsEmpty", reserveHeight); 967 }); 968} 969 970if (document.readyState === "loading") { 971 document.addEventListener("DOMContentLoaded", initMediumRectangleContentTopAdSlots); 972 document.addEventListener("DOMContentLoaded", initMediumRectangleSidebarTopAdSlots); 973} else { 974 initMediumRectangleContentTopAdSlots(); 975 initMediumRectangleSidebarTopAdSlots(); 976} 977 978(function ($) { 979 $(function () { 980 // If there is no author then remove author-share-box 981 if (!$(".author-share-box").children().length) { 982 $(".author-share-box").remove(); 983 } 984 985 onResize(); 986 987 $(document).ready(function () { 988 $(".subcategories-menu .select .select-options") 989 .last() 990 .addClass("last-options"); 991 }); 992 993 //searching in top menu 994 $(".show-search").on("click", function () { 995 $(this) 996 .closest(".container") 997 .find(".site-search .right-menu .right-menu-icons") 998 .fadeOut(100); 999 $(this) 1000 .closest(".container") 1001 .find(".right-menu-search") 1002 .delay(100) 1003 .fadeIn(100, function () { 1004 $(this) 1005 .closest(".container") 1006 .find(".search-input input[name=s]") 1007 .focus(); 1008 }); 1009 }); 1010 1011 $(".close-search").on("click", function () { 1012 $(".right-menu-search").fadeOut(100); 1013 $(".right-menu-icons").delay(100).fadeIn(100); 1014 }); 1015 1016 /* DROPDOWN */ 1017 1018 $("select").each(function () { 1019 var $this = $(this), 1020 numberOfOptions = $(this).children("option").length; 1021 1022 $this.addClass("select-hidden"); 1023 $this.wrap('<div class="select"></div>'); 1024 $this.after('<div class="select-styled"></div>'); 1025 1026 var $styledSelect = $this.next("div.select-styled"); 1027 $styledSelect.text($this.children("option").eq(0).text()); 1028 1029 var $list = $("<ul />", { 1030 class: "select-options", 1031 }).insertAfter($styledSelect); 1032 1033 for (var i = 0; i < numberOfOptions; i++) { 1034 $("<a />", { 1035 text: $this.children("option").eq(i).text(), 1036 href: $this.children("option").eq(i).val(), 1037 }).appendTo($list); 1038 //if ($this.children('option').eq(i).is(':selected')){ 1039 // $('li[rel="' + $this.children('option').eq(i).val() + '"]').addClass('is-selected') 1040 //} 1041 } 1042 1043 var $listItems = $list.children("li"); 1044 1045 $styledSelect.click(function (e) { 1046 e.stopPropagation(); 1047 $("div.select-styled.active") 1048 .not(this) 1049 .each(function () { 1050 $(this).removeClass("active").next("ul.select-options").hide(); 1051 $(this).next("ul.select-options").addClass("show-formatted"); 1052 }); 1053 if ($(this).next("ul.select-options").height() > 400) { 1054 $(this).next("ul.select-options").addClass("add-overflow"); 1055 } 1056 $(this).next("ul.select-options").addClass("show-formatted"); 1057 if ($(this).hasClass("active")) { 1058 $(this).removeClass("active").next("ul.select-options").hide(); 1059 } else { 1060 $(this).addClass("active").next("ul.select-options").show(); 1061 } 1062 // Add flash effect only for touch devices 1063 if ("ontouchstart" in window) { 1064 $(this).css("background", "#10214c"); 1065 setTimeout(function () { 1066 $styledSelect.css("background", ""); 1067 }, 100); // Change color back after 100ms 1068 } 1069 }); 1070 1071 $listItems.click(function (e) { 1072 e.stopPropagation(); 1073 $styledSelect.text($(this).text()).removeClass("active"); 1074 $this.val($(this).attr("rel")); 1075 $list.hide(); 1076 //console.log($this.val()); 1077 }); 1078 1079 $(document).click(function () { 1080 $styledSelect.removeClass("active"); 1081 $list.hide(); 1082 }); 1083 }); 1084 }); 1085})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.