1// Toggle sticky class on navbar on scroll 2// document.addEventListener('DOMContentLoaded', function () { 3// const navbar = document.getElementById('profile-nav'); 4 5// // on page load 6// let rect = navbar.getBoundingClientRect(); 7// // Check if the navbar is in the viewport 8// if (rect.top <= 0) { 9// navbar.classList.add("sticky"); 10// } else { 11// navbar.classList.remove("sticky"); 12// } 13 14// // on scroll 15// window.onscroll = function() { 16// let rect = navbar.getBoundingClientRect(); 17// // Check if the navbar is in the viewport 18// if (rect.top <= 0) { 19// navbar.classList.add("sticky"); 20// } else { 21// navbar.classList.remove("sticky"); 22// } 23// }; 24 25// // check if the actual section is in the viewport 26// const sections = document.querySelectorAll('.gladney-page-section'); 27// const navLinks = document.querySelectorAll('.profile-nav-link'); 28// window.addEventListener('scroll', () => { 29// sections.forEach(section => { 30// const rect = section.getBoundingClientRect(); 31// const sectionTop = rect.top; 32// const sectionBottom = rect.bottom; 33 34// if (sectionTop <= 40 && sectionBottom >= 0 || (section.getAttribute('id') === 'contact' && sectionTop <= 300)) { 35// const id = section.getAttribute('id'); 36// navLinks.forEach(link => { 37// link.classList.remove('active'); 38// if (link.getAttribute('href') === `#${id}`) { 39// link.classList.add('active'); 40// } 41// }); 42// } 43// }); 44// }); 45// }); 46 47// smooth scroll on anchor 48document.querySelectorAll('a[href^="#"]').forEach(anchor => { 49 anchor.addEventListener('click', function (e) { 50 e.preventDefault(); 51 52 let sectionId = this.getAttribute('href'); 53 sectionId = sectionId.replace('#', ''); // Remove trailing slash if exists 54 55 const element = document.getElementById(sectionId); 56 if (element) { 57 window.scroll(0, element.offsetTop - 30); 58 } 59 }); 60}); 61 62// Profile Single Page 63document.addEventListener('DOMContentLoaded', function () {
64 const loadMoreButton = document.getElementById('photos-load-more'); 65 if (loadMoreButton) { 66 loadMoreButton.addEventListener('click', function () { 67 const photosContainer = document.getElementById('photos-gallery'); 68 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 69 70 if (hiddenImages.length !== 0) { 71 hiddenImages.forEach((photo) => { 72 if(photo.classList.contains('hidden')) { 73 photo.classList.add('toggleImages'); 74 photo.classList.remove('hidden'); 75 } 76 77 if(photo.classList.contains('md:hidden')) { 78 photo.classList.remove('md:hidden'); 79 photo.classList.add('md:toggleImages'); 80 } 81 }); 82 loadMoreButton.textContent = 'Show Less'; 83 } else { 84 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 85 allImages.forEach((photo) => { 86 if(photo.classList.contains('toggleImages')) { 87 photo.classList.remove('toggleImages'); 88 photo.classList.add('hidden'); 89 } 90 91 if(photo.classList.contains('md:toggleImages')) { 92 photo.classList.remove('md:toggleImages'); 93 photo.classList.add('md:hidden'); 94 } 95 }); 96 loadMoreButton.textContent = 'Load More'; 97 } 98 }); 99 } 100
101 const loadMoreButton2 = document.getElementById('photos-load-more2'); 102 if (loadMoreButton2) { 103 loadMoreButton2.addEventListener('click', function () { 104 const photosContainer = document.getElementById('photos-gallery2'); 105 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 106 107 if (hiddenImages.length !== 0) { 108 hiddenImages.forEach((photo) => { 109 if(photo.classList.contains('hidden')) { 110 photo.classList.add('toggleImages'); 111 photo.classList.remove('hidden'); 112 } 113 114 if(photo.classList.contains('md:hidden')) { 115 photo.classList.remove('md:hidden'); 116 photo.classList.add('md:toggleImages'); 117 } 118 }); 119 loadMoreButton2.textContent = 'Show Less'; 120 } else { 121 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 122 allImages.forEach((photo) => { 123 if(photo.classList.contains('toggleImages')) { 124 photo.classList.remove('toggleImages'); 125 photo.classList.add('hidden'); 126 } 127 128 if(photo.classList.contains('md:toggleImages')) { 129 photo.classList.remove('md:toggleImages'); 130 photo.classList.add('md:hidden'); 131 } 132 }); 133 loadMoreButton.textContent = 'Load More'; 134 } 135 }); 136 } 137 138
139 const loadMoreButton3 = document.getElementById('photos-load-more3'); 140 if (loadMoreButton3) { 141 loadMoreButton3.addEventListener('click', function () { 142 const photosContainer = document.getElementById('photos-gallery3'); 143 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 144 145 if (hiddenImages.length !== 0) { 146 hiddenImages.forEach((photo) => { 147 if(photo.classList.contains('hidden')) { 148 photo.classList.add('toggleImages'); 149 photo.classList.remove('hidden'); 150 } 151 152 if(photo.classList.contains('md:hidden')) { 153 photo.classList.remove('md:hidden'); 154 photo.classList.add('md:toggleImages'); 155 } 156 }); 157 loadMoreButton3.textContent = 'Show Less'; 158 } else { 159 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 160 allImages.forEach((photo) => { 161 if(photo.classList.contains('toggleImages')) { 162 photo.classList.remove('toggleImages'); 163 photo.classList.add('hidden'); 164 } 165 166 if(photo.classList.contains('md:toggleImages')) { 167 photo.classList.remove('md:toggleImages'); 168 photo.classList.add('md:hidden'); 169 } 170 }); 171 loadMoreButton3.textContent = 'Load More'; 172 } 173 }); 174 } 175 176
177 const loadMoreButton4 = document.getElementById('photos-load-more4'); 178 if (loadMoreButton4) { 179 loadMoreButton4.addEventListener('click', function () { 180 const photosContainer = document.getElementById('photos-gallery4'); 181 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 182 183 if (hiddenImages.length !== 0) { 184 hiddenImages.forEach((photo) => { 185 if(photo.classList.contains('hidden')) { 186 photo.classList.add('toggleImages'); 187 photo.classList.remove('hidden'); 188 } 189 190 if(photo.classList.contains('md:hidden')) { 191 photo.classList.remove('md:hidden'); 192 photo.classList.add('md:toggleImages'); 193 } 194 }); 195 loadMoreButton4.textContent = 'Show Less'; 196 } else { 197 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 198 allImages.forEach((photo) => { 199 if(photo.classList.contains('toggleImages')) { 200 photo.classList.remove('toggleImages'); 201 photo.classList.add('hidden'); 202 } 203 204 if(photo.classList.contains('md:toggleImages')) { 205 photo.classList.remove('md:toggleImages'); 206 photo.classList.add('md:hidden'); 207 } 208 }); 209 loadMoreButton4.textContent = 'Load More'; 210 } 211 }); 212 } 213
214 const loadMoreButton5 = document.getElementById('photos-load-more5'); 215 if (loadMoreButton5) { 216 loadMoreButton5.addEventListener('click', function () { 217 const photosContainer = document.getElementById('photos-gallery5'); 218 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 219 220 if (hiddenImages.length !== 0) { 221 hiddenImages.forEach((photo) => { 222 if(photo.classList.contains('hidden')) { 223 photo.classList.add('toggleImages'); 224 photo.classList.remove('hidden'); 225 } 226 227 if(photo.classList.contains('md:hidden')) { 228 photo.classList.remove('md:hidden'); 229 photo.classList.add('md:toggleImages'); 230 } 231 }); 232 loadMoreButton5.textContent = 'Show Less'; 233 } else { 234 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 235 allImages.forEach((photo) => { 236 if(photo.classList.contains('toggleImages')) { 237 photo.classList.remove('toggleImages'); 238 photo.classList.add('hidden'); 239 } 240 241 if(photo.classList.contains('md:toggleImages')) { 242 photo.classList.remove('md:toggleImages'); 243 photo.classList.add('md:hidden'); 244 } 245 }); 246 loadMoreButton5.textContent = 'Load More'; 247 } 248 }); 249 } 250
251 const loadMoreButton6 = document.getElementById('photos-load-more6'); 252 if (loadMoreButton6) { 253 loadMoreButton6.addEventListener('click', function () { 254 const photosContainer = document.getElementById('photos-gallery6'); 255 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 256 257 if (hiddenImages.length !== 0) { 258 hiddenImages.forEach((photo) => { 259 if(photo.classList.contains('hidden')) { 260 photo.classList.add('toggleImages'); 261 photo.classList.remove('hidden'); 262 } 263 264 if(photo.classList.contains('md:hidden')) { 265 photo.classList.remove('md:hidden'); 266 photo.classList.add('md:toggleImages'); 267 } 268 }); 269 loadMoreButton6.textContent = 'Show Less'; 270 } else { 271 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 272 allImages.forEach((photo) => { 273 if(photo.classList.contains('toggleImages')) { 274 photo.classList.remove('toggleImages'); 275 photo.classList.add('hidden'); 276 } 277 278 if(photo.classList.contains('md:toggleImages')) { 279 photo.classList.remove('md:toggleImages'); 280 photo.classList.add('md:hidden'); 281 } 282 }); 283 loadMoreButton6.textContent = 'Load More'; 284 } 285 }); 286 } 287
288 const loadMoreButton7 = document.getElementById('photos-load-more7'); 289 if (loadMoreButton7) { 290 loadMoreButton7.addEventListener('click', function () { 291 const photosContainer = document.getElementById('photos-gallery7'); 292 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 293 294 if (hiddenImages.length !== 0) { 295 hiddenImages.forEach((photo) => { 296 if(photo.classList.contains('hidden')) { 297 photo.classList.add('toggleImages'); 298 photo.classList.remove('hidden'); 299 } 300 301 if(photo.classList.contains('md:hidden')) { 302 photo.classList.remove('md:hidden'); 303 photo.classList.add('md:toggleImages'); 304 } 305 }); 306 loadMoreButton7.textContent = 'Show Less'; 307 } else { 308 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 309 allImages.forEach((photo) => { 310 if(photo.classList.contains('toggleImages')) { 311 photo.classList.remove('toggleImages'); 312 photo.classList.add('hidden'); 313 } 314 315 if(photo.classList.contains('md:toggleImages')) { 316 photo.classList.remove('md:toggleImages'); 317 photo.classList.add('md:hidden'); 318 } 319 }); 320 loadMoreButton7.textContent = 'Load More'; 321 } 322 }); 323 } 324
325 const loadMoreButton8 = document.getElementById('photos-load-more8'); 326 if (loadMoreButton8) { 327 loadMoreButton8.addEventListener('click', function () { 328 const photosContainer = document.getElementById('photos-gallery8'); 329 let hiddenImages = photosContainer.querySelectorAll('.photo-gallery.hidden, .photo-gallery.md\\:hidden'); 330 331 if (hiddenImages.length !== 0) { 332 hiddenImages.forEach((photo) => { 333 if(photo.classList.contains('hidden')) { 334 photo.classList.add('toggleImages'); 335 photo.classList.remove('hidden'); 336 } 337 338 if(photo.classList.contains('md:hidden')) { 339 photo.classList.remove('md:hidden'); 340 photo.classList.add('md:toggleImages'); 341 } 342 }); 343 loadMoreButton8.textContent = 'Show Less'; 344 } else { 345 const allImages = photosContainer.querySelectorAll('.photo-gallery.toggleImages, .photo-gallery.md\\:toggleImages'); 346 allImages.forEach((photo) => { 347 if(photo.classList.contains('toggleImages')) { 348 photo.classList.remove('toggleImages'); 349 photo.classList.add('hidden'); 350 } 351 352 if(photo.classList.contains('md:toggleImages')) { 353 photo.classList.remove('md:toggleImages'); 354 photo.classList.add('md:hidden'); 355 } 356 }); 357 loadMoreButton8.textContent = 'Load More'; 358 } 359 }); 360 } 361 362 const copyButton = document.getElementById('copy-profile-link'); 363 if (copyButton) { 364 copyButton.addEventListener('click', function () { 365 let copyIcon = copyButton.querySelector('img'); 366 let originalSrc = copyIcon.getAttribute('src'); 367 368 //copy the url 369 navigator.clipboard.writeText(window.location.href); 370 371 // Change the button icon to indicate success 372 copyIcon.setAttribute('src', copyIcon.getAttribute('data-copied-success-src')); 373 374 // Change the span text 375 copyButton.querySelector('#tooltip span').textContent = 'Link copied!'; 376 copyButton.querySelector('#tooltip').classList.remove('hidden'); 377 378 // Reset the icon after 2 seconds 379 setTimeout(() => { 380 copyIcon.setAttribute('src', originalSrc); 381 copyButton.querySelector('#tooltip span').textContent = 'Copy profile link'; 382 copyButton.querySelector('#tooltip').classList.add('hidden'); 383 }, 2500); 384 }); 385 } 386 387 const copyInstagramButton = document.getElementById('copy-instagram-link'); 388 if (copyInstagramButton) { 389 copyInstagramButton.addEventListener('click', function () { 390 let copyIcon = copyInstagramButton.querySelector('img'); 391 let originalSrc = copyIcon.getAttribute('src'); 392 393 //copy the url 394 navigator.clipboard.writeText(copyIcon.getAttribute('data-copied-link-src')); 395 396 // Change the button icon to indicate success 397 copyIcon.setAttribute('src', copyIcon.getAttribute('data-copied-success-src')); 398 399 // Change the span text 400 copyInstagramButton.querySelector('#tooltip span').textContent = 'Link copied!'; 401 copyInstagramButton.querySelector('#tooltip').classList.remove('hidden'); 402 403 // Reset the icon after 2 seconds 404 setTimeout(() => { 405 copyIcon.setAttribute('src', originalSrc); 406 copyInstagramButton.querySelector('#tooltip span').textContent = 'Copy Instagram link'; 407 copyInstagramButton.querySelector('#tooltip').classList.add('hidden'); 408 }, 2500); 409 }); 410 } 411 412 const copyFacebookButton = document.getElementById('copy-facebook-link'); 413 if (copyFacebookButton) { 414 copyFacebookButton.addEventListener('click', function () { 415 let copyIcon = copyFacebookButton.querySelector('img'); 416 let originalSrc = copyIcon.getAttribute('src'); 417 418 //copy the url 419 navigator.clipboard.writeText(copyIcon.getAttribute('data-copied-link-src')); 420 421 // Change the button icon to indicate success 422 copyIcon.setAttribute('src', copyIcon.getAttribute('data-copied-success-src')); 423 424 // Change the span text 425 copyFacebookButton.querySelector('#tooltip span').textContent = 'Link copied!'; 426 copyFacebookButton.querySelector('#tooltip').classList.remove('hidden'); 427 428 // Reset the icon after 2 seconds 429 setTimeout(() => { 430 copyIcon.setAttribute('src', originalSrc); 431 copyFacebookButton.querySelector('#tooltip span').textContent = 'Copy Facebook link'; 432 copyFacebookButton.querySelector('#tooltip').classList.add('hidden'); 433 }, 2500); 434 }); 435 } 436 437 const profilePosts = document.querySelectorAll('.profile-post'); 438 const modal = document.getElementById('profile-post-modal'); 439 const modalPrevButton = document.getElementById('profile-post-modal-prev'); 440 const modalNextButton = document.getElementById('profile-post-modal-next'); 441 const modalClose = document.getElementById('profile-post-modal-close'); 442 if(profilePosts.length > 0) { 443 let totalPosts = 0; 444
445 profilePosts.forEach(post => { 446 post.addEventListener('click', function () { 447 const postTitle = this.querySelector('#profile-post-title').textContent; 448 const postContent = this.querySelector('#profile-post-content').innerHTML; 449 const postIndex = this.getAttribute('data-post-index'); 450 let postImage = this.querySelector('#profile-post-image').getAttribute('data-lazy-src'); 451 postImage = postImage ? postImage : this.querySelector('#profile-post-image').getAttribute('src'); 452 453 totalPosts = parseInt(this.getAttribute('data-total-posts')); 454 455 updatePostModalContent(postTitle, postContent, postImage, postIndex, totalPosts); 456 }); 457 }); 458 459 modalClose.addEventListener('click', function () { 460 modal.classList.add('hidden'); 461 }); 462 463 modal.addEventListener('click', function (event) { 464 if (event.target === modal) { 465 modal.classList.add('hidden'); 466 } 467 }); 468 469 modalPrevButton.addEventListener('click', function () { 470 let currentIndex = parseInt(modal.getAttribute('data-modal-post-index')); 471 const prevPost = profilePosts[currentIndex - 1]; 472 473 if (prevPost) { 474 const prevPostTitle = prevPost.querySelector('#profile-post-title').textContent; 475 const prevPostContent = prevPost.querySelector('#profile-post-content').innerHTML; 476 const prevPostIndex = prevPost.getAttribute('data-post-index'); 477 let prevPostImage = prevPost.querySelector('#profile-post-image').getAttribute('data-lazy-src'); 478 prevPostImage = prevPostImage ? prevPostImage : prevPost.querySelector('#profile-post-image').getAttribute('src'); 479 480 updatePostModalContent(prevPostTitle, prevPostContent, prevPostImage, prevPostIndex, totalPosts); 481 } 482 }); 483 484 modalNextButton.addEventListener('click', function () { 485 let currentIndex = parseInt(modal.getAttribute('data-modal-post-index')); 486 const nextPost = profilePosts[currentIndex + 1]; 487 488 if (nextPost) { 489 const nextPostTitle = nextPost.querySelector('#profile-post-title').textContent; 490 const nextPostContent = nextPost.querySelector('#profile-post-content').innerHTML; 491 const nextPostIndex = nextPost.getAttribute('data-post-index'); 492 let nextPostImage = nextPost.querySelector('#profile-post-image').getAttribute('data-lazy-src'); 493 nextPostImage = nextPostImage ? nextPostImage : nextPost.querySelector('#profile-post-image').getAttribute('src'); 494 495 updatePostModalContent(nextPostTitle, nextPostContent, nextPostImage, nextPostIndex, totalPosts); 496 } 497 }); 498 } 499 500 function updatePostModalContent(postTitle, postContent, postImage, postIndex, totalPosts) { 501 const modalTitle = document.getElementById('profile-post-modal-title'); 502 const modalContent = document.getElementById('profile-post-modal-content'); 503 const modalImage = document.getElementById('profile-post-modal-image'); 504 505 // Update the modal content 506 modalTitle.textContent = postTitle; 507 modalContent.innerHTML = postContent; 508 if (postImage.length > 0) { 509 modalImage.setAttribute('src', postImage); 510 } else { 511 modalImage.setAttribute('src', 'https://profiles.adoption.com/wp-content/uploads/2025/08/stock_photo.jpg'); 512 } 513 modal.setAttribute('data-modal-post-index', postIndex); 514 515 // Update the modal navigation buttons 516 postIndex > 0 ? modalPrevButton.classList.add('active') : modalPrevButton.classList.remove('active'); 517 postIndex < totalPosts - 1 ? modalNextButton.classList.add('active') : modalNextButton.classList.remove('active'); 518 519 modal.classList.remove('hidden'); 520 521 } 522 523 const profilePhotos = document.querySelectorAll('.photo-gallery'); 524 const modalPhotos = document.getElementById('profile-photo-modal'); 525 const modalPhotosPrevButton = document.getElementById('profile-photo-modal-prev'); 526 const modalPhotosNextButton = document.getElementById('profile-photo-modal-next'); 527 const modalPhotosClose = document.getElementById('profile-photo-modal-close'); 528 if(profilePhotos.length > 0) { 529 let totalPhotos = 0; 530 531 profilePhotos.forEach(photo => { 532 photo.addEventListener('click', function () { 533 // const photoTitle = this.querySelector('#profile-photo-title').textContent; 534 const photoTitle = ''; // No title available 535 const photoIndex = this.getAttribute('data-photo-index'); 536 const albumIndex = this.getAttribute('data-album-index'); 537 538 let image = this.querySelector('#profile-photo-image').getAttribute('data-lazy-src'); 539 image = image ? image : this.querySelector('#profile-photo-image').getAttribute('src'); 540 541 totalPhotos = parseInt(this.getAttribute('data-total-photos')); 542 543 updatePhotosModalContent(photoTitle, image, photoIndex, totalPhotos, albumIndex); 544 }); 545 }); 546 547 modalPhotosClose.addEventListener('click', function () { 548 modalPhotos.classList.add('hidden'); 549 }); 550 551 modalPhotos.addEventListener('click', function (event) { 552 if (event.target === modalPhotos) { 553 modalPhotos.classList.add('hidden'); 554 } 555 }); 556 557 modalPhotosPrevButton.addEventListener('click', function () { 558 let currentIndex = parseInt(modalPhotos.getAttribute('data-modal-photo-index')); 559 let currentAlbumIndex = parseInt(modalPhotos.getAttribute('data-modal-album-index')); 560 let albumProfilePhotos = document.querySelectorAll('.photo-gallery[data-album-index="' + currentAlbumIndex + '"]'); 561 const prevPhoto = albumProfilePhotos[currentIndex - 1]; 562 563 if (prevPhoto) { 564 // const prevPhotoTitle = prevPhoto.querySelector('#profile-photo-title').textContent; 565 const prevPhotoTitle = ''; // No title available 566 const prevPhotoIndex = prevPhoto.getAttribute('data-photo-index'); 567 const prevAlbumIndex = prevPhoto.getAttribute('data-album-index'); 568 let prevPhotoImage = prevPhoto.querySelector('#profile-photo-image').getAttribute('data-lazy-src'); 569 prevPhotoImage = prevPhotoImage ? prevPhotoImage : prevPhoto.querySelector('#profile-photo-image').getAttribute('src'); 570 571 updatePhotosModalContent(prevPhotoTitle, prevPhotoImage, prevPhotoIndex, totalPhotos, prevAlbumIndex); 572 } 573 }); 574 575 modalPhotosNextButton.addEventListener('click', function () { 576 let currentIndex = parseInt(modalPhotos.getAttribute('data-modal-photo-index')); 577 let currentAlbumIndex = parseInt(modalPhotos.getAttribute('data-modal-album-index')); 578 let albumProfilePhotos = document.querySelectorAll('.photo-gallery[data-album-index="' + currentAlbumIndex + '"]'); 579 const nextPhoto = albumProfilePhotos[currentIndex + 1]; 580 581 if (nextPhoto) { 582 // const nextPhotoTitle = nextPhoto.querySelector('#profile-photo-title').textContent; 583 const nextPhotoTitle = ''; // No title available 584 const nextPhotoIndex = nextPhoto.getAttribute('data-photo-index'); 585 const nextAlbumIndex = nextPhoto.getAttribute('data-album-index'); 586 let nextPhotoImage = nextPhoto.querySelector('#profile-photo-image').getAttribute('data-lazy-src'); 587 nextPhotoImage = nextPhotoImage ? nextPhotoImage : nextPhoto.querySelector('#profile-photo-image').getAttribute('src'); 588 589 updatePhotosModalContent(nextPhotoTitle, nextPhotoImage, nextPhotoIndex, totalPhotos, nextAlbumIndex); 590 } 591 }); 592 } 593 594 function updatePhotosModalContent(photoTitle, image, photoIndex, totalPhotos, albumIndex) { 595 const modalTitle = document.getElementById('profile-photo-modal-title'); 596 const modalImage = document.getElementById('profile-photo-modal-image'); 597 598 // Update the modal content 599 modalTitle.textContent = photoTitle; 600 modalImage.setAttribute('src', image); 601 modalPhotos.setAttribute('data-modal-photo-index', photoIndex); 602 modalPhotos.setAttribute('data-modal-album-index', albumIndex); 603 604 // Update the modal navigation buttons 605 photoIndex > 0 ? modalPhotosPrevButton.classList.add('active') : modalPhotosPrevButton.classList.remove('active'); 606 photoIndex < totalPhotos - 1 ? modalPhotosNextButton.classList.add('active') : modalPhotosNextButton.classList.remove('active'); 607 608 modalPhotos.classList.remove('hidden'); 609 } 610 611 document.addEventListener('click', function (event) { 612 // attr openModal 613 if (event.target.hasAttribute('openModal')) { 614 const modalId = event.target.getAttribute('openModal'); 615 616 const modal = document.getElementById(modalId); 617 618 if (modal) { 619 // Show the modal 620 modal.classList.remove('hidden'); 621 modal.style.display = ''; 622 } 623 } 624 }); 625 626 //close modal 627 document.addEventListener('click', function (event) { 628 if (event.target.classList.contains('close-button') || event.target.classList.contains('cancel-button')) { 629 const modal = event.target.closest('.modal-wrapper'); 630 if (modal) { 631 modal.style.display = 'none'; 632 } 633 } 634 }); 635}); 636 637// Add ... to the pagination 638window.almOnChange = function(){ 639 pagination_dots(); 640}; 641 642window.almOnLoad = function(){ 643 pagination_dots(); 644}; 645 646window.almComplete = function(){ 647 pagination_dots(); 648}; 649 650function pagination_dots() { 651 const pagination = document.querySelector('.alm-btn-wrap > .alm-paging'); 652 if (pagination) { 653 let current_page = pagination.getAttribute('data-current-page'); 654 let total_pages = pagination.getAttribute('data-total-pages'); 655 656 if(current_page >= 4) { 657 const first_dots = document.querySelector('.first_dots'); 658 if (!first_dots) { 659 const dots = document.createElement('li'); 660 dots.classList.add('dots','first_dots'); 661 dots.innerHTML = '<span>...</span>'; 662 663 let first_page = pagination.querySelector('.num[data-page-number="2"]'); 664 pagination.insertBefore(dots, first_page); 665 } 666 } else { 667 const first_dots = document.querySelector('.first_dots'); 668 if (first_dots) { 669 first_dots.remove(); 670 } 671 } 672 673 if(current_page <= total_pages - 4) { 674 const last_dots = document.querySelector('.last_dots'); 675 if (!last_dots) { 676 const dots = document.createElement('li'); 677 dots.classList.add('dots','last_dots'); 678 dots.innerHTML = '<span>...</span>'; 679 680 let last_page = pagination.querySelector('.num[data-page-number="' + total_pages + '"]'); 681 pagination.insertBefore(dots, last_page); 682 } 683 } else { 684 const last_dots = document.querySelector('.last_dots'); 685 if (last_dots) { 686 last_dots.remove(); 687 } 688 } 689 } 690 691} 692 693// Close filters when clicked out 694document.addEventListener('click', function (event) { 695 if(event.target.closest('[id="alm-filter-1"]:not([data-key="search"])') == null) { 696 const filters = document.getElementById('alm-filter-parent_1_-_race-inner'); 697 if (filters && filters.style.display === 'block') { 698 filters.setAttribute('aria-hidden', 'true'); 699 filters.style.display = 'none'; 700 document.getElementById('alm-filter-parent_1_-_race-title').setAttribute('aria-expanded', 'false'); 701 } 702 703 const filters2 = document.getElementById('alm-filter-parent_1_religion-inner'); 704 if (filters2 && filters2.style.display === 'block') { 705 filters2.setAttribute('aria-hidden', 'true'); 706 filters2.style.display = 'none'; 707 document.getElementById('alm-filter-parent_1_religion-title').setAttribute('aria-expanded', 'false'); 708 } 709 710 const filters3 = document.getElementById('alm-filter-children_in_home-inner'); 711 if (filters3 && filters3.style.display === 'block') { 712 filters3.setAttribute('aria-hidden', 'true'); 713 filters3.style.display = 'none'; 714 document.getElementById('alm-filter-children_in_home-title').setAttribute('aria-expanded', 'false'); 715 } 716 717 const filters4 = document.getElementById('alm-filter-select_state-inner'); 718 if (filters4 && filters4.style.display === 'block') { 719 filters4.setAttribute('aria-hidden', 'true'); 720 filters4.style.display = 'none'; 721 document.getElementById('alm-filter-select_state-title').setAttribute('aria-expanded', 'false'); 722 } 723 724 const filters5 = document.getElementById('alm-filter-profile_type-inner'); 725 if (filters5 && filters5.style.display === 'block') { 726 filters5.setAttribute('aria-hidden', 'true'); 727 filters5.style.display = 'none'; 728 document.getElementById('alm-filter-profile_type-title').setAttribute('aria-expanded', 'false'); 729 } 730 } else { 731 const filters = document.getElementById('alm-filter-parent_1_-_race-inner'); 732 const filters2 = document.getElementById('alm-filter-parent_1_religion-inner'); 733 const filters3 = document.getElementById('alm-filter-children_in_home-inner'); 734 const filters4 = document.getElementById('alm-filter-select_state-inner'); 735 const filters5 = document.getElementById('alm-filter-profile_type-inner'); 736 737 if (event.target.closest('#alm-filter-parent_1_-_race-title') != null) { 738 if (filters2 && filters2.style.display === 'block') { 739 filters2.setAttribute('aria-hidden', 'true'); 740 filters2.style.display = 'none'; 741 document.getElementById('alm-filter-parent_1_religion-title').setAttribute('aria-expanded', 'false'); 742 } 743 744 if (filters3 && filters3.style.display === 'block') { 745 filters3.setAttribute('aria-hidden', 'true'); 746 filters3.style.display = 'none'; 747 document.getElementById('alm-filter-children_in_home-title').setAttribute('aria-expanded', 'false'); 748 } 749 750 if (filters4 && filters4.style.display === 'block') { 751 filters4.setAttribute('aria-hidden', 'true'); 752 filters4.style.display = 'none'; 753 document.getElementById('alm-filter-select_state-title').setAttribute('aria-expanded', 'false'); 754 } 755 756 if (filters5 && filters5.style.display === 'block') { 757 filters5.setAttribute('aria-hidden', 'true'); 758 filters5.style.display = 'none'; 759 document.getElementById('alm-filter-profile_type-title').setAttribute('aria-expanded', 'false'); 760 } 761 } 762 763 if (event.target.closest('#alm-filter-parent_1_religion-title') != null) { 764 if (filters && filters.style.display === 'block') { 765 filters.setAttribute('aria-hidden', 'true'); 766 filters.style.display = 'none'; 767 document.getElementById('alm-filter-parent_1_-_race-title').setAttribute('aria-expanded', 'false'); 768 } 769 770 if (filters3 && filters3.style.display === 'block') { 771 filters3.setAttribute('aria-hidden', 'true'); 772 filters3.style.display = 'none'; 773 document.getElementById('alm-filter-children_in_home-title').setAttribute('aria-expanded', 'false'); 774 } 775 776 if (filters4 && filters4.style.display === 'block') { 777 filters4.setAttribute('aria-hidden', 'true'); 778 filters4.style.display = 'none'; 779 document.getElementById('alm-filter-select_state-title').setAttribute('aria-expanded', 'false'); 780 } 781 782 if (filters5 && filters5.style.display === 'block') { 783 filters5.setAttribute('aria-hidden', 'true'); 784 filters5.style.display = 'none'; 785 document.getElementById('alm-filter-profile_type-title').setAttribute('aria-expanded', 'false'); 786 } 787 } 788�
788 789 if (event.target.closest('#alm-filter-children_in_home-title') != null) { 790 if (filters && filters.style.display === 'block') { 791 filters.setAttribute('aria-hidden', 'true'); 792 filters.style.display = 'none'; 793 document.getElementById('alm-filter-parent_1_-_race-title').setAttribute('aria-expanded', 'false'); 794 } 795 796 if (filters2 && filters2.style.display === 'block') { 797 filters2.setAttribute('aria-hidden', 'true'); 798 filters2.style.display = 'none'; 799 document.getElementById('alm-filter-parent_1_religion-title').setAttribute('aria-expanded', 'false'); 800 } 801 802 if (filters4 && filters4.style.display === 'block') { 803 filters4.setAttribute('aria-hidden', 'true'); 804 filters4.style.display = 'none'; 805 document.getElementById('alm-filter-select_state-title').setAttribute('aria-expanded', 'false'); 806 } 807 808 if (filters5 && filters5.style.display === 'block') { 809 filters5.setAttribute('aria-hidden', 'true'); 810 filters5.style.display = 'none'; 811 document.getElementById('alm-filter-profile_type-title').setAttribute('aria-expanded', 'false'); 812 } 813 } 814 815 if (event.target.closest('#alm-filter-select_state-title') != null) { 816 if (filters && filters.style.display === 'block') { 817 filters.setAttribute('aria-hidden', 'true'); 818 filters.style.display = 'none'; 819 document.getElementById('alm-filter-parent_1_-_race-title').setAttribute('aria-expanded', 'false'); 820 } 821 822 if (filters2 && filters2.style.display === 'block') { 823 filters2.setAttribute('aria-hidden', 'true'); 824 filters2.style.display = 'none'; 825 document.getElementById('alm-filter-parent_1_religion-title').setAttribute('aria-expanded', 'false'); 826 } 827 828 if (filters3 && filters3.style.display === 'block') { 829 filters3.setAttribute('aria-hidden', 'true'); 830 filters3.style.display = 'none'; 831 document.getElementById('alm-filter-children_in_home-title').setAttribute('aria-expanded', 'false'); 832 } 833 834 if (filters5 && filters5.style.display === 'block') { 835 filters5.setAttribute('aria-hidden', 'true'); 836 filters5.style.display = 'none'; 837 document.getElementById('alm-filter-profile_type-title').setAttribute('aria-expanded', 'false'); 838 } 839 } 840 841 if (event.target.closest('#alm-filter-profile_type-title') != null) { 842 if (filters && filters.style.display === 'block') { 843 filters.setAttribute('aria-hidden', 'true'); 844 filters.style.display = 'none'; 845 document.getElementById('alm-filter-parent_1_-_race-title').setAttribute('aria-expanded', 'false'); 846 } 847 848 if (filters2 && filters2.style.display === 'block') { 849 filters2.setAttribute('aria-hidden', 'true'); 850 filters2.style.display = 'none'; 851 document.getElementById('alm-filter-parent_1_religion-title').setAttribute('aria-expanded', 'false'); 852 } 853 854 if (filters3 && filters3.style.display === 'block') { 855 filters3.setAttribute('aria-hidden', 'true'); 856 filters3.style.display = 'none'; 857 document.getElementById('alm-filter-children_in_home-title').setAttribute('aria-expanded', 'false'); 858 } 859 860 if (filters4 && filters4.style.display === 'block') { 861 filters4.setAttribute('aria-hidden', 'true'); 862 filters4.style.display = 'none'; 863 document.getElementById('alm-filter-select_state-title').setAttribute('aria-expanded', 'false'); 864 } 865 } 866 } 867}); 868 869const LS_KEY = 'my_favs'; 870 871function getFavs() { 872 try { 873 return JSON.parse(localStorage.getItem(LS_KEY)) || []; 874 } catch { 875 return []; 876 } 877} 878 879function saveFavs(arr) { 880 localStorage.setItem(LS_KEY, JSON.stringify(arr)); 881} 882 883/* ---------- UI toggler ---------- */ 884function updateHeart(el, isFav) { 885 const outline = el.querySelector('.favorite-icon'); 886 const filled = el.querySelector('.favorite-icon-filled'); 887 if (isFav) { 888 outline.style.display = 'none'; 889 filled .style.display = 'block'; 890 } else { 891 outline.style.display = 'block'; 892 filled .style.display = 'none'; 893 } 894} 895 896/* ---------- initial paint ---------- */ 897document.addEventListener('DOMContentLoaded', () => { 898 const favArray = getFavs(); 899 console.log('fav array', favArray); 900 901 document.querySelectorAll('.favorite-heart').forEach(el => { 902 const id = parseInt(el.dataset.postId, 10); 903 const isFav = favArray.includes(id); 904 updateHeart(el, isFav); 905 906 /* click handler */ 907 el.addEventListener('click', () => { 908 let favs = getFavs(); 909 910 const idx = favs.indexOf(id); 911 912 if (idx > -1) { // already a favourite â remove 913 favs.splice(idx, 1); 914 updateHeart(el, false); 915 } else { // add to favourites 916 favs.push(id); 917 updateHeart(el, true); 918 } 919 saveFavs(favs); 920 921 922 });
923 }); 924}); 925 926 927window.almDone = function(){ 928 const favArray = getFavs(); 929 console.log('fav array', favArray); 930 931 document.querySelectorAll('.favorite-heart').forEach(el => { 932 const id = parseInt(el.dataset.postId, 10); 933 const isFav = favArray.includes(id); 934 updateHeart(el, isFav); 935 936 /* click handler */ 937 el.addEventListener('click', () => { 938 let favs = getFavs(); 939 940 const idx = favs.indexOf(id); 941 942 if (idx > -1) { // already a favourite â remove 943 favs.splice(idx, 1); 944 updateHeart(el, false); 945 } else { // add to favourites 946 favs.push(id); 947 updateHeart(el, true); 948 } 949 saveFavs(favs); 950 951 952 }); 953 }); 954}; 955 956window.almFilterComplete = function(){ 957 const favArray = getFavs(); 958 console.log('fav array', favArray); 959 960 document.querySelectorAll('.favorite-heart').forEach(el => { 961 const id = parseInt(el.dataset.postId, 10); 962 const isFav = favArray.includes(id); 963 updateHeart(el, isFav); 964 965 /* click handler */ 966 el.addEventListener('click', () => { 967 let favs = getFavs(); 968 969 const idx = favs.indexOf(id); 970 971 if (idx > -1) { // already a favourite â remove 972 favs.splice(idx, 1); 973 updateHeart(el, false); 974 } else { // add to favourites 975 favs.push(id); 976 updateHeart(el, true); 977 } 978 saveFavs(favs); 979 980 981 }); 982 }); 983 }; 984 985 986 window.almComplete = function(alm){ 987 988 const favArray = getFavs(); 989 console.log('fav array', favArray); 990 991 document.querySelectorAll('.favorite-heart').forEach(el => { 992 const id = parseInt(el.dataset.postId, 10); 993 const isFav = favArray.includes(id); 994 updateHeart(el, isFav); 995 996 /* click handler */ 997 el.addEventListener('click', () => { 998 let favs = getFavs(); 999 1000 const idx = favs.indexOf(id); 1001 1002 if (idx > -1) { // already a favourite â remove 1003 favs.splice(idx, 1); 1004 updateHeart(el, false); 1005 } else { // add to favourites 1006 favs.push(id); 1007 updateHeart(el, true); 1008 } 1009 saveFavs(favs); 1010 1011 1012 }); 1013 }); 1014 }; 1015 1016 1017document.addEventListener('favorite-toggle', evt => { 1018 /* 1. find the heart that fired the event & its post-id */ 1019 const isFavorited = !!evt.detail.isFavorited; // comes from your toggle 1020 1021 /* 2. update favourites array in localStorage */ 1022 let favs = getFavs(); 1023 1024 if (isFavorited) { 1025 1026 //remove the paging stuff causing issues. 1027 (function () { 1028 const url = new URL(window.location.href); 1029 if (url.searchParams.has('pg')) { 1030 url.searchParams.delete('pg'); 1031 history.replaceState({}, '', url); 1032 } 1033 })(); 1034 1035 ajaxloadmore.filter( 1036 'fade', 1037 250, 1038 { 1039 'post-In': favs.join(','), 1040 'filters-startpage': 1 1041 } 1042 ); 1043 1044 } else { 1045 1046 const payload = { 1047 'post-type': 'profile', 1048 'post-In': '', 1049 }; 1050 1051 ajaxloadmore.filter( 1052 'fade', 1053 250, 1054 payload 1055 ); 1056 } 1057 1058 }); 1059 1060 1061jQuery(document).on("gform_post_render", function (event, form_id, current_page) { 1062 // elementos del formulario 1063 console.log("carga el form"); 1064 1065 if (form_id == 10) { 1066let linkButton = document.getElementById('input_10_181').value; 1067if (linkButton.length > 0) { 1068 document.getElementById('show_home_study_preview').style.display = 'block'; 1069 document.getElementById('show_link_home_study').href = linkButton; 1070} else { 1071 document.getElementById('current-upload-button').style.display = 'block'; 1072 1073} 1074 } 1075 1076 // Preview Elements 1077 const previewTitle = jQuery("#preview_title"); 1078 const previewQuote = jQuery("#preview_quote"); 1079 const previewLetter = jQuery("#preview_letter"); 1080 const previewPhoto = jQuery("#preview_photo"); 1081 1082 const previewTitle2 = jQuery("#preview_title_2"); 1083 const previewQuote2 = jQuery("#preview_quote_2"); 1084 const previewLetter2 = jQuery("#preview_letter_2"); 1085 const previewPhoto2 = jQuery("#preview_photo_2"); 1086 1087 const previewTitle3 = jQuery("#preview_title_3"); 1088 const previewQuote3 = jQuery("#preview_quote_3"); 1089 const previewLetter3 = jQuery("#preview_letter_3"); 1090 const previewPhoto3 = jQuery("#preview_photo_3"); 1091 1092 const previewTitle4 = jQuery("#preview_title_4"); 1093 const previewQuote4 = jQuery("#preview_quote_4"); 1094 const previewLetter4 = jQuery("#preview_letter_4"); 1095 const previewPhoto4 = jQuery("#preview_photo_4"); 1096 1097 const previewTitle5 = jQuery("#preview_title_5"); 1098 const previewQuote5 = jQuery("#preview_quote_5"); 1099 const previewLetter5 = jQuery("#preview_letter_5"); 1100 const previewPhoto5 = jQuery("#preview_photo_5"); 1101 1102 const previewTitle6 = jQuery("#preview_title_6");
1103 const previewQuote6 = jQuery("#preview_quote_6"); 1104 const previewLetter6 = jQuery("#preview_letter_6"); 1105 const previewPhoto6 = jQuery("#preview_photo_6"); 1106 1107 const previewTitle7 = jQuery("#preview_title_7"); 1108 const previewQuote7 = jQuery("#preview_quote_7"); 1109 const previewLetter7 = jQuery("#preview_letter_7"); 1110 const previewPhoto7 = jQuery("#preview_photo_7"); 1111 1112 const previewTitle8 = jQuery("#preview_title_8"); 1113 const previewQuote8 = jQuery("#preview_quote_8"); 1114 const previewLetter8 = jQuery("#preview_letter_8"); 1115 const previewPhoto8 = jQuery("#preview_photo_8"); 1116 1117 function registerTextChangeEvent(inputSelector, previewElement, defaultText = "") { 1118 jQuery(document).on("input", inputSelector, function () { 1119 previewElement.text(jQuery(this).val() !== '' ? jQuery(this).val() : defaultText); 1120 }); 1121 previewElement.text(jQuery(inputSelector).val() !== '' ? jQuery(inputSelector).val() : defaultText); 1122 } 1123 1124 function registerTinyMCEChangeEvent(inputId, previewElement) { 1125 const editor = tinymce.get(inputId); 1126 if (editor) { 1127 editor.on("keyup change input", function () { 1128 previewElement.html(editor.getContent()); 1129 }); 1130 1131 // Inicializa inmediatamente el contenido actual 1132 const content = editor.getContent(); 1133 if (content && previewElement) { 1134 previewElement.html(content); 1135 } 1136 1137 editor.on("init", function () { 1138 previewElement.html(editor.getContent()); 1139 }); 1140 } 1141 } 1142 1143 function registerPhotoChangeEvent(inputSelector, previewElement) { 1144 jQuery(document).off("change", inputSelector).on("change", inputSelector, function () { 1145 const $container = jQuery(this); 1146 const checkImage = setInterval(() => { 1147 const $img = $container.find('img').first(); 1148 1149 if ($img.length && $img.attr('src')) { 1150 clearInterval(checkImage); 1151 previewElement.attr("src", $img.attr('src')); 1152 } 1153 }, 1000); // Check every 100ms 1154 // if (input.files && input.files[0]) { 1155 // const reader = new FileReader(); 1156 // reader.onload = function (e) { 1157 // previewElement.attr("src", e.target.result); 1158 // }; 1159 // reader.readAsDataURL(input.files[0]); 1160 // } else { 1161 // previewElement.attr("src", ""); 1162 // } 1163 // previewElement.attr("src", sourceImage); 1164 }); 1165 } 1166 1167 function loadPreviousPhoto(inputSelector, previewElement) { 1168 const input = jQuery(inputSelector)[0]; 1169 if (input && input.value) { 1170 previewElement.attr("src", input.value); 1171 } else { 1172 previewElement.attr("src", "https://placehold.co/226x169"); 1173 } 1174 } 1175 1176 1177 // Titles - Profile Editor 1178 registerTextChangeEvent("#input_13_244", previewTitle); 1179 registerTextChangeEvent("#input_13_351", previewTitle2); 1180 registerTextChangeEvent("#input_13_356", previewTitle3); 1181 registerTextChangeEvent("#input_13_361", previewTitle4); 1182 registerTextChangeEvent("#input_13_366", previewTitle5); 1183 registerTextChangeEvent("#input_13_371", previewTitle6); 1184 registerTextChangeEvent("#input_13_377", previewTitle7); 1185 registerTextChangeEvent("#input_13_381", previewTitle8); 1186 1187 1188 // Quotes - Profile Editor 1189 registerTextChangeEvent("#input_13_245", previewQuote); 1190 registerTextChangeEvent("#input_13_352", previewQuote2); 1191 registerTextChangeEvent("#input_13_357", previewQuote3); 1192 registerTextChangeEvent("#input_13_362", previewQuote4); 1193 registerTextChangeEvent("#input_13_367", previewQuote5); 1194 registerTextChangeEvent("#input_13_372", previewQuote6); 1195 registerTextChangeEvent("#input_13_378", previewQuote7); 1196 registerTextChangeEvent("#input_13_382", previewQuote8); 1197 1198 // Esperar la inicialización de TinyMCE 1199 if (typeof tinymce !== "undefined") { 1200 // tinymce.init({ 1201 // setup: function (editor) { 1202 // editor.on("keyup change input", function () { 1203 // previewLetter.html(editor.getContent()); 1204 // }); 1205 1206 // // Inicializa inmediatamente el contenido actual 1207 // editor.on("init", function () { 1208 // previewLetter.html(editor.getContent()); 1209 // }); 1210 // }, 1211 // }); 1212 1213 // Manejar el caso en que TinyMCE ya esté inicializado (Gravity Forms lo hace) 1214 setTimeout(() => { 1215 // Letters - Profile Creator 1216 1217 // Letters - Profile Editor 1218 registerTinyMCEChangeEvent("input_13_246", previewLetter); 1219 registerTinyMCEChangeEvent("input_13_353", previewLetter2); 1220 registerTinyMCEChangeEvent("input_13_358", previewLetter3); 1221 registerTinyMCEChangeEvent("input_13_363", previewLetter4); 1222 registerTinyMCEChangeEvent("input_13_368", previewLetter5); 1223 registerTinyMCEChangeEvent("input_13_373", previewLetter6); 1224 registerTinyMCEChangeEvent("input_13_379", previewLetter7); 1225 registerTinyMCEChangeEvent("input_13_383", previewLetter8); 1226 }, 500); // Espera medio segundo a la inicialización del editor 1227 } 1228 1229 1230 // Photos - Profile Editor 1231 registerPhotoChangeEvent("#gform_multifile_upload_13_247", previewPhoto); 1232 registerPhotoChangeEvent("#gform_multifile_upload_13_354", previewPhoto2); 1233 registerPhotoChangeEvent("#gform_multifile_upload_13_359", previewPhoto3); 1234 registerPhotoChangeEvent("#gform_multifile_upload_13_364", previewPhoto4); 1235 registerPhotoChangeEvent("#gform_multifile_upload_13_369", previewPhoto5); 1236 registerPhotoChangeEvent("#gform_multifile_upload_13_374", previewPhoto6); 1237 registerPhotoChangeEvent("#gform_multifile_upload_13_380", previewPhoto7); 1238 registerPhotoChangeEvent("#gform_multifile_upload_13_384", previewPhoto8); 1239 1240 // Load previous photos - Profile Editor 1241 loadPreviousPhoto("#input_13_394", previewPhoto); 1242 loadPreviousPhoto("#input_13_395", previewPhoto2); 1243 loadPreviousPhoto("#input_13_396", previewPhoto3); 1244 loadPreviousPhoto("#input_13_397", previewPhoto4); 1245 loadPreviousPhoto("#input_13_398", previewPhoto5); 1246 loadPreviousPhoto("#input_13_399", previewPhoto6); 1247 loadPreviousPhoto("#input_13_400", previewPhoto7); 1248 loadPreviousPhoto("#input_13_401", previewPhoto8); 1249}); 1250 1251document.addEventListener('DOMContentLoaded', function () { 1252 const formWrapper = document.getElementById('gform_wrapper_1'); 1253 const progressBarPercentage = document.getElementById('progress-bar-percentage'); 1254 const progressBarPercentage2 = document.getElementById('progress-bar-percentage2'); 1255 const progressBar = document.getElementById('progress-bar'); 1256 const progressBar2 = document.getElementById('progress-bar2'); 1257 const progressBarPercentage2Tablet = document.getElementById('progress-bar-percentage2-tablet'); 1258 const progressBar2Tablet = document.getElementById('progress-bar2-tablet'); 1259 const titleElement = document.getElementById('encouraging-copy-title'); 1260 const contentElement = document.getElementById('encouraging-copy-content'); 1261 1262 // Configuración para cada paso del formulario 1263 const stepsConfig = { 1264 1: { 1265 percentage: '0%', 1266 progressBar: '10px', 1267 progressBarTablet: '10px', 1268 img: { 1269 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003326.webp', 1270 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005457.webp', 1271 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005457.webp' 1272 }, 1273 title: 'Encouraging reminders along the way', 1274 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Be authenticâyour true story is your greatest strength.</li><li>Share clear, warm photos that show your real life.</li><li>Speak from the heart in your letterâhonesty creates connection.</li></ul>' 1275 }, 1276 2: { 1277 percentage: '22%', 1278 progressBar: '76px', 1279 progressBarTablet: '142px', 1280 img: { 1281 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003328.webp', 1282 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005458.webp', 1283 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005458.webp' 1284 }, 1285 title: 'Encouraging reminders along the way:', 1286 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>This document is an important part of the adoption process and helps confirm that you are approved and ready to adopt.</li><li>Itâs a key step in building trust with expectant mothers and moving your profile forward.</li></ul>' 1287 }, 1288 3: { 1289 percentage: '33%', 1290 progressBar: '109px', 1291 progressBarTablet: '208px', 1292 img: { 1293 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003336.webp', 1294 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005459.webp', 1295 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005459.webp' 1296 }, 1297 title: 'Encouraging reminders along the way:', 1298 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Upload a variety of clear, warm photos that show who you are and what your life looks like â include pictures of you as a couple, with family and friends, doing activities you love, and in your home environment. These images help expectant mothers connect with you on a personal level.</li><li>Avoid blurry or overly filtered images. Include a mix of posed and candid shots.</li></ul>' 1299 }, 1300 4: { 1301 percentage: '55%', 1302 progressBar: '175px', 1303 progressBarTablet: '340px', 1304 img: { 1305 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/How-can-we-help-you-Desktop.webp', 1306 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/How-can-we-help-you-Mobile.webp', 1307 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/How-can-we-help-you-Mobile.webp' 1308 }, 1309 title: 'Encouraging reminders along the way:', 1310 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Upload a short, heartfelt video where you speak directly to expectant mothers. Let your personality, warmth, and values shine through â share a bit about who you are, your hopes for adoption, and what kind of life youâd offer a child.</li><li>Even a simple, authentic message filmed at home can make a big impact.</li></ul>' 1311 }, 1312 // 5: { 1313 // percentage: '66%', 1314 // progressBar: '208px', 1315 // progressBarTablet: '406px', 1316 // img: { 1317 // desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1318 // mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1319 // fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1320 // }, 1321 // title: 'Encouraging reminders along the way:', 1322 // content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Share your story, hopes, and heart with the mother who may choose you.</li><li>Your words can provide comfort, connection, and insight into your journey.</li><li>This is your chance to speak directly to an expectant motherâbe honest, be you.</li></ul>' 1323 // }, 1324 5: { 1325 percentage: '77%', 1326 progressBar: '241px', 1327 progressBarTablet: '472px', 1328 img: { 1329 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1330 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1331 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1332 }, 1333 title: 'Encouraging reminders along the way:', 1334 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Be authentic. Write the way you speakâlet your personality shine.</li><li>Include details. Whether it is a holiday, a weekend trip, or a family tradition, details help expectant mothers picture your life.</li><li>
1334Add photos. A few images can bring your story to life and make your post more engaging.</li><li>Share your values. What matters most to your family? This is a great place to express it.</li><li>Keep it warm and positive. Expectant mothers are looking for a safe and loving environmentâhelp them feel that through your stories.</li></ul>' 1335 }, 1336 6: { 1337 percentage: '88%', 1338 progressBar: '274px', 1339 progressBarTablet: '538px', 1340 img: { 1341 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1342 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1343 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1344 }, 1345 title: 'Encouraging reminders along the way:', 1346 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Be authentic. Write the way you speakâlet your personality shine.</li><li>Include details. Whether it is a holiday, a weekend trip, or a family tradition, details help expectant mothers picture your life.</li><li>Add photos. A few images can bring your story to life and make your post more engaging.</li><li>Share your values. What matters most to your family? This is a great place to express it.</li><li>Keep it warm and positive. Expectant mothers are looking for a safe and loving environmentâhelp them feel that through your stories.</li></ul>' 1347 }, 1348 7: { 1349 percentage: '100%', 1350 progressBar: '241px', 1351 progressBarTablet: '472px', 1352 img: { 1353 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1354 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1355 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1356 }, 1357 title: 'Encouraging reminders along the way:', 1358 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Every plan offers visibilityâchoose what works best for your family.</li><li>You can upgrade anytime if you want to increase your exposure.</li><li>Featured profiles get more viewsâconsider Premium for added reach.</li><li>All profiles are searchable, no matter the plan you choose.</li><li>Think about your goals and what feels right for your journey.</li><li>Need help choosing? Our team is here to guide you if youâre unsure.</li></ul>' 1359 }, 1360 8: { 1361 percentage: '88%', 1362 progressBar: '274px', 1363 progressBarTablet: '538px', 1364 img: { 1365 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1366 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1367 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1368 }, 1369 title: '', 1370 content: '' 1371 }, 1372 9: { 1373 percentage: '100%', 1374 progressBar: '310px', 1375 progressBarTablet: '620px', 1376 img: { 1377 desktop: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000003334.webp', 1378 mobile: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp', 1379 fallback: 'https://live-adoption-demo.pantheonsite.io/wp-content/uploads/2025/04/Frame-1000005460.webp' 1380 }, 1381 title: '', 1382 content: '' } 1383 }; 1384 1385 function updateContentForStep(step) { 1386 const config = stepsConfig[step]; 1387 progressBarPercentage.textContent = config.percentage; 1388 progressBar.style.width = config.progressBar; 1389 progressBarPercentage2.textContent = config.percentage; 1390 progressBar2.style.width = config.progressBar; 1391 progressBarPercentage2Tablet.textContent = config.percentage; 1392 progressBar2Tablet.style.width = config.progressBarTablet; 1393 titleElement.textContent = config.title; 1394 contentElement.innerHTML = config.content; 1395 if (step === 1) { 1396 document.getElementById('about-check').style.display = 'none'; 1397 document.getElementById('about-box').classList.remove('bg-[#5aafbb]'); 1398 document.getElementById('about-box').classList.add('bg-white'); 1399 document.getElementById('home-study-text').classList.remove('text-[#333333]'); 1400 document.getElementById('home-study-text').classList.add('text-black/20'); 1401 document.getElementById('home-study-box').classList.remove('bg-white'); 1402 document.getElementById('home-study-box').classList.add('bg-[#e0e0e0]'); 1403 } 1404 if (step === 2) { 1405 document.getElementById('about-check').style.display = 'flex'; 1406 document.getElementById('about-box').classList.remove('bg-white'); 1407 document.getElementById('about-box').classList.add('bg-[#5aafbb]'); 1408 document.getElementById('home-study-box').classList.remove('bg-[#5aafbb]'); 1409 document.getElementById('home-study-text').classList.remove('text-black/20'); 1410 document.getElementById('home-study-box').classList.remove('bg-[#e0e0e0]'); 1411 document.getElementById('home-study-box').classList.add('bg-white'); 1412 document.getElementById('home-study-text').classList.remove('text-black/20'); 1413 document.getElementById('home-study-text').classList.add('text-[#333333]'); 1414 document.getElementById('home-study-check').style.display = 'none'; 1415 document.getElementById('photo-album-text').classList.add('text-black/20'); 1416 document.getElementById('photo-album-text').classList.remove('text-[#333333]'); 1417 } 1418 1419 if (step == 3) { 1420 document.getElementById('home-study-check').style.display = 'flex'; 1421 document.getElementById('home-study-box').classList.remove('bg-white'); 1422 document.getElementById('home-study-box').classList.add('bg-[#5aafbb]'); 1423 document.getElementById('photo-album-text').classList.remove('text-black/20'); 1424 document.getElementById('photo-album-text').classList.add('text-[#333333]'); 1425 document.getElementById('photo-album-check').style.display = 'none'; 1426 document.getElementById('photo-album-box').classList.remove('bg-[#5aafbb]'); 1427 document.getElementById('photo-album-box').classList.add('bg-white'); 1428 document.getElementById('photo-album-box').classList.remove('bg-[#e0e0e0]'); 1429 document.getElementById('videos-text').classList.add('text-black/20'); 1430 document.getElementById('videos-text').classList.remove('text-[#333333]'); 1431 } 1432 1433 if (step == 4) { 1434 document.getElementById('photo-album-check').style.display = 'flex'; 1435 document.getElementById('photo-album-box').classList.remove('bg-white'); 1436 document.getElementById('photo-album-box').classList.add('bg-[#5aafbb]'); 1437 1438 document.getElementById('videos-text').classList.remove('text-black/20'); 1439 document.getElementById('videos-text').classList.add('text-[#333333]'); 1440 document.getElementById('videos-check').style.display = 'none'; 1441 document.getElementById('videos-box').classList.remove('bg-[#5aafbb]'); 1442 document.getElementById('videos-box').classList.add('bg-white'); 1443 document.getElementById('videos-box').classList.remove('bg-[#e0e0e0]'); 1444 1445 document.getElementById('letter-to-mom-text').classList.add('text-black/20'); 1446 document.getElementById('letter-to-mom-text').classList.remove('text-[#333333]'); 1447 1448 document.getElementById('videos-check').style.display = 'flex'; 1449 document.getElementById('videos-box').classList.remove('bg-white'); 1450 document.getElementById('videos-box').classList.add('bg-[#5aafbb]'); 1451 1452 document.getElementById('letter-to-mom-text').classList.remove('text-black/20'); 1453 document.getElementById('letter-to-mom-text').classList.add('text-[#333333]'); 1454 document.getElementById('letter-to-mom-check').style.display = 'none'; 1455 document.getElementById('letter-to-mom-box').classList.remove('bg-[#5aafbb]'); 1456 document.getElementById('letter-to-mom-box').classList.add('bg-white'); 1457 document.getElementById('letter-to-mom-box').classList.remove('bg-[#e0e0e0]'); 1458 1459 document.getElementById('posts-text').classList.add('text-black/20'); 1460 document.getElementById('posts-text').classList.remove('text-[#333333]'); 1461 } 1462 1463 if (step == 5) { 1464 document.getElementById('letter-to-mom-check').style.display = 'flex'; 1465 document.getElementById('letter-to-mom-box').classList.remove('bg-white'); 1466 document.getElementById('letter-to-mom-box').classList.add('bg-[#5aafbb]'); 1467 1468 document.getElementById('posts-text').classList.remove('text-black/20'); 1469 document.getElementById('posts-text').classList.add('text-[#333333]'); 1470 document.getElementById('posts-check').style.display = 'none'; 1471 document.getElementById('posts-box').classList.remove('bg-[#5aafbb]'); 1472 document.getElementById('posts-box').classList.add('bg-white'); 1473 document.getElementById('posts-box').classList.remove('bg-[#e0e0e0]'); 1474 1475 document.getElementById('contact-info-text').classList.add('text-black/20'); 1476 document.getElementById('contact-info-text').classList.remove('text-[#333333]'); 1477 } 1478 1479 if (step == 6) { 1480 document.getElementById('posts-check').style.display = 'flex'; 1481 document.getElementById('posts-box').classList.remove('bg-white'); 1482 document.getElementById('posts-box').classList.add('bg-[#5aafbb]'); 1483 1484 document.getElementById('contact-info-text').classList.remove('text-black/20'); 1485 document.getElementById('contact-info-text').classList.add('text-[#333333]'); 1486 document.getElementById('contact-info-check').style.display = 'none'; 1487 document.getElementById('contact-info-box').classList.remove('bg-[#5aafbb]'); 1488 document.getElementById('contact-info-box').classList.add('bg-white'); 1489 document.getElementById('contact-info-box').classList.remove('bg-[#e0e0e0]'); 1490 } 1491 1492 if (step == 7) { 1493 document.getElementById('contact-info-check').style.display = 'flex'; 1494 document.getElementById('contact-info-box').classList.remove('bg-white'); 1495 document.getElementById('contact-info-box').classList.add('bg-[#5aafbb]'); 1496 } 1497 } 1498 1499 function detectCurrentStep() { 1500 if (formWrapper == null) { 1501 return null; 1502 } 1503 const pages = formWrapper.querySelectorAll('.gform_page'); 1504 for (let i = 0; i < pages.length; i++) { 1505 if (pages[i].style.display !== 'none') { 1506 return i + 1; // pages are 1-indexed in config 1507 } 1508 } 1509 return null; 1510 } 1511 1512 // Observa cambios en el DOM 1513 const observer = new MutationObserver(() => { 1514 const step = detectCurrentStep(); 1515 if (step) { 1516 updateContentForStep(step); 1517 } 1518 });
1519 1520 // Inicia la observación del wrapper de Gravity Forms 1521 if (document.getElementById('gform_wrapper_1')) { 1522 observer.observe(formWrapper, { 1523 childList: true, 1524 subtree: true 1525 }); 1526 } 1527 1528 // Detecta paso inicial 1529 const initialStep = detectCurrentStep(); 1530 if (initialStep) { 1531 updateContentForStep(initialStep); 1532 } 1533 }); 1534 1535jQuery(document).on('gform_confirmation_loaded', function(event, formId) { 1536 if (formId !== 1) { 1537 return; // Solo aplica para el formulario con ID 1 1538 } 1539 1540 document.getElementById('progress-bar-percentage').textContent = '100%'; 1541 document.getElementById('progress-bar').style.width = '310px'; 1542 document.getElementById('progress-bar-percentage2').textContent = '100%'; 1543 document.getElementById('progress-bar2').style.width = '310px'; 1544 document.getElementById('progress-bar-percentage2-tablet').textContent = '100%'; 1545 document.getElementById('progress-bar2-tablet').style.width = '620px'; 1546 document.getElementById('contact-info-check').style.display = 'flex'; 1547 document.getElementById('contact-info-box').classList.remove('bg-white'); 1548 document.getElementById('contact-info-box').classList.add('bg-[#5aafbb]'); 1549}); 1550 1551// Show/hide profile sections 1552// function setupProfileNavigation() { 1553// // Map of button IDs to their corresponding content div IDs 1554// const sectionMap = { 1555// 'show-about': 'profile-builder-about', 1556// 'show-homestudy': 'profile-builder-homestudy', 1557// 'show-albums': 'profile-builder-albums', 1558// 'show-videos': 'profile-builder-videos', 1559// 'show-letters': 'profile-builder-letters', 1560// 'show-posts': 'profile-builder-posts', 1561// 'show-contactinfo': 'profile-builder-contactinfo' 1562// }; 1563 1564// // Add click event listeners to all section buttons 1565// Object.entries(sectionMap).forEach(([buttonId, sectionId]) => { 1566// const button = document.getElementById(buttonId); 1567// if (button) { 1568// button.addEventListener('click', (e) => { 1569// e.preventDefault(); 1570 1571// // Hide all sections 1572// Object.values(sectionMap).forEach(id => { 1573// const element = document.getElementById(id); 1574// if (element) element.classList.add('hidden'); 1575// }); 1576 1577// // Show the selected section 1578// const selectedSection = document.getElementById(sectionId); 1579// if (selectedSection) selectedSection.classList.remove('hidden'); 1580// }); 1581// } 1582// }); 1583// } 1584 1585 1586function setupProfileNavigation() { 1587 // Map of button IDs to their corresponding content div IDs 1588 const sectionMap = { 1589 'show-about': 'profile-builder-about', 1590 'show-homestudy': 'profile-builder-homestudy', 1591 'show-albums': 'profile-builder-albums', 1592 'show-videos': 'profile-builder-videos', 1593 'show-letters': 'profile-builder-letters', 1594 'show-posts': 'profile-builder-posts', 1595 'show-contactinfo': 'profile-builder-contactinfo' 1596 }; 1597 1598 const sectionContent = { 1599 "show-about": 1600 { 1601 title: 'Encouraging reminders along the way:', 1602 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>This document is an important part of the adoption process and helps confirm that you are approved and ready to adopt.</li><li>Itâs a key step in building trust with expectant mothers and moving your profile forward.</li></ul>' 1603 }, 1604 "show-homestudy": 1605 { 1606 title: 'Encouraging reminders along the way:', 1607 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Upload a variety of clear, warm photos that show who you are and what your life looks like â include pictures of you as a couple, with family and friends, doing activities you love, and in your home environment. These images help expectant mothers connect with you on a personal level.</li><li>Avoid blurry or overly filtered images. Include a mix of posed and candid shots.</li></ul>' 1608 }, 1609 "show-albums": 1610 { 1611 title: 'Encouraging reminders along the way:', 1612 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Upload a short, heartfelt video where you speak directly to expectant mothers. Let your personality, warmth, and values shine through â share a bit about who you are, your hopes for adoption, and what kind of life youâd offer a child.</li><li>Even a simple, authentic message filmed at home can make a big impact.</li></ul>' 1613 }, 1614 "show-videos": 1615 { 1616 1617 title: 'Encouraging reminders along the way:', 1618 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Share your story, hopes, and heart with the mother who may choose you.</li><li>Your words can provide comfort, connection, and insight into your journey.</li><li>This is your chance to speak directly to an expectant motherâbe honest, be you.</li></ul>' 1619 }, 1620 "show-letters": 1621 { 1622 title: 'Encouraging reminders along the way:', 1623 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Be authentic. Write the way you speakâlet your personality shine.</li><li>Include details. Whether it is a holiday, a weekend trip, or a family tradition, details help expectant mothers picture your life.</li><li>
1623Add photos. A few images can bring your story to life and make your post more engaging.</li><li>Share your values. What matters most to your family? This is a great place to express it.</li><li>Keep it warm and positive. Expectant mothers are looking for a safe and loving environmentâhelp them feel that through your stories.</li></ul>' 1624 }, 1625 "show-posts": 1626 { 1627 title: 'Encouraging reminders along the way:', 1628 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Be authentic. Write the way you speakâlet your personality shine.</li><li>Include details. Whether it is a holiday, a weekend trip, or a family tradition, details help expectant mothers picture your life.</li><li>Add photos. A few images can bring your story to life and make your post more engaging.</li><li>Share your values. What matters most to your family? This is a great place to express it.</li><li>Keep it warm and positive. Expectant mothers are looking for a safe and loving environmentâhelp them feel that through your stories.</li></ul>' 1629 }, 1630 "show-contactinfo": 1631 { 1632 title: 'Encouraging reminders along the way:', 1633 content: '<ul class="list-disc flex flex-col gap-3 pl-5 leading-[20px]"><li>Every plan offers visibilityâchoose what works best for your family.</li><li>You can upgrade anytime if you want to increase your exposure.</li><li>Featured profiles get more viewsâconsider Premium for added reach.</li><li>All profiles are searchable, no matter the plan you choose.</li><li>Think about your goals and what feels right for your journey.</li><li>Need help choosing? Our team is here to guide you if youâre unsure.</li></ul>' 1634 } 1635}; 1636 1637const titleElement = document.getElementById('encouraging-copy-title'); 1638const contentElement = document.getElementById('encouraging-copy-content'); 1639 1640const updateContent = (sectionId) => { 1641 const section = sectionContent[sectionId]; 1642 if (section) { 1643 titleElement.textContent = section.title; 1644 contentElement.innerHTML = section.content; 1645 } 1646}; 1647 1648 // Function to show a specific section and hide others 1649 const showSection = (sectionId) => { 1650 // Hide all sections 1651 Object.values(sectionMap).forEach(id => { 1652 const element = document.getElementById(id); 1653 if (element) element.classList.add('hidden'); 1654 }); 1655 1656 // Show the selected section 1657 const selectedSection = document.getElementById(sectionId); 1658 if (selectedSection) { 1659 selectedSection.classList.remove('hidden'); 1660 // Save to localStorage 1661 localStorage.setItem('lastSelectedSection', sectionId); 1662 } 1663 }; 1664 1665 // Add click event listeners to all section buttons 1666 Object.entries(sectionMap).forEach(([buttonId, sectionId]) => { 1667 const button = document.getElementById(buttonId); 1668 if (button) { 1669 button.addEventListener('click', (e) => { 1670 e.preventDefault(); 1671 showSection(sectionId); 1672 updateContent(sectionId); 1673 }); 1674 } 1675 }); 1676 1677 // Check for saved section and show it, or show the first section by default 1678 const lastSection = localStorage.getItem('lastSelectedSection'); 1679 if (lastSection && document.getElementById(lastSection)) { 1680 showSection(lastSection); 1681 updateContent(lastSection); 1682 } else { 1683 // Show the first section by default if no saved section exists 1684 const firstSection = Object.values(sectionMap)[0]; 1685 if (firstSection) { 1686 showSection(firstSection); 1687 updateContent(firstSection); 1688 } 1689 } 1690} 1691 1692// Initialize the profile navigation when the DOM is loaded 1693document.addEventListener('DOMContentLoaded', function() { 1694 setupProfileNavigation(); 1695}); 1696 1697// document.addEventListener('DOMContentLoaded', function() { 1698// const form = document.querySelector('.frontend-form'); 1699 1700// form.addEventListener('submit', function(e) { 1701// e.preventDefault(); 1702 1703// const formData = new FormData(form); 1704// formData.append('action', 'acf_frontend_submit_form'); 1705 1706// fetch("/wp-admin/admin-ajax.php", { 1707// method: 'POST', 1708// credentials: 'same-origin', 1709// body: formData 1710// }) 1711// .then(res => res.json()) 1712// .then(response => { 1713// if(response.success){ 1714// alert('Formulario guardado correctamente!'); 1715// location.reload(); 1716// } else { 1717// alert('Error guardando formulario.'); 1718// console.log(response); 1719// } 1720// }) 1721// .catch(err => { 1722// alert('Error en el servidor.'); 1723// console.error(err); 1724// }); 1725// }); 1726// }); 1727 1728// document.addEventListener('DOMContentLoaded', function() { 1729// const form = document.querySelector('.frontend-form'); 1730 1731// if (form && !form.querySelector('button[type="submit"]')) { 1732// const submitBtn = document.createElement('button'); 1733// submitBtn.type = 'submit'; 1734// submitBtn.textContent = 'Update'; 1735// submitBtn.classList.add('acf-button', 'button', 'button-primary'); 1736// form.appendChild(submitBtn); 1737// } 1738// }); 1739 1740document.addEventListener("alpine:init", () => { 1741 Alpine.data("editProfileImage", () => ({ 1742 image: null, 1743 init() { 1744 const self = this; 1745 self.image = document.getElementById("input_9_427").value; 1746 const input = document.getElementById("input_9_73"); 1747 if (input) { 1748 input.addEventListener("change", function () { 1749 if (input.files && input.files[0]) { 1750 const reader = new FileReader(); 1751 reader.onload = function (e) { 1752 self.image = e.target.result; 1753 };
1754 reader.readAsDataURL(input.files[0]); 1755 } 1756 }); 1757 } 1758 }, 1759 })); 1760 1761 /* 1762 Alpine.data("editLetter", () => ({ 1763 title: '', 1764 quote: '', 1765 letter: '', 1766 photo: '', 1767 1768 init() { 1769 const self = this; 1770 1771 const id_title = self.$el.dataset.idTitle; 1772 const id_quote = self.$el.dataset.idQuote; 1773 const id_letter = self.$el.dataset.idLetter; 1774 const id_photo = self.$el.dataset.idPhoto; 1775 1776 function updateValue(id, property) { 1777 return () => { 1778 self[property] = jQuery(`#input_${id}`).val(); 1779 } 1780 } 1781 1782 jQuery(`#input_${id_title}`).on('input', updateValue(id_title, 'title')); 1783 jQuery(`#input_${id_quote}`).on('input', updateValue(id_quote, 'quote')); 1784 1785 updateValue(id_title, 'title')(); 1786 updateValue(id_quote, 'quote')(); 1787 1788 // waitForTinyMCE(() => { 1789 // tinymce.init({ 1790 // selector: `#input_${id_letter}`, 1791 // setup: function(editor) { 1792 // editor.on('keyup change input', function() { 1793 // self.letter = editor.getContent(); 1794 // }); 1795 1796 // // Inicializa inmediatamente el contenido actual 1797 // editor.on('init', function() { 1798 // console.log('hahahahah'); 1799 // self.letter = editor.getContent(); 1800 // }); 1801 // } 1802 // }); 1803 // }); 1804 1805 // waitForTinyMCEReady().then(() => { 1806 // tinymce.init({ 1807 // selector: `#input_${id_letter}`, 1808 // setup: function(editor) { 1809 // editor.on('keyup change input', function() { 1810 // console.log('Content changed'); 1811 // self.letter = editor.getContent(); 1812 // }); 1813 1814 // // Inicializa inmediatamente el contenido actual 1815 // editor.on('init', function() { 1816 // console.log('initialized'); 1817 // self.letter = editor.getContent(); 1818 // }); 1819 // } 1820 // }); 1821 // }); 1822 } 1823 })); 1824 */ 1825}); 1826 1827// function waitForTinyMCEReady() { 1828// return new Promise((resolve) => { 1829// function check() { 1830// if (window.tinymce) { 1831// resolve(); 1832// } else { 1833// requestAnimationFrame(check); 1834// } 1835// } 1836// check(); 1837// }); 1838// } 1839 1840// function waitForTinyMCE(callback) { 1841// const interval = setInterval(() => { 1842// if (window.tinymce) { 1843// clearInterval(interval); 1844// callback(); 1845// } 1846// }, 50); 1847// } 1848 1849document.addEventListener('gform_post_render', function(event, formId){ 1850 if(formId === 10) { 1851 const $ = jQuery; 1852 const fieldId = '#input_10_16'; 1853 1854 // Caso 1: HTML5 <input type="date"> 1855 const dateInput = document.querySelector(fieldId); 1856 if(dateInput && dateInput.type === 'date') { 1857 const today = new Date(); 1858 today.setDate(today.getDate() + 1); // mañana 1859 const yyyy = today.getFullYear(); 1860 const mm = String(today.getMonth() + 1).padStart(2, '0'); 1861 const dd = String(today.getDate()).padStart(2, '0'); 1862 dateInput.min = `${yyyy}-${mm}-${dd}`; 1863 } 1864 1865 // Caso 2: jQuery UI datepicker (modo clásico de GF) 1866 if ($.fn.datepicker) { 1867 $(fieldId).datepicker('option', 'minDate', 1); // 1 = mañana 1868 } 1869 } 1870}); 1871 1872gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) { 1873 if ( formId == 9 || formId == 20 ) { 1874 1875 optionsObj.minDate = null; 1876 optionsObj.maxDate = null; 1877 1878 // Rango DOB tÃpico 1879 optionsObj.changeMonth = true; 1880 optionsObj.changeYear = true; 1881 optionsObj.minDate = '-60Y'; // mÃnimo 120 años atrás 1882 optionsObj.maxDate = '-18Y'; // máximo 18 años atrás 1883 } 1884 if (formId == 10 ) { 1885 optionsObj.minDate = '+2M'; 1886 } 1887 if (formId == 3) { 1888 optionsObj.minDate = '+1D'; 1889 let date = new Date(); 1890 date.setMonth(date.getMonth() + 9); 1891 optionsObj.maxDate = date; 1892 } 1893 return optionsObj; 1894}); 1895 1896 1897 1898 1899document.addEventListener('DOMContentLoaded', function() { 1900 1901 1902 1903 let form = document.querySelector('form#gform_4'); // Adjust the selector to match your form's ID 1904 let data = false; 1905 if (!form) { 1906 return; 1907 } 1908 1909 1910 let fpPromise = null; 1911 let fingerprintChecked = false; 1912 let fingerprintData = null; 1913 const FINGERPRINT_CACHE_KEY = 'fingerprint_data'; 1914 const TIMEOUT_MS = 3000; 1915 1916 // Check for cached fingerprint data 1917 const cachedFingerprint = localStorage.getItem(FINGERPRINT_CACHE_KEY); 1918 if (cachedFingerprint) { 1919 try { 1920 if (fingerprintData.suspectScore !== null) { 1921 fingerprintChecked = true; 1922 fingerprintData = JSON.parse(cachedFingerprint); 1923 } 1924 } catch (e) { 1925 console.error('Error parsing cached fingerprint data', e); 1926 } 1927 } 1928 1929 const setGFInputValue = (inputId, value) => { 1930 const input = document.getElementById(inputId); 1931 if (input) { 1932 input.value = value || ''; 1933 input.dispatchEvent(new Event('change', { bubbles: true })); 1934 } 1935 }; 1936 1937 // Initialize fingerprint on first interaction 1938 1939 const fetchEventData = async (requestId) => { 1940 console.log('fetching event data', requestId); 1941 try { 1942 const response = await fetch('https://api.fpjs.io/events/' + requestId, { 1943 method: 'GET', 1944 headers: { 1945 'Auth-API-Key': 'pd37CKNipQk9EzghvAgq', 1946 'accept': 'application/json' 1947 } 1948 }); 1949 1950 if (!response.ok) { 1951 throw new Error(`HTTP error! status: ${response.status}`); 1952 } 1953 1954 const data = await response.json(); 1955 return data; 1956 } catch (error) { 1957 console.error('Error fetching event data:', error); 1958 throw error; 1959 } 1960} 1961 const initFingerprintOnInteraction = () => { 1962 console.log('is initiating the fingerprint install');
1963 if (fpPromise) return; 1964 1965 fpPromise = import('https://fpnew.adoption.com/web/v3/Y2XFawxR2AjKejHGGpnD') 1966 .then(FingerprintJS => FingerprintJS.load({ 1967 endpoint: [ 1968 "https://fpnew.adoption.com", 1969 FingerprintJS.defaultEndpoint 1970 ] 1971 })) 1972 .then(fp => fp.get()) 1973 .then(result => { 1974 1975 console.log('marking fingerprint', result); 1976 fingerprintData = { 1977 visitorId: result.visitorId, 1978 requestId: result.requestId, 1979 score: result.confidence.score, 1980 riskScore: result.riskScore, // Add risk score 1981 botDetected: result.botDetected, // Add bot detection 1982 timestamp: new Date().toISOString() 1983 }; 1984 1985 1986 1987 // localStorage.setItem(FINGERPRINT_CACHE_KEY, JSON.stringify(fingerprintData)); 1988 fingerprintChecked = true; 1989 1990 // Add hidden fields to the form 1991 addFingerprintFields(form, fingerprintData); 1992 1993 setTimeout(() => { 1994 fetchEventData(result.requestId).then(data => { 1995 1996 let browserData = data.products.identification.data.browserDetails.browserName; 1997 1998 if (browserData === 'Facebook') { 1999 document.getElementById('gform_submit_button_4').disabled = true; 2000 document.getElementById('gform_submit_button_4').style.display = 'none'; 2001 // document.getElementById('gform_previous_button_4').disabled = true; 2002 // document.getElementById('gform_previous_button_4').style.display = 'none'; 2003 form.style.display = 'none'; 2004 // document.getElementById('custom_form_field').style.display = 'none'; 2005 document.getElementById('form_data_lead').style.display = 'block'; 2006 } 2007 2008 if (browserData === 'Instagram') { 2009 document.getElementById('gform_submit_button_4').disabled = true; 2010 document.getElementById('gform_submit_button_4').style.display = 'none'; 2011 // document.getElementById('gform_previous_button_4').disabled = true; 2012 // document.getElementById('gform_previous_button_4').style.display = 'none'; 2013 form.style.display = 'none'; 2014 document.getElementById('form_data_lead').style.display = 'block'; 2015 } 2016 2017 fingerprintData.suspectScore = data.products.suspectScore.data.result; 2018 localStorage.setItem(FINGERPRINT_CACHE_KEY, JSON.stringify(fingerprintData)); 2019 2020 2021 if (fingerprintData.suspectScore > 7) { 2022 2023 2024 document.getElementById('gform_submit_button_4').disabled = true; 2025 document.getElementById('gform_submit_button_4').style.display = 'none'; 2026 // document.getElementById('gform_previous_button_4').disabled = true; 2027 // document.getElementById('gform_previous_button_4').style.display = 'none'; 2028 form.style.display = 'none'; 2029 document.getElementById('form_data_lead').style.display = 'block'; 2030 2031 } 2032 2033 addFingerprintFields(form, fingerprintData); 2034 2035 2036 }) 2037 .catch(error => { 2038 console.error('Failed to fetch event data:', error); 2039 }); 2040 }, 2000); 2041 2042 2043 2044 2045 }) 2046 .catch(error => { 2047 console.error('FingerprintJS error:', error); 2048 fingerprintChecked = true; // Allow form submission even if fingerprint fails 2049 }); 2050 }; 2051 2052 initFingerprintOnInteraction(); 2053 2054 // Add hidden fields to the form 2055 const addFingerprintFields = (form, data) => { 2056 // Remove any existing fingerprint fields 2057 const existingFields = form.querySelectorAll('input[name^="fingerprint_"]'); 2058 existingFields.forEach(field => field.remove()); 2059 2060 // Add new fields 2061 for (const [key, value] of Object.entries(data)) { 2062 const input = document.createElement('input'); 2063 input.type = 'hidden'; 2064 input.name = `fingerprint_${key}`; 2065 input.value = value; 2066 form.appendChild(input); 2067 } 2068 }; 2069 2070 // Handle form submission 2071 2072 document.addEventListener('gform_pre_submission', function () { 2073 if (fingerprintData) { 2074 // setGFInputValue('input_4_32', fingerprintData.requestId); 2075 // setGFInputValue('input_4_33', fingerprintData.visitorId); 2076 // setGFInputValue('input_4_28', fingerprintData.suspectScore); 2077 } 2078 }); 2079 2080 2081 2082 // Initialize fingerprint on first interaction 2083// form.addEventListener('click', initFingerprintOnInteraction, { once: true });
2084// form.addEventListener('focusin', initFingerprintOnInteraction, { once: true }); 2085});
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.