PageSourceSearch

https://www.scholarrescuefund.org/wp-content/themes/astra-child/assets/js/custom.js?ver=0.1790240386

js scholarrescuefund.org collected 2026-09-24 09:00:27 UTC 10,862 bytes, 320 lines download raw bytes

1"use strict";
2
3(function ($) {
4  $(document).ready(function () {
5    $('.elementor-pagination a.page-numbers').each(function () {
6      var old_url = $(this).attr('href');
7
8      if (old_url.indexOf('/page/') == -1) {
9        var patt = /\/(\d+)\//g;
10        var result = old_url.match(patt);
11
12        if (result != null) {
13          var result2 = '/page' + result[0];
14          var url = old_url.replace(result[0], result2);
15          $(this).attr('href', url);
16        }
17      }
18    });
19    $('.link-search a').on('click', function () {
20      var search_block = $('body');
21
22      if (search_block.length > 0 && $(window).width() > 1025) {
23        if (!$('.elementor-location-header').hasClass('header-sticky')) {
24          search_block.toggleClass('active');
25        } else {
26          if ($(this).hasClass('is-open')) {
27            $('.elementor-location-header').removeClass('sticky-search-active');
28          } else {
29            $('.elementor-location-header').addClass('sticky-search-active');
30          }
31        }
32
33        $(this).toggleClass('is-open');
34      }
35
36      return false;
37    }); // Accordion Wrapper
38
39    var accordion_wrapper = $('.accordion-wrapper');
40    var expand_link = accordion_wrapper.find('.expand-all a');
41    expand_link.on('click', function () {
42      var expand_all = $(this);
43      $('.ea-card').each(function () {
44        if (expand_all.text() == 'expand all') {
45          if (!$(this).hasClass('ea-expand')) {
46            $(this).find('.ea-header a').trigger('click');
47          }
48        } else {
49          if ($(this).hasClass('ea-expand')) {
50            $(this).find('.ea-header a').trigger('click');
51          }
52        }
53      });
54
55      if ($(this).text() == 'collapse all') {
56        $(this).text('expand all');
57      } else {
58        $(this).text('collapse all');
59      }
60
61      return false;
62    }); // Seeking Placement Slider
63
64    $('.seeking-placement-slider').slick({
65      infinite: true,
66      autoplay: true,
67      dots: true,
68      autoplaySpeed: 5000,
69      responsive: [{
70        breakpoint: 768,
71        settings: {
72          slidesToShow: 2,
73          slidesToScroll: 2
74        }
75      }, {
76        breakpoint: 480,
77        settings: {
78          slidesToShow: 1,
79          slidesToScroll: 1
80        }
81      }]
82    }); // Features Scholars Form Select
83
84    var scholar_select = $('.featured-scholars-form form select');
85
86    if (scholar_select.length > 0) {
87      scholar_select.on('change', function () {
88        $(this).closest('form').submit();
89      });
90    } // Responsive Tables
91
92    /* Credits:
93    This bit of code: Exis | exisweb.net/responsive-tables-in-wordpress
94    Original idea: Dudley Storey | codepen.io/dudleystorey/pen/Geprd */
95
96
97    var headertext = [];
98    var headers = document.querySelectorAll("thead");
99    var tablebody = document.querySelectorAll("tbody");
100
101    for (var i = 0; i < headers.length; i++) {
102      headertext[i] = [];
103
104      for (var j = 0, headrow; headrow = headers[i].rows[0].cells[j]; j++) {
105        var current = headrow;
106        headertext[i].push(current.textContent);
107      }
108    }
109
110    for (var h = 0, tbody; tbody = tablebody[h]; h++) {
111      for (var i = 0, row; row = tbody.rows[i]; i++) {
112        for (var j = 0, col; col = row.cells[j]; j++) {
113          if (headertext[h] !== undefined && headertext[h][j] !== undefined) {
114            col.setAttribute("data-th", headertext[h][j]);
115          }
116        }
117      }
118    } // Header Sticky Old
119
120    /* if ($(window).width() > 1025 && $('.elementor-location-header').length > 0) {
121      var pageHeaderHeight = $('.elementor-location-header').height();
122      var headerPlaceholder = $('.header-placeholder');
123      $('.header-placeholder').css('height' + 'px');
124        var stickyNavHeader = function stickyNavHeader() {
125        var scrollTop = $(window).scrollTop();
126          if (scrollTop > pageHeaderHeight) {
127          headerPlaceholder.css('display', 'block');
128          $('.elementor-location-header').addClass('header-sticky');
129          $('.elementor-location-header').addClass('slide-down');
130        } else {
131          headerPlaceholder.css('display', 'none');
132          $('.elementor-location-header').removeClass('header-sticky');
133          $('.elementor-location-header').removeClass('slide-down');
134        }
135      };
136        stickyNavHeader();
137      $(window).scroll(function () {
138        stickyNavHeader();
139      });
140    } */
141    // New Header sticky
142
143
144    $(window).scroll(function () {
145      if ($(window).scrollTop() > 100) {
146        $('.main-menu-wrapper').addClass('custom-header-sticky');
147      } else {
148        $('.main-menu-wrapper').removeClass('custom-header-sticky');
149      }
150    });
151
152    // Add aria-label to search button for accessibility
153    function addSearchButtonAriaLabel() {
154      $('button.wpr_submit').attr('aria-label', 'Search');
155    }
156    
157    // Populate search form label for accessibility
158    function populateSearchLabel() {
159      $('.wpr-search-form label').each(function() {
160        var $label = $(this);
161        // Only populate if label is empty
162        if ($label.text().trim() === '') {
163          $label.text('Search for:');
164        }
165      });
166    }
167    
168    // Add aria-label immediately if button exists
169    addSearchButtonAriaLabel();
170    // Populate label immediately if form exists
171    populateSearchLabel();
172    
173    // Also add when menu opens (for dynamically loaded content)
174    $(document).on('click', '#wprmenu_bar, .wprmenu_bar', function() {
175      setTimeout(function() {
176        addSearchButtonAriaLabel();
177        populateSearchLabel();
178      }, 100);
179    });
180    
181    // Use MutationObserver to catch dynamically added buttons and labels
182    if (typeof MutationObserver !== 'undefined') {
183      var observer = new MutationObserver(function(mutations) {
184        addSearchButtonAriaLabel();
185        populateSearchLabel();
186      });
187      
188      observer.observe(document.body, {
189        childList: true,
190        subtree: true
191      });
192    }
193    
194    // Add href attributes to anchor tags that don't have them (for accessibility)
195    function addHrefToAnchors() {
196      // Find all anchor tags without href attributes, especially in menus
197      $('a:not([href]), a[href=""], a[href="#"]').each(function() {
198        var $anchor = $(this);
199        var $parentLi = $anchor.closest('li');
200        
201        // Skip if already has a valid href (except empty or #)
202        if ($anchor.attr('href') && $anchor.attr('href') !== '#' && $anchor.attr('href') !== '') {
203          return;
204        }
205        
206        // Check if it's a menu item with children (submenu parent)
207        if ($parentLi.hasClass('menu-item-has-children') || $anchor.hasClass('has-submenu')) {
208          // For parent items with submenus, use # as href
209          if (!$anchor.attr('href') || $anchor.attr('href') === '') {
210            $anchor.attr('href', '#');
211          }
212        } else {
213          // For other items, try to find a URL from the menu item data or use home URL
214          var menuItemUrl = $parentLi.data('url') || $anchor.data('url');
215          if (menuItemUrl) {
216            $anchor.attr('href', menuItemUrl);
217          } else {
218            // Fallback to home URL
219            $anchor.attr('href', '/');
220          }
221        }
222      });
223      
224      // Also check for Elementor menu items specifically
225      $('.elementor-sub-item, .elementor-item').each(function() {
226        var $anchor = $(this);
227        if (!$anchor.attr('href') || $anchor.attr('href') === '') {
228          var $parentLi = $anchor.closest('li.menu-item');
229          if ($parentLi.length) {
230            var menuItemUrl = null;
231            
232            // Try multiple methods to find the URL
233            // 1. Check if parent li has a data attribute
234            menuItemUrl = $parentLi.data('url') || $parentLi.attr('data-url');
235            
236            // 2. Check if there's another anchor in the same li with a valid href
237            if (!menuItemUrl) {
238              var $otherLink = $parentLi.find('a[href]').not($anchor).first();
239              if ($otherLink.length && $otherLink.attr('href') && $otherLink.attr('href') !== '#' && $otherLink.attr('href') !== '') {
240                menuItemUrl = $otherLink.attr('href');
241              }
242            }
243            
244            // 3. Check if the menu item has a class that might indicate a URL (WordPress menu items sometimes have IDs)
245            if (!menuItemUrl && $parentLi.attr('id')) {
246              var menuItemId = $parentLi.attr('id').replace('menu-item-', '');
247              // Try to find a link by looking at WordPress menu structure
248              var $wpMenuLink = $parentLi.find('a').first();
249              if ($wpMenuLink.length && $wpMenuLink.attr('href') && $wpMenuLink.attr('href') !== '#' && $wpMenuLink.attr('href') !== '') {
250                menuItemUrl = $wpMenuLink.attr('href');
251              }
252            }
253            
254            // Apply the URL or fallback
255            if (menuItemUrl) {
256              $anchor.attr('href', menuItemUrl);
257            } else if ($parentLi.hasClass('menu-item-has-children') || $anchor.hasClass('has-submenu')) {
258              $anchor.attr('href', '#');
259            } else {
260              $anchor.attr('href', '/');
261            }
262          } else {
263            // If not in a menu item, check if it has submenu class
264            if ($anchor.hasClass('has-submenu')) {
265              $anchor.attr('href', '#');
266            } else {
267              $anchor.attr('href', '/');
268            }
269          }
270        }
271      });
272    }
273    
274    // Run immediately
275    addHrefToAnchors();
276    
277    // Also run after a short delay to catch dynamically loaded content
278    setTimeout(addHrefToAnchors, 500);
279    setTimeout(addHrefToAnchors, 1000);
280    
281    // Use MutationObserver to catch dynamically added menu items
282    if (typeof MutationObserver !== 'undefined') {
283      var menuObserver = new MutationObserver(function(mutations) {
284        addHrefToAnchors();
285      });
286      
287      menuObserver.observe(document.body, {
288        childList: true,
289        subtree: true,
290        attributes: true,
291        attributeFilter: ['class']
292      });
293    }
294  });
295})(jQuery);
296"use strict";
297
298/* Credits:
299	This bit of code: Exis | exisweb.net/responsive-tables-in-wordpress
300	Original idea: Dudley Storey | codepen.io/dudleystorey/pen/Geprd */
301var headertext = [];
302var headers = document.querySelectorAll("thead");
303var tablebody = document.querySelectorAll("tbody");
304
305for (var i = 0; i < headers.length; i++) {
306  headertext[i] = [];
307
308  for (var j = 0, headrow; headrow = headers[i].rows[0].cells[j]; j++) {
309    var current = headrow;
310    headertext[i].push(current.textContent);
311  }
312}
313
314for (var h = 0, tbody; tbody = tablebody[h]; h++) {
315  for (var i = 0, row; row = tbody.rows[i]; i++) {
316    for (var j = 0, col; col = row.cells[j]; j++) {
317      col.setAttribute("data-th", headertext[h][j]);
318    }
319  }
320}

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.