PageSourceSearch

https://www.nfcc.org/wp-content/themes/foundation/js/2023-scripts.js?ver=1.0.13

js nfcc.org collected 2026-10-02 07:29:34 UTC 6,552 bytes, 186 lines download raw bytes

1jQuery(document).ready(function($) {
2    var $window = $(window);
3
4    // Homepage 1 & 2 URL Parameter updates
5    var pathname = window.location.pathname;
6    var locSuffix = (pathname === '/' || pathname === '') ? '-hpa' : 
7                    (pathname === '/nfcc-home' || pathname === '/nfcc-home/') ? '-hpb' : null;
8
9    if (locSuffix) {
10        $('a[href*="loc="]').each(function() {
11            var $link = $(this);
12            var href = $link.attr('href');
13            var updated = href.replace(/loc=([^&\#]*)/g, function(match, locValue) {
14                // Skip if already just hpa or hpb
15                if (locValue === 'hpa' || locValue === 'hpb') {
16                    return match;
17                }
18                // Remove trailing slash and any existing suffix before appending
19                locValue = locValue.replace(/\/$/, '').replace(/-hp[12]$/, '');
20                return 'loc=' + locValue + locSuffix;
21            });
22            $link.attr('href', updated);
23        });
24    }
25
26    // Track the homepage variant so the debt-navigator results page can
27    // append ?loc=debtnav-hpb to CTA links when the user came from /nfcc-home/.
28    if (pathname === '/nfcc-home' || pathname === '/nfcc-home/') {
29        sessionStorage.setItem('nfccOrigin', 'hpb');
30    } else if (pathname === '/' || pathname === '') {
31        sessionStorage.setItem('nfccOrigin', 'hpa');
32    }
33
34    // On debt-navigator and step-3 landing pages, update header phone + agency finder link to match the origin variant.
35    var debtNavPages = [
36        '/debt-navigator', '/debt-navigator/',
37        '/debt-management-plan', '/debt-management-plan/',
38        '/bankruptcy-counseling', '/bankruptcy-counseling/',
39        '/budgeting-financing-counseling', '/budgeting-financing-counseling/'
40    ];
41    if (debtNavPages.indexOf(pathname) !== -1) {
42        var origin = sessionStorage.getItem('nfccOrigin');
43        var phoneMap = { hpa: '877-360-6322', hpb: '833-746-7578' };
44        var locMap   = { hpa: 'hpa', hpb: 'hpb' };
45        var phone = phoneMap[origin];
46        var loc   = locMap[origin];
47        if (phone || loc) {
48            $(document).ready(function() {
49                if (phone) {
50                    $('.btn-link__phone span').text(phone);
51                    $('.btn-link__phone').attr('href', 'tel:' + phone.replace(/\D/g, ''));
52                }
53                if (loc) {
54                    $('.btn-link__email').each(function() {
55                        var href = $(this).attr('href') || '';
56                        if (href && href.indexOf('loc=') === -1) {
57                            var sep = href.indexOf('?') === -1 ? '?' : '&';
58                            $(this).attr('href', href + sep + 'loc=' + loc);
59                        }
60                    });
61                }
62            });
63        }
64    }
65
66    // Append ?loc=debtnav-hpb to debt-navigator CTA links when origin is /nfcc-home.
67    function updateDebtNavLinks() {
68        if (sessionStorage.getItem('nfccOrigin') !== 'hpb') { return; }
69        $('.debt-navigator-cta a').each(function() {
70            var $link = $(this);
71            var href = $link.attr('href') || '';
72            if (!href || href.indexOf('loc=debtnav-hpb') !== -1) { return; }
73            var sep = href.indexOf('?') === -1 ? '?' : '&';
74            $link.attr('href', href + sep + 'loc=debtnav-hpb');
75        });
76    }
77    // Run on page load (page-redirect confirmation) and after GF AJAX confirmation.
78    updateDebtNavLinks();
79    $(document).on('gform_confirmation_loaded', updateDebtNavLinks);
80
81    $(window).on('scroll', function() {
82        $topOffset = $(this).scrollTop();
83        // console.log($topOffset);
84    });
85
86    // For Gtranslate 3.0 header buttons 
87    function getCookie(gtransCookie) {
88        var name = gtransCookie + "=";
89        var decodedCookie = decodeURIComponent(document.cookie);
90        var cookieArray = decodedCookie.split(';');
91
92        for(var i = 0; i < cookieArray.length; i++) {
93            var cookie = cookieArray[i].trim();
94            
95            if (cookie.indexOf(name) === 0) {
96                return cookie.substring(name.length, cookie.length);
97            }
98        }
99        
100        return null; 
101    }
102    
103    // Local
104    var gtLang = getCookie('googtrans');
105    var $enBtn = $('.gt-btns__en');
106    var $esBtn = $('.gt-btns__es');
107
108    // Pro
109    var proCurrentLang = document.getElementsByTagName('html')[0].getAttribute('lang');
110
111    if ((gtLang === '/en/es') || (proCurrentLang === 'Spanish') || (proCurrentLang === 'es')) {
112        $esBtn.hide();
113        $enBtn.show();
114    } else {
115        $esBtn.show();
116        $enBtn.hide();
117    }
118
119    $enBtn.on('click', function() {
120        $enBtn.hide();
121        $esBtn.show();
122    });
123
124    $esBtn.on('click', function() {
125        $enBtn.show();
126        $esBtn.hide();
127    });
128
129    $('.toggle-bio').on('click', function(e) {
130        e.preventDefault();
131    
132        var $this = $(this); 
133        var $bioExcerpt = $this.siblings('.bio-excerpt'); 
134        var fullBio = $bioExcerpt.data('full-bio');
135        var excerpt = $bioExcerpt.data('excerpt');
136    
137        if ($this.text() === 'Full Bio') {
138            $bioExcerpt.text(fullBio);
139            $bioExcerpt.addClass('expanded');
140            $this.text('Less');
141            $this.addClass('active-bio'); 
142        } else {
143            $bioExcerpt.text(excerpt);
144            $bioExcerpt.removeClass('expanded');
145            $this.text('Full Bio');
146            $this.removeClass('active-bio'); 
147        }
148    });  
149
150});
151
152jQuery(document).ready(function($) {
153  // Initialize Fancybox for existing and dynamically added content
154  function initFancybox() {
155      if (typeof Fancybox !== 'undefined') {
156          // Bind to direct links with fancy-popup-link class
157          Fancybox.bind(".fancy-popup-link", {
158              Thumbs: false,
159              Toolbar: false,
160              closeButton: "top",
161          });
162          
163          // Also bind to links inside elements with fancy-popup-link class
164          Fancybox.bind(".fancy-popup-link a", {
165              Thumbs: false,
166              Toolbar: false,
167              closeButton: "top",
168          });
169      }
170  }
171
172  // Initialize on page load
173  initFancybox();
174
175  // Re-initialize Fancybox when new content is added (for testimonials load more)
176  $(document).on('DOMNodeInserted', function() {
177      initFancybox();
178  });
179
180  // Also trigger on custom event for when testimonials are loaded
181  $(document).on('testimonialsLoaded', function() {
182      initFancybox();
183  });
184
185  
186});

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.