PageSourceSearch

https://americanprecision.org/wp-content/themes/apm/js/index.js?ver=1.4

js americanprecision.org collected 2026-10-01 10:45:53 UTC 10,068 bytes, 313 lines download raw bytes

1
2$(document).ready(function () {
3    initMainMenu();
4    initMainSlider();
5    setPageImg();
6    initSidebar();
7    initScrollSpy();
8    initNavBar();
9    initMembership();
10    initDonateCard();
11    setActiveMenu();
12    $('form br').remove();
13    initSmoothScroll();
14    removeEmptyP();
15    initMatchHeight();
16});
17
18function initMainMenu() {
19    $('.main, .page').css('margin-top', $('nav.main-nav').height());
20    $(window).resize(function () {
21        $('.main, .page').css('margin-top', $('nav.main-nav').height());
22    });
23    $('nav .nav-1 .nav-right ul li:nth-child(n+4):nth-child(-n+5) a').addClass('border');
24    $('nav .nav-1 .nav-right ul li:last-child a').addClass('red');
25}
26
27
28function initMainSlider() {
29    let active = 2;
30    if ($('.slider').length > 0) {
31        $('.slider .slide:nth-child(2)').addClass('active');
32        var container = $('.container').width();
33        var pad = ($(window).width() - container) / 2;
34        var setWidth = function () {
35            if ($(window).width() <= 575)
36                return;
37            $('.slider').width(container * $('.slider .slide').length);
38            $('.slider .slide:first-child').css('margin-left', -(container - pad));
39            $(".slider .slide.active .bg").css('opacity', '0');
40            $(".slider .slide.active").css('height', '');
41        };
42        setWidth();
43        $(window).resize(function () {
44            setWidth();
45        });
46        $('.slider .slide .nav .next').click(function () {
47            if ($(window).width() > 575) {
48                $(".slider .slide.active .bg").css('opacity', '1');
49                $(".slider .slide.active").removeClass('active');
50                setTimeout(function () {
51                    $(".slider").animate({
52                        'margin-left': -container
53                    }, 500, function () {
54                        $('.slider .slide:first-child').css('opacity', '').css('height', '').css('margin-left', '').parent().append($('.slider .slide:first-child'));
55                        $('.slider').css('margin-left', '');
56                        $(".slider .slide:nth-child(2)").addClass('active');
57                        setWidth();
58                    });
59                }, 500);
60            } else {
61                active++;
62                if (active > 4)
63                    active = 1;
64                $(".slider .slide.active").removeClass('active');
65                $(".slider .slide:nth-child(" + active+")").addClass('active');
66            }
67        });
68        $('.slider .slide .nav .prev').click(function () {
69            if ($(window).width() > 575) {
70                $('.slider .slide:last-child').parent().prepend($('.slider .slide:last-child'));
71                $('.slider .slide:first-child').css('margin-left', -(2 * container - pad));
72                $(".slider .slide.active .bg").css('opacity', '1');
73                $(".slider .slide.active").removeClass('active');
74                setTimeout(function () {
75                    $(".slider").animate({
76                        'margin-left': container
77                    }, 500, function () {
78                        $('.slider .slide:first-child').css('opacity', '').css('height', '').css('margin-left', '');
79                        $('.slider').css('margin-left', '');
80                        $(".slider .slide:nth-child(2)").css('margin-left', '').addClass('active');
81                        setWidth();
82                    });
83                }, 500);
84            }
85            else {
86                active--;
87                if (active <= 0)
88                    active = 4;
89                $(".slider .slide.active").removeClass('active');
90                $(".slider .slide:nth-child(" + active + ")").addClass('active');
91            }
92        });
93    }
94    if ($('.section-7-l-2-content').length > 0) {
95         $('.section-7-l-2-content').slick({
96            prevArrow :'<a href="#" class="prev"></a>',
97            nextArrow: '<a href="#" class="next"></a>',
98            autoplay: true,
99            autoplaySpeed: 6000,
100            pauseOnFocus: true,
101            infinite: true
102        });
103    }
104}
105
106function setPageImg() {
107    if ($(window).width() < 992)
108        return;
109    if ($('#page-sec-4-img').length > 0) {
110        var setPageImgWidth = function () {
111            var offset = $('#page-sec-4-point').offset();
112            $('#page-sec-4-img').css('width', $(window).width() - offset.left);
113        };
114        setPageImgWidth();
115
116        $(window).resize(function () {
117            setPageImgWidth();
118        });
119    }
120
121    if ($('.section-3-btn').length > 0) {
122        var setPageImgWidth1 = function () {
123            var offset = $('.section-3-btn').offset();
124            $('.section-4-right-block .img').css('width', $(window).width() - offset.left);
125        };
126        setPageImgWidth1();
127
128        $(window).resize(function () {
129            setPageImgWidth1();
130        });
131    }
132}
133
134function initSidebar() {
135    // if there is anchor of first le element need to set it active
136    if ($('#sidebar').length > 0) {
137        var href = $('#sidebar li:first-child a').attr('href');
138        if (href !== '#' && href.indexOf('#') === 0 && $(href).length > 0)
139            $('#sidebar li:first-child').addClass('active');
140
141        if ($(window).width() < 992)
142            return;
143
144        $("#sidebar").stick_in_parent({
145            offset_top: 140
146        });
147    }
148}
149
150function initScrollSpy() {
151    if ($(window).width() < 992)
152        return;
153    $('body').scrollspy({
154        target: '#sidebar',
155        offset: 160
156    });
157    $(window).on('activate.bs.scrollspy', function (e, obj) {
158        $('#sidebar .nav-item').removeClass('active');
159        $('#sidebar .nav-item a[href="' + obj.relatedTarget + '"]').parent().addClass('active');
160    });
161
162    $('[href="#donate"]').click(function (e) {
163        e.preventDefault();
164        e.stopPropagation();
165        location.href = '/?donate_page=support-the-museum';
166    });
167    $('[href="#support"]').click(function (e) {
168        e.preventDefault();
169        e.stopPropagation();
170        location.href = '/?support_page=176';
171    });
172    $('[href="#corporate"]').click(function (e) {
173        e.preventDefault();
174        e.stopPropagation();
175        location.href = '/?corporate_giving=corporate-giving';
176    });
177    $('[href="#volonteer"]').click(function (e) {
178        e.preventDefault();
179        e.stopPropagation();
180        location.href = '/?donate_page=volunteer-opportunities';
181    });
182}
183
184function initNavBar() {
185    if ($(window).width() < 992)
186        return;
187    var checkNavBar = function () {
188        if (window.pageYOffset >= 80 && $('nav.sticky').length === 0) {
189            $('nav').addClass('sticky');
190        }
191        if (window.pageYOffset < 80 && $('nav.sticky').length > 0) {
192            $('nav.sticky').removeClass('sticky');
193        }
194    };
195    $(window).scroll(function () {
196        checkNavBar();
197    });
198    checkNavBar();
199}
200
201function initMembership() {
202    $('.membership .card a').click(function (e) {
203        e.preventDefault();
204        e.stopPropagation();
205        $('.membership .active').removeClass('active');
206        $(this).closest('.card').addClass('active');
207        let value = $(this).attr('data-value');
208        $('#form_total').val(value + ' USD');
209        $('html, body').animate({
210            scrollTop: $('form').offset().top - 160
211        }, 1100, function () {
212        });
213    });
214    $('.membership .deselect').click(function (e) {
215        $('.membership .active').removeClass('active');
216        $('#form_total').val('');
217    });
218    $('#form_amount').on('change',function(){
219        let value =$(this).val();
220        if(value!==''){
221            $('.membership .active').removeClass('active');
222            $('#form_total').val(value + ' USD');
223            $('html, body').animate({
224                scrollTop: $('form').offset().top - 160
225            }, 1100, function () {
226            });
227        }
228    })
229
230}
231
232function initDonateCard() {
233    $('.donate-card').click(function () {
234        
235        if ($('.donate-card.active')[0] !== $(this)[0]) {
236            $('.donate-card.active').removeClass('active');
237            $(this).addClass('active');
238            let value = $('p.value', this).attr('data-value');
239            $('#form_total').val(value + ' USD');
240        }
241        else {
242            $('.donate-card.active').removeClass('active');
243            $('#form_total').val('');
244        }
245    });
246}
247
248function setActiveMenu() {
249    // Get current page URL
250    var url = window.location.href;
251
252    // remove # from URL
253    url = url.substring(0, (url.indexOf("#") === -1) ? url.length : url.indexOf("#"));
254
255    // remove parameters from URL
256    url = url.substring(0, (url.indexOf("?") === -1) ? url.length : url.indexOf("?"));
257
258    // select file name
259    url = url.substr(url.lastIndexOf("/"));
260
261
262    // Loop all menu items
263    $('nav li').each(function () {
264
265        // select href
266        var href = $(this).find('a').attr('href');
267
268        // Check filename
269        if (url === href) {
270
271            // Add active class
272            $(this).addClass('active');
273        }
274    });
275}
276
277function initSmoothScroll() {
278    $(document).ready(function () {
279        if (location.hash !== "") {
280
281            var hash = location.hash;
282
283            $('html, body').animate({
284                scrollTop: $(hash).offset().top -160
285            }, 1100, function () {
286            });
287        } // End if
288        $("a[href^='#']").on('click', function (event) {
289            if (this.hash !== "") {
290                event.preventDefault();
291                event.stopPropagation();
292
293                var hash = this.hash;
294
295                $('html, body').animate({
296                    scrollTop: $(hash).offset().top -160
297                }, 1100, function () {
298                });
299            } // End if
300        });
301    })
302}
303
304function removeEmptyP() {
305    $('p:empty').remove();
306}
307
308function initMatchHeight() {
309    $('.section-2 .section-card-title').matchHeight();
310    $(window).resize(function () {
311        $('.section-2 .section-card-title').matchHeight();
312    });
313}

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.