1jQuery(document).ready(function ($) { 2 3 $("#boligvelger-filter .wp-block-button").click(function() { 4 $("#boligvelger-filter .wp-block-button").removeClass("active"); 5 $(".boligvelger-bilde").hide(); 6 $(this).addClass("active"); 7 var targetDiv = "#" + $(this).find("a").attr("rel"); 8 $(targetDiv).show(); 9 }) 10 11 $('.leilighet').each(function () { 12 const fullID = $(this).data('leilighets_id'); // eks: "32A-H0206" 13 const status = $(this).data('status'); // eks: "ledig" eller "opptatt" 14 const post_id = $(this).data("id"); 15 const kommer = $(this).data("kommer"); 16 17 if (!fullID) return; 18 19 // Finn polygon med eksakt match pÃ¥ ID 20 const $polygon = $(`polygon[id='${fullID}']`); 21 22 if ($polygon.length) { 23 $polygon.attr("data-ref", fullID).attr("data-status", status).attr("data-postid",post_id).attr("data-kommer",kommer); 24 25 if (status === 'ledig') { 26 $polygon.addClass('ledig'); 27 } else if (status === 'opptatt') { 28 $polygon.addClass('opptatt'); 29 } 30 } 31}); 32 33 var ajaxurl = "https://frost.no/wp-admin/admin-ajax.php"; 34 35 let isLoading = false; 36 37 $('polygon[data-postid]').on('click', function () { 38 if (isLoading) return; 39 isLoading = true; 40 41 $("#follow-mouse").hide(); 42 43 const postId = $(this).data('postid'); 44 if (!postId) { 45 isLoading = false; 46 return; 47 } 48 49 const $reveal = $('#leilighet-reveal'); 50 $reveal.addClass('is-visible'); 51 $reveal.find('.ajax-content').html(` 52 <div class="loading-indicator"> 53 <div class="spinner"></div> 54 <span>Laster innâ¦</span> 55 </div> 56 `); 57 58 59 // Legg til hash i URL uten Ã¥ scrolle til toppen 60 history.pushState(null, '', '#leilighet'); 61 62 $('html, body').animate({ 63 scrollTop: $('#leilighet-reveal').offset().top - 150 // juster offset her 64}, 400); 65 66 $.ajax({
67 url: ajaxurl, 68 type: 'POST', 69 data: { 70 action: 'load_leilighet_single', 71 post_id: postId 72 }, 73 success: function(response) { 74 $reveal.find('.ajax-content').html(response); 75 76 $reveal.find('.orbit').each(function() { 77 new Foundation.Orbit($(this)); 78 }); 79 80 $reveal.find(".plantegning").magnificPopup({ 81 type:'image', 82 closeOnContentClick: true, 83 }); 84 85 $reveal.find('.orbit-container').each(function() { 86 $(this).magnificPopup({ 87 delegate: 'a', 88 type: 'image', 89 gallery: {enabled: true} 90 }); 91 }); 92 93 94 95 96 97 }, 98 error: function() { 99 $reveal.find('.ajax-content').html('<p>En feil oppsto ved lasting av innhold.</p>'); 100 }, 101 complete: function() { 102 isLoading = false; 103 } 104 }); 105 }); 106 107 // Lukk reveal-boksen når brukeren trykker "tilbake" 108 window.addEventListener('popstate', function () { 109 const $reveal = $('#leilighet-reveal'); 110 if (window.location.hash !== '#leilighet') { 111 $reveal.removeClass('is-visible').find('.ajax-content').empty(); 112 } 113 }); 114 115 116 $("polygon:not(.st1").on('mouseenter',function() { 117 var ref = $(this).attr("data-ref"); 118 var status = $(this).attr("data-status"); 119 var kommer = $(this).attr("data-kommer"); 120 var leilighet = $(".leilighet[data-leilighets_id='"+ref+"']"); 121 var type = leilighet.find(".type").text(); 122 var storrelse = leilighet.find(".storrelse").text(); 123 var ledig_fra = leilighet.find(".ledig_fra").text(); 124 var title = $(this).attr("id"); 125 var plantegning = leilighet.find(".plantegning").html(); 126 127 if(title == "felleskjokken") { 128 $("#follow-mouse").addClass("remove-border"); 129 $("#follow-mouse div").hide(); 130 $("#follow-mouse .title").show(); 131 $("#follow-mouse .title").text("Felleskjøkken"); 132 } 133 else { 134 $("#follow-mouse div").show(); 135 $("#follow-mouse").removeClass("remove-border"); 136 $("#follow-mouse .title").text(title); 137 $("#follow-mouse .size span").text(storrelse); 138 $("#follow-mouse .bedrooms span").text(type); 139 $("#follow-mouse .plantegning").html(plantegning); 140 if(status == "opptatt") { 141 $("#follow-mouse .status").text("Opptatt").removeClass("opptatt kommer ledig").addClass(status); 142 } 143 else if(kommer == "1") { 144 $("#follow-mouse .status").text("Kommer snart").addClass("kommer"); 145 } 146 else { 147 $("#follow-mouse .status").text("Ledig fra: " + ledig_fra).removeClass("opptatt kommer ledig").addClass(status); 148 } 149 } 150 151 if($(window).width() > 1023) { 152 153 $("#follow-mouse").show(); 154 } 155 }).on('mouseleave',function() { 156 $("#follow-mouse").hide(); 157 }) 158 159 $(document).on('mousemove', function (e) { 160 $('#follow-mouse').css({ 161 left: (e.clientX + 50) + 'px', 162 top: (e.clientY - 60) + 'px' 163 }); 164 }); 165}); 166 167 168 169jQuery(document).ready(function($) { 170 // Gallery init 171 $('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"]').each(function(){ 172 if ($(this).parents('.gallery').length == 0) { 173 $(this).magnificPopup({ 174 type:'image', 175 closeOnContentClick: true, 176 }); 177 } 178 }); 179 $(".wp-block-uagb-icon-list .wp-block-uagb-icon-list-child").each(function() { 180 if($(this).find("a").length) { 181 $(this).addClass("has-link"); 182 } 183 }) 184 185 const $slider = $('#ads'); 186 let isDown = false; 187 let startX; 188 let scrollLeft; 189 190 $slider.on('mousedown', function(e) { 191 isDown = true; 192 $slider.addClass('dragging'); 193 startX = e.pageX - $slider.offset().left; 194 scrollLeft = $slider.scrollLeft(); 195 }); 196 197 $(document).on('mouseup', function() { 198 isDown = false; 199 $slider.removeClass('dragging'); 200 }); 201 202 $(document).on('mousemove', function(e) { 203 if (!isDown) return; 204 e.preventDefault(); 205 const x = e.pageX - $slider.offset().left; 206 const walk = (x - startX) * 1.5; // Scroll-hastighet 207 $slider.scrollLeft(scrollLeft - walk); 208 }); 209 210 if ($(window).width() < 1024) { 211 var userClick = true; 212 // Legg til en toggle-knapp etter <a> 213 $('.menu-item-has-children > a').after('<span class="submenu-toggle" aria-hidden="true"></span>'); 214 $('.menu-item-has-children > a').click(function(e) { 215 if(userClick) { 216 e.preventDefault(); 217 var url = $(this).attr("href"); 218 window.location.href = url; 219 } 220 userClick = true; 221 });
222 // Når toggle trykkes: åpne/lukk undermeny 223 $('.submenu-toggle').on('click', function(e) { 224 e.preventDefault(); 225 // const $parent = $(this).closest('a'); 226 // $parent.trigger("click"); 227 userClick = false; 228 $(this).parent().find("a").trigger("click"); 229 }); 230 } 231 232 $('.wp-block-media-text').each(function () { 233 const $mediaText = $(this); 234 const $mediaLink = $mediaText.find('.wp-block-media-text__media > a').first(); 235 236 if ($mediaLink.length > 0) { 237 const href = $mediaLink.attr('href'); 238 239 // Klon innholdet for trygg manipulering 240 const $clone = $mediaText.clone(); 241 242 // Fjern alle <a> unntatt den i media 243 $clone.find('a').not('.wp-block-media-text__media > a').each(function () { 244 const $a = $(this); 245 const $div = $('<div>') 246 .addClass($a.attr('class')) 247 .attr('style', $a.attr('style')) 248 .html($a.html()); 249 $a.replaceWith($div); 250 }); 251 252 // Hent originale klassene fra container 253 const originalClasses = $mediaText.attr('class'); 254 255 // Pakk inn alt innhold i en ny <a> med samme klasser 256 const $newWrapper = $('<a>') 257 .attr('href', href) 258 .addClass(originalClasses) 259 .html($clone.html()); 260 261 // Bytt ut opprinnelig blokk 262 $mediaText.replaceWith($newWrapper); 263 } 264 }); 265 266 267 268const counters = $('body:not(.page-id-188) .uagb-container-inner-blocks-wrap h1'); 269const duration = 1000; // total varighet i ms 270let hasAnimated = false; 271 272function isInViewport(el) { 273 const rect = el.getBoundingClientRect(); 274 return ( 275 rect.top >= 0 && 276 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) 277 ); 278} 279 280function animateCounter($el) { 281 const target = parseInt($el.text().replace(/\D/g, ''), 10); 282 if (isNaN(target)) return; 283 284 const frameRate = 60; 285 const totalFrames = Math.round((duration / 1000) * frameRate); 286 let frame = 0; 287 288 const counter = setInterval(function () { 289 frame++; 290 const progress = frame / totalFrames; 291 const current = Math.round(target * progress); 292 $el.text(current.toLocaleString()); 293 294 if (frame >= totalFrames) { 295 clearInterval(counter); 296 $el.text(target.toLocaleString()); 297 } 298 }, duration / totalFrames); 299} 300 301function handleScroll() { 302 if (hasAnimated) return; 303 304 counters.each(function () { 305 if (isInViewport(this)) { 306 animateCounter($(this)); 307 hasAnimated = true; 308 } 309 }); 310} 311 312$(window).on('scroll resize load', handleScroll); 313 314 315 316 317 318 const $filterContainer = $('#leilighetstyper-filtrering'); 319 const $leiligheter = $('.leilighetstype'); 320 321 let steder = []; 322 323 // 1. Samle unike navn fra hver leilighetstype 324 $leiligheter.each(function() { 325 const text = $(this).find('.wp-block-button__link').text().trim(); 326 if (text && !steder.includes(text)) { 327 steder.push(text); 328 } 329 // Lagre på elementet for rask filtering senere 330 $(this).attr('data-sted', text); 331 }); 332 333 // 2. Lag en "Vis alle"-knapp først 334 $filterContainer.append(`<button class="filter-btn" data-filter="alle">Vis alle</button>`); 335 336 // 3. Lag knapp for hvert unike sted 337 steder.forEach(function(sted) { 338 const knapp = `<button class="filter-btn" data-filter="${sted}">${sted}</button>`; 339 $filterContainer.append(knapp); 340 }); 341 342 // 4. Filter-klikking 343 $filterContainer.on('click', '.filter-btn', function() { 344 const valgt = $(this).data('filter'); 345 346 if (valgt === 'alle') { 347 $leiligheter.show(); 348 } else { 349 $leiligheter.each(function() { 350 const sted = $(this).data('sted'); 351 if (sted === valgt) { 352 $(this).show(); 353 } else { 354 $(this).hide(); 355 } 356 }); 357 } 358 359 // Marker aktiv knapp (valgfritt) 360 $('.filter-btn').removeClass('active'); 361 $(this).addClass('active'); 362 });
363 364 365 366 $(".toggle-filters").click(function() { 367 $(this).toggleClass("active"); 368 $("#filters").toggleClass("active"); 369 $("#filters .filter .filter-btn").removeClass("active"); 370 $("#ads .cell").show(); 371 }) 372 373 $(".filter-btn").click(function() { 374 let $this = $(this); 375 376 // Toggle "active" class (kan ha flere aktive samtidig) 377 378 if($(this).closest(".filter").attr("data-id") == "price" && !$(this).hasClass("active")) { 379 $(".filter[data-id='price'] .filter-btn").removeClass("active"); 380 } 381 382 $this.toggleClass("active"); 383 384 385 filterListings(); 386 }); 387 388 $('.leilighetstype').each(function () { 389 const $columns = $(this).find('.wp-block-column'); 390 391 // Sjekk hvilken kolonne som har bilde 392 $columns.each(function (index) { 393 if ($(this).find('img').length > 0) { 394 // Denne har bilde â vi vil at den skal være nr 2 pÃ¥ desktop 395 $(this).addClass('small-order-1 large-order-2'); 396 // Den andre fÃ¥r motsatt 397 $columns.not(this).addClass('small-order-2 large-order-1'); 398 } 399 }); 400 }); 401 402 403 404 const $el = $('.typewrited'); 405 if($el.length) { 406 const originalHTML = $el.html(); 407 408 // Splitt pÃ¥ <br> for Ã¥ beholde linjeskift 409 const parts = originalHTML.split(/<br\s*\/?>/i); 410 const plainText = parts.map(p => $('<div>').html(p).text()); // Fjern HTML 411 const fullText = plainText.join('\n'); 412 413 let i = 0; 414 const speed = 35; 415 let started = false; 416 417 function typeWriter() { 418 if (i < fullText.length) { 419 const char = fullText.charAt(i); 420 if (char === '\n') { 421 $el.append('<br>'); 422 } else { 423 $el.append(char); 424 } 425 i++; 426 setTimeout(typeWriter, speed); 427 } 428 } 429 430 // Viewport detection 431 function isInViewport(el) { 432 const rect = el.get(0).getBoundingClientRect(); 433 return ( 434 rect.top >= 0 && 435 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) 436 ); 437 } 438 439 // Scroll + initial check 440 function checkVisibility() { 441 if (!started && isInViewport($el)) { 442 started = true; 443 $el.html(''); 444 $el.removeClass("noshow"); 445 typeWriter(); 446 } 447 } 448 449 $(window).on('scroll resize load', checkVisibility); 450 checkVisibility(); // i tilfelle allerede synlig ved load 451 } 452 453 454 function filterListings() { 455 $("#ads .cell").each(function() { 456 let $listing = $(this); 457 let location = $listing.data("location"); 458 let price = $listing.data("price"); 459 let bedrooms = String($listing.data("bedrooms")); 460 461 // Hent alle aktive verdier for hver kategori 462 let activeLocations = $(".filter[data-id='location'] .filter-btn.active").map(function() { 463 return $(this).text().trim(); 464 }).get(); 465 466 let activePricesMin = $(".filter[data-id='price'] .f
466ilter-btn.active").attr("data-min"); 467 let activePricesMax = $(".filter[data-id='price'] .filter-btn.active").attr("data-max"); 468 469 let activeBedrooms = $(".filter[data-id='bedrooms'] .filter-btn.active").map(function() { 470 return String($(this).attr("data-id").trim()); 471 }).get(); 472 473 let show = true; 474 475 // Sjekk om minst ett valgt filter matcher 476 if (activeLocations.length > 0 && !activeLocations.includes(location)) { 477 show = false; 478 } 479 if (activePricesMin != "" && price > activePricesMin && price < activePricesMax) { 480 console.log(activePricesMin + " - " + activePricesMax); 481 show = true; 482 } 483 else if(activePricesMin) { 484 show = false; 485 console.log(activePricesMin + " - " + activePricesMax); 486 } 487 if (activeBedrooms.length > 0 && !activeBedrooms.includes(bedrooms)) { 488 489 show = false; 490 if(activeBedrooms.includes("3")) { 491 if(bedrooms == 3 || bedrooms == 4 || bedrooms == 5) { 492 show = true; 493 } 494 } 495 } 496 497 // Vis/skjul element 498 if (show) { 499 $listing.show(); 500 } else { 501 $listing.hide(); 502 } 503 }); 504 } 505 506 507 508 $(".wpml-wrap ul li a span").each(function() { 509 var originalText = $(this).text(); 510 var trimmedText = originalText.substring(0, 3); // Beholder kun de 3 første bokstavene 511 $(this).text(trimmedText); // Oppdaterer teksten 512 }) 513 514 var windowWidth = $(document).width(); 515 516 $(".wp-block-uagb-team:not(.boligprosjekt) .uagb-team__content").each(function() { 517 var name = $(this).find(".uagb-team__title").text(); 518 $(this).append('<div class="show-name">'+name+'</div>'); 519 $(this).find("img").after("<div class='back'></div>"); 520 $(this).find("img").wrap("<div class='front'></div>"); 521 522 }) 523 if($(window).width() > 1023 && $("body").hasClass("home")) { 524 var headerHeight = 114; 525 var windowHeight = $(window).height(); 526 var spacing = 32; 527 var startHeight = windowHeight - headerHeight - (spacing * 2); 528 console.log(startHeight); 529 530 $("#hero-wrap").attr("data-0","top:0%").attr("data-1200","top:0%").attr("data-2100","top:-100%;"); 531 532 // $("#hero").attr("data-0","margin-top:8rem; height:"+startHeight+"px;") 533 // .attr("data-100","margin-top:6rem;height:"+(startHeight+32)+"px;"); 534 // .attr("data-200","margin-top:6rem;height:"+startHeight+(spacing*2)+"px;") 535 536 // $("#hero-wrap .wp-block-group__inner-container").attr("data-0","width:96%;").attr("data-200","width:"+windowWidth+"px;"); 537 // data-0="top:0%;" data-1000="top:0%;" 538 // data-0="background-color:rgb(0,0,255);" data-500="background-color:rgb(255,0,0); 539 540 541 var s = skrollr.init({ 542 animate: true, 543 smoothScrollingDuration: 10 544 545 }); 546 } 547 else if($(window).width() < 1024) { 548 $("#off-canvas").removeClass("position-top top-offcanvas").addClass("position-right"); 549 $("#menu-megameny li.menu-item-has-children > a").click(function(e) { 550 e.preventDefault(); 551 $(".menu-item-has-children").removeClass("active"); 552 $(this).closest("li").addClass("active"); 553 }) 554 } 555 556 $(".close-btn").click(function() { 557 $(".js-off-canvas-overlay").trigger("click"); 558 }) 559 560 function frostInsertEnglishMenuIcons($) { 561 // Kjør kun på engelsk (tilpass ved behov) 562 var isEnglish = 563 window.location.pathname.indexOf('/en/') === 0 || 564 (document.documentElement.lang || '').toLowerCase().startsWith('en'); 565 566 if (!isEnglish) return; 567 568 // Map fra menu-item-ID -> bilde-URL (hentet fra norsk meny) 569 var icons = { 570 'menu-item-222': 'https://frost.no/wp-content/themes/frost-wt/assets/images/nav1.svg', 571 'menu-item-226': 'https://frost.no/wp-content/themes/frost-wt/assets/images/naering.svg', 572 'menu-item-218': 'https://frost.no/wp-content/themes/frost-wt/assets/images/nav4.svg', 573 'menu-item-234': 'https://frost.no/wp-content/themes/frost-wt/assets/images/nav5.svg', 574 'menu-item-229': 'https://frost.no/wp-content/themes/frost-wt/assets/images/nav6.svg', 575 'menu-item-2370': 'https://frost.no/wp-content/themes/frost-wt/assets/images/kontakt.svg' 576 }; 577 578 // Sett inn <div class="icon"><img ...></div> først i <a> for hvert menypunkt 579 $.each(icons, function (liId, imgUrl) { 580 var $li = $('#' + liId); 581 if (!$li.length) return; 582 583 var $a = $li.children('a'); 584 if (!$a.length) return; 585 586 // Unngå duplikater hvis noe allerede har lagt inn ikon 587 if ($a.find('.icon').length) return; 588 589 $a.prepend( 590 '<div class="icon"><img src="' + imgUrl + '" alt="" /></div>' 591 ); 592 }); 593 } 594 frostInsertEnglishMenuIcons($); 595 596 597 598 $("#menu-megameny li a img").each(function() { 599 $(this).wrap("<div class='icon'></div>"); 600 });
601 var ajaxurl = "https://frost.no/wp-admin/admin-ajax.php"; 602 $('#load-more-btn').on('click', function () { 603 var button = $(this); 604 var page = parseInt(button.attr('data-page')) + 1; 605 var maxPages = parseInt(button.attr('data-max-pages')); 606 607 $(this).addClass("loading"); 608 609 if (page <= maxPages) { 610 $.ajax({ 611 url: ajaxurl, 612 type: 'POST', 613 data: { 614 action: 'load_more_posts', 615 page: page, 616 }, 617 beforeSend: function () { 618 button.find("span").text('Laster...'); 619 }, 620 success: function (response) { 621 if (response) { 622 $(this).remove("loading"); 623 $('.posts-container').append(response); 624 button.attr('data-page', page).text('Last flere'); 625 var fourthCell = $('.posts-container .cell').eq(3); // Velg den fjerde .cell (0-basert indeks 626 var offsetTop = fourthCell.offset().top; // Hent offset top 627 $("html, body").animate({ scrollTop:offsetTop-20}, 400); 628 if (page >= maxPages) { 629 button.hide(); // Skjul knappen når alle innlegg er lastet 630 } 631 } else { 632 button.hide(); // Skjul knappen hvis ingen innlegg ble returnert 633 } 634 }, 635 }); 636 } else { 637 button.hide(); // Skjul knappen hvis sidenummer overstiger maks antall sider 638 } 639 }); 640 641 642 643 $('.gallery').each(function() { 644 $(this).magnificPopup({ 645 delegate: 'a', 646 type: 'image', 647 gallery: {enabled: true} 648 }); 649 }); 650 651 // Fjern wow om man har scrollet forbi! 652 function onScrollWOW() { 653 $('.wow').each(function() { 654 const elem = $(this)[0]; 655 656 if (window.scrollY + window.innerHeight >= elem.offsetTop) { 657 $(this).removeClass('wow'); 658 } 659 }) 660 } 661 662 $(window).scroll(onScrollWOW); 663 onScrollWOW(); 664 665 new WOW().init(); 666 667 var didScroll; 668 var lastScrollTop = 0; 669 var delta = 10; 670 if($(window).width() < 768) { 671 delta = 100; 672 } 673 var navbarHeight = $('header').outerHeight() - 80; 674 675 $(window).scroll(function(event){ 676 didScroll = true; 677 }); 678 679 setInterval(function() { 680 if (didScroll) { 681 hasScrolled(); 682 didScroll = false; 683 } 684 }, 250); 685 686 function hasScrolled() { 687 var st = $(this).scrollTop(); 688 689 if(st > 200) { 690 $('header').addClass("not-top"); 691 } 692 else { 693 $('header').removeClass("not-top"); 694 } 695 696 // Make sure they scroll more than delta 697 if(Math.abs(lastScrollTop - st) <= delta) 698 return; 699 700 // If they scrolled down and are past the navbar, add class .nav-up. 701 // This is necessary so you never see what is "behind" the navbar. 702 if (st > lastScrollTop && st > navbarHeight){ 703 // Scroll Down 704 $('header').removeClass('nav-down').addClass('nav-up'); 705 } else { 706 // Scroll Up 707 if(st + $(window).height() < $(document).height()) { 708 $('header').removeClass('nav-up').addClass('nav-down'); 709 } 710 } 711 712 lastScrollTop = st; 713 } 714});
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.