PageSourceSearch

https://wealthwriteup.com/wp-content/themes/wealth-write-up-child/js/custom.js?ver=1.5.0.1730991246

js wealthwriteup.com collected 2026-10-05 18:59:54 UTC 13,442 bytes, 383 lines download raw bytes

1$ = jQuery;
2
3// Always start at top so nav height is in full state for false-header-height calculation
4if (history.scrollRestoration) {
5    history.scrollRestoration = 'manual';
6}
7window.scrollTo(0, 0);
8
9$(document).ready(function () {
10
11    var $body = $('body');
12    var isHomePage = $body.hasClass('home') || $body.data('template') === 'template-home';
13
14
15    function updateNavState(scrollY, animate) {
16        var $nav = $('#wrapper-navbar');
17        if (!animate) {
18            $nav.addClass('no-transition');
19            $body.addClass('no-transition');
20        }
21        if (scrollY > 30) {
22            $nav.addClass('solid');
23            $body.addClass('nav-scrolled');
24            if (isHomePage) $body.removeClass('home-at-top');
25        } else {
26            $nav.removeClass('solid');
27            $body.removeClass('nav-scrolled');
28            if (isHomePage) $body.addClass('home-at-top');
29        }
30        if (!animate) {
31            $nav[0].offsetHeight;
32            $nav.removeClass('no-transition');
33            $body.removeClass('no-transition');
34        }
35    }
36
37    // Run immediately on load so there's no flash
38    updateNavState($(window).scrollTop(), false);
39
40    $(window).scroll(function(event){
41        $scrolledPx = $(this).scrollTop();
42        updateNavState($scrolledPx, true);
43
44    });
45    
46    $('#openDrawer').on('click', function(e){
47        e.preventDefault();
48        $('#drawer').fadeIn(100);
49    })
50    $('#closeDrawer').on('click', function(e){
51        e.preventDefault();
52        $('#drawer').fadeOut(100);
53    })
54    
55    $('.scroll').click(function(e){
56        e.preventDefault();
57        var elementClicked= $(this).attr("href");
58        var destination = $(elementClicked).offset().top - 150;
59        $("html:not(:animated), body:not(:animated)").animate({
60                "scrollTop" : destination
61            }, 600);
62    });
63    
64//     $('.reasons-slider').flickity({
65//         imagesLoaded: true,
66//         prevNextButtons: false,
67//         draggable: true,
68//         wrapAround: false,
69//         prevNextButtons: false,
70//         pageDots: false,
71//         cellAlign: 'center',
72// //        initialIndex: 0,
73//         autoPlay: true
74//     });
75    
76    var $trustedSlider = $('.trusted-slider').flickity({
77        imagesLoaded: true,
78        prevNextButtons: false,
79        draggable: true,
80        wrapAround: true,
81        cellAlign: 'center',
82        prevNextButtons: false,
83        pageDots: false,
84//        contain: true,
85        autoPlay: 1400
86    });
87    
88    
89    // Tooltip auto-cycle handled below
90    
91    
92//     var $testimonialSlider = $('.testimonial-slider').flickity({
93//         imagesLoaded: true,
94//         prevNextButtons: false,
95//         draggable: true,
96//         // wrapAround: true,
97//         infinite: true,
98//         cellAlign: 'left',
99//         prevNextButtons: false,
100//         pageDots: false,
101// //        contain: true,
102//         autoPlay: false
103//     });
104
105    
106    // $('.testimonial-prev').on( 'click', function() {
107    //   $testimonialSlider.flickity('previous');
108    // });
109    // // next
110    // $('.testimonial-next').on( 'click', function() {
111    //   $testimonialSlider.flickity('next');
112    // });
113    
114    
115    $(".set > a").on("click", function(e) {
116          e.preventDefault();
117        if ($(this).hasClass("active")) {
118          $(this).removeClass("active");
119          $(this)
120            .siblings(".content")
121            .slideUp(150);
122          $(".set > a i.minus").hide();
123          $(".set > a i.plus").show();
124        } else {
125          $(".set > a i.minus").hide();
126          $(".set > a i.plus").show();
127          $(this)
128            .find("i.plus").hide();
129        $(this)
130            .find("i.minus").show();
131          $(".set > a").removeClass("active");
132          $(this).addClass("active");
133          $(".content").slideUp(150);
134          $(this)
135            .siblings(".content")
136            .slideDown(150);
137        }
138      });
139
140
141      
142      //  //faq block - reporting page    
143        $(document).on('click', '.new_repeater .inline', function () {      
144          if ($(this).hasClass("current")) {
145            $(this).removeClass("current");
146            $(this).parent().find(".answer").slideUp();
147          } else {
148            $(this).addClass("current");
149            $(this).parent().find(".answer").slideDown();
150          }
151        });
152        $('.new_repeater .inline').trigger('click');
153    // //faq block - reporting page
154    
155    // Announcement bar slider
156    var $annBars = $('.announcement-bar');
157    var $sec1    = $('.home_pg.sec_1');
158    var $falseHeaderEls = $('.false-header-height');
159
160    function updateSec1Padding() {
161        if (!$sec1.length) return;
162        if (window.innerWidth <= 1200) {
163            var headerHeight = $('.wrapper-nav-under-lg').outerHeight() || 0;
164            $sec1.css('padding-top', headerHeight + 'px');
165        } else {
166            $sec1.css('padding-top', '');
167        }
168    }
169
170    function updateFalseHeaderHeight() {
171        if (!$falseHeaderEls.length) return;
172        var headerHeight = window.innerWidth >= 1200
173            ? $('#wrapper-navbar').outerHeight() || 0
174            : $('.wrapper-nav-under-lg').outerHeight() || 0;
175        $falseHeaderEls.css('padding-top', headerHeight + 'px');
176    }
177
178    if ($annBars.length) {
179        if (sessionStorage.getItem('announcementDismissed') === '1') {
180            $annBars.hide();
181        } else {
182            var annSlides   = $annBars.first().find('.announcement-bar__slide');
183            var annReal     = annSlides.length;
184            var annStyles   = annSlides.map(function () {
185                return $(this).attr('data-style') === 'orange' ? 'orange' : 'light';
186            }).get();
187            var annInterval = parseInt($annBars.first().data('interval'), 10) || 2000;
188            var annTimer    = null;
189            var annPaused   = false;
190            var annTrackPos = 1;        // position in cloned track (1 = real first slide)
191            var annCurrent  = 0;        // real slide index (0-based)
192            var annBusy     = false;    // debounce during transition
193
194            function annApplyStyle(i) {
195                var isOrange = annStyles[i] === 'orange';
196                $annBars.toggleClass('announcement-bar--orange', isOrange);
197                $annBars.toggleClass('announcement-bar--light', !isOrange);
198            }
199
200            if (annReal > 1) {
201                // Clone last slide before start, first slide after end → seamless loop in both directions
202                // Track layout: [clone-last][slide0][slide1]...[slideN-1][clone-first]
203                $('.announcement-bar__track').each(function () {
204                    var $s = $(this).find('.announcement-bar__slide');
205                    $s.last().clone().addClass('ann-clone').prependTo($(this));
206                    $s.first().clone().addClass('ann-clone').appendTo($(this));
207                });
208
209                function annSetPos(pos, animate) {
210                    var $tracks = $('.announcement-bar__track');
211                    if (!animate) {
212                        $tracks.css('transition', 'none');
213                        $tracks[0] && $tracks[0].getBoundingClientRect(); // force reflow
214                    } else {
215                        $tracks.css('transition', '');
216                    }
217                    $tracks.css('transform', 'translateX(-' + (pos * 100) + '%)');
218                    annTrackPos = pos;
219                }
220
221                function annStep(dir) {
222                    if (annBusy) return;
223                    annBusy = true;
224                    annTrackPos += dir;
225                    annCurrent = ((annCurrent + dir) % annReal + annReal) % annReal;
226                    annApplyStyle(annCurrent);
227                    annSetPos(annTrackPos, true);
228                }
229
230                // After each animated transition, silently jump if we landed on a clone
231                $(document).on('transitionend', '.announcement-bar__track', function (e) {
232                    if (e.originalEvent.propertyName !== 'transform') return;
233                    if (annTrackPos >= annReal + 1) {
234                        annSetPos(1, false);          // clone-first → real first
235                    } else if (annTrackPos <= 0) {
236                        annSetPos(annReal, false);    // clone-last → real last
237                    }
238                    annBusy = false;
239                });
240
241                // Start at real first slide (track position 1, no animation)
242                annSetPos(1, false);
243
244                function annStartTimer() {
245                    annTimer = setInterval(function () {
246                        if (!annPaused) annStep(1);
247                    }, annInterval);
248                }
249                function annStopTimer() { clearInterval(annTimer); }
250
251                annStartTimer();
252
253                $annBars.on('mouseenter', function () { annPaused = true; });
254                $annBars.on('mouseleave', function () { annPaused = false; });
255
256                $(document).on('click', '.announcement-bar__prev', function () {
257                    annStep(-1); annStopTimer(); annStartTimer();
258                });
259                $(document).on('click', '.announcement-bar__next', function () {
260                    annStep(1); annStopTimer(); annStartTimer();
261                });
262
263                var annTouchX = 0;
264                var annTouchY = 0;
265                $annBars.each(function () {
266                    this.addEventListener('touchstart', function (e) {
267                        annTouchX = e.touches[0].clientX;
268                        annTouchY = e.touches[0].clientY;
269                        annPaused = true;
270                    }, { passive: true });
271                    this.addEventListener('touchend', function (e) {
272                        var dx = e.changedTouches[0].clientX - annTouchX;
273                        var dy = e.changedTouches[0].clientY - annTouchY;
274                        if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) {
275                            annStep(dx < 0 ? 1 : -1);
276                            annStopTimer(); annStartTimer();
277                        }
278                        annPaused = false;
279                    }, { passive: true });
280                });
281
282                $(document).on('click', '.announcement-bar__close', function () {
283                    $annBars.hide();
284                    sessionStorage.setItem('announcementDismissed', '1');
285                    annStopTimer();
286                    updateSec1Padding();
287                    updateFalseHeaderHeight();
288                });
289
290            } else {
291                $(document).on('click', '.announcement-bar__close', function () {
292                    $annBars.hide();
293                    sessionStorage.setItem('announcementDismissed', '1');
294                    updateSec1Padding();
295                    updateFalseHeaderHeight();
296                });
297            }
298        }
299    }
300
301    $(window).on('load', function () {
302        updateSec1Padding();
303        updateFalseHeaderHeight();
304    });
305    $(window).on('resize', function () {
306        updateSec1Padding();
307        updateFalseHeaderHeight();
308    });
309
310    $(document).on('wwu:textSizeChanged', function () {
311        setTimeout(function () {
312            updateSec1Padding();
313            updateFalseHeaderHeight();
314        }, 50);
315    });
316
317    // Reveal page — all adjustments are done, remove loading class to trigger CSS fade-in
318    document.documentElement.classList.remove('page-loading');
319
320    // Sec 8 tooltip auto-cycle
321    (function () {
322        var section = document.querySelector('.sec_8');
323        var chunks  = document.querySelectorAll('.sec_8 .tool-tip-chunk');
324        if (!section || !chunks.length) return;
325
326        // Clear any inline display:none set by old jQuery so CSS transitions work
327        chunks.forEach(function (c) {
328            var hc = c.querySelector('.hidden-chunk');
329            if (hc) hc.style.display = '';
330        });
331
332        var current = 0;
333        var timer   = null;
334        var DELAY   = 3500;
335
336        function activate(index) {
337            chunks.forEach(function (c) { c.classList.remove('active'); });
338            chunks[index].classList.add('active');
339            current = index;
340        }
341
342        function startCycle() {
343            if (timer) return;
344            timer = setInterval(function () {
345                activate((current + 1) % chunks.length);
346            }, DELAY);
347        }
348
349        function stopCycle() {
350            clearInterval(timer);
351            timer = null;
352        }
353
354        function resetCycle() {
355            stopCycle();
356            startCycle();
357        }
358
359        // Click handler — jump to tooltip and reset timer
360        chunks.forEach(function (chunk, i) {
361            chunk.querySelector('.tooltip-num').addEventListener('click', function () {
362                activate(i);
363                resetCycle();
364            });
365        });
366
367        // Only run while section is in viewport
368        var observer = new IntersectionObserver(function (entries) {
369            entries.forEach(function (entry) {
370                if (entry.isIntersecting) {
371                    activate(0);
372                    startCycle();
373                } else {
374                    stopCycle();
375                }
376            });
377        }, { threshold: 0.2 });
378
379        observer.observe(section);
380    })();
381
382})//end doc ready
383

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.