PageSourceSearch

https://www.fathersuplift.org/wp-content/themes/jrd-fathers-uplift/ui/js/jquery.init.js?ver=1623262663

js fathersuplift.org collected 2026-10-02 10:25:42 UTC 6,953 bytes, 210 lines download raw bytes

1// jshint esversion: 6
2/* ========================================================================= */
3/* BE SURE TO COMMENT CODE/IDENTIFY PER PLUGIN CALL */
4/* ========================================================================= */
5
6jQuery(function($){
7
8	// Alert
9	if(Cookies.get('alert_cookie') != 'hide'){
10		$('#alert').css('display','flex');
11	}
12	$('#alert .close').on('click',function(e){
13		e.preventDefault();
14		$('#alert').slideUp(100);
15		Cookies.set('alert_cookie', 'hide', { expires: 1, path: '/' });
16	    return false;
17    });
18
19    // UNRUNT
20    $.fn.unrunt = function(){
21        $(this).each(function(){
22            let txt = $(this).html().trim().replace(' ',' ');
23            let wordArray = txt.split(" ");
24            if (wordArray.length > 1) {
25                wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1];
26                wordArray.pop();
27                $(this).html(wordArray.join(" "));
28            }
29        });
30    };
31    $('.orphan, .gchoice label').unrunt();
32
33    // PARALLAX
34    $.fn.plax = function(x, y){
35        this.css({
36            'webkitTransform' : 'translate3d('+x+'px, '+y+'px, 0)',
37            'MozTransform'    : 'translate3d('+x+'px, '+y+'px, 0)',
38            'msTransform'     : 'translateX('+x+'px) translateY('+y+'px)',
39            'OTransform'      : 'translate3d('+x+'px, '+y+'px, 0)',
40            'transform'       : 'translate3d('+x+'px, '+y+'px, 0)'
41        });
42    };
43
44    $('.menu-toggle').on('click', function(){
45        $('#slide-out').toggleClass('open');
46        $('#menu-closed, #search-desktop, #donate-desktop').toggleClass('hide');
47    });
48
49    $('.search-toggle').on('click',function(){
50        var input = $(this).prev('input').val();
51        if ( input == '') {
52            $(this).parent('#search-desktop').toggleClass('open');
53            $(this).prev('input').focus();
54            return false;
55        }
56    });
57
58    new Swiper('#fatherhood-slider', {
59        direction: 'vertical',
60        slidesPerView: 4,
61        loop: true,
62        autoplay: {
63            delay: 2000,
64            disableOnInteraction: false,
65        },
66    });
67
68    function appendMoreSvg(){
69        $('a.more').each( function() {
70            if ( ! $(this).children('svg').length ) {
71                $(this).append($('<svg width="6" height="9" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-2)" fill="none" fill-rule="evenodd"><path d="M2.28.203a.692.692 0 01.914-.058l.065.058 3.785 3.785c.25.25.269.642.057.914l-.057.065-3.785 3.785a.692.692 0 01-1.037-.914l.058-.065 3.295-3.296L2.28 1.182a.692.692 0 01-.058-.914L2.28.203z"/></g></svg>'));
72            }
73        });
74    }
75    appendMoreSvg();
76
77    $('form.ajax-filters').on('submit', function(){
78        var url = $(this).attr('action');
79        var queryString = makeQueryString(this);
80        fetchAjax( url + queryString );
81        return false;
82    });
83
84    $('select#category').on('change', function(){
85        if ( ! $(this).parents('form.ajax-filters').length ) {
86            var url = $(this).parent('.select-menu').data('url'),
87                val = $(this).val();
88            if ( val != 'all' ) {
89                url += '?category=' + val;
90            }
91            window.location.href = url;
92        }
93    });
94
95
96
97    // INFINITE SCROLL
98    $.fn.isOnScreen = function(x, y){
99        if(y == null || typeof y == 'undefined') y = 1;
100        var win = $(window);
101        var viewport = {
102            top : win.scrollTop()
103        };
104        viewport.bottom = viewport.top + win.height();
105        var height = this.outerHeight();
106        if(!height){
107            return false;
108        }
109        var bounds = this.offset();
110        bounds.bottom = bounds.top + height;
111        var visible = (!(viewport.bottom < bounds.top || viewport.top > bounds.bottom));
112        if(!visible){
113            return false;
114        }
115        var deltas = {
116            top : Math.min( 1, ( bounds.bottom - viewport.top ) / height),
117            bottom : Math.min(1, ( viewport.bottom - bounds.top ) / height),
118        };
119        return (deltas.top * deltas.bottom) >= y;
120    };
121
122    // trigger a button click
123    $aCount = 0;
124    $('.loading').hide(); // hide loader animation
125    $(document).on('scroll ready', function(){
126        if($('.load-more a').isOnScreen() === true){
127            if($aCount == 0){
128                $('.load-more a').trigger('click');
129            }
130            $aCount += 1;
131        }
132    });
133
134    $('.load-more a').on('click', function(e)  {
135        $('.loading').show(); // show loader animation
136        e.preventDefault();
137        var link = $(this).attr('href');
138        var content = '.ajax-content';
139        var anchor = '.load-more a';
140        var next_href = $(anchor).attr('href'); // Get URL for the next set of posts
141
142        $.post(link+'', function(data){
143            var $elements = $('<div>').append(data);
144            var $new_content = $elements.find(content).wrapInner('').html(); // Grab just the content
145            next_href = $elements.find(anchor).attr('href'); // Get the new href
146            $(content + ' .ajax-item:last-child').after($new_content); // Append the new content
147            $(anchor).attr('href', next_href); // Change the next URL
148            var nlink = $(anchor).attr('href');
149            if(nlink == link){ $(anchor).remove(); }
150
151        }).done(function(){
152            $aCount = 0;
153            $('.loading').hide(); //hide loader animation
154        });
155    });
156
157
158    /*
159    $(document).scroll(function(){
160        var nm = $("html").scrollTop();
161        var nw = $("body").scrollTop();
162        var n = (nm > nw ? nm : nw);
163
164        $('#element').plax(0,n);
165
166        // if transform3d isn't available, use top over background-position
167        //$('#element').css('top', Math.ceil(n/2) + 'px');
168
169    });
170    */
171
172});
173
174function focusIt(){ document.getElementById("jumptocontent").focus(); }
175
176function fetchAjax( url ) {
177    console.log(url);
178    history.pushState( '', document.title, url );
179    var $content = '.ajax-content';
180    $($content).animate({
181        'opacity': 0.3,
182    },150);
183    $.post(url+'', function(data){
184        var $elements = $('<div>').append(data);
185        var $new_content = $elements.find($content).wrapInner('').html(); // Grab just the content
186        $($content).html($new_content); // Append the new content
187    }).done(function(){
188        $($content).animate({
189            'opacity': 1,
190        },150);
191    });
192}
193
194function makeQueryString(element) {
195    var filVal = '';
196    var returns = [];
197    filVal = $(element).serializeArray();
198    for (var i = 0; i < filVal.length; i++) {
199        if (filVal[i].value != '') {
200            returns.push(filVal[i]);
201        }
202    }
203    returns = '?' + jQuery.param(returns, true);
204    returns = returns.replace(/[?&\/]+$/, ''); // strip trailing ?, &, or /
205    return returns;
206}
207
208function refreshCSS(){
209    jQuery('link#style-css').attr('href', $('link#style-css').attr('href') + 'a' );
210}

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.