PageSourceSearch

https://www.orix.com/wp-content/themes/orix/assets/js/reset_filters_our_people.js

js orix.com collected 2026-10-03 20:53:59 UTC 4,251 bytes, 117 lines download raw bytes

1jQuery(document).ready(function($) {
2
3    $('.page-our-people .btn_reset_filters').on('click touchend', function () {
4        $('.page-our-people .btn_reset_filters').prop('checked', true);
5    });
6    jQuery('.ct_type_filter input[type="radio"]').on('change', function () {
7        $('.page-our-people .btn_reset_filters').prop('checked', false);
8    });
9
10    // Get the current page URL
11    var current_page_url = $('form.op-filter input[name="current_page_url"]').val();
12
13    // Function to handle URL change and pushState
14    function handleUrlAndPushState(targetUrl) {
15        var initialUrl = window.location.href;
16        history.pushState(null, null, targetUrl);
17    }
18
19    // Function to check if the current URL is the "our people" page
20    function isOurPeoplePage() {
21        var pathname = window.location.pathname;
22        return pathname === '/our-people/' || pathname === '/our-people'; // Handles trailing slash and no trailing slash
23    }
24
25    // Store the previous page URL in a cookie
26    function storePreviousPage() {
27        var currentPath = window.location.pathname;
28        var previousPage = getCookie('previousPage');
29
30        // Check if current page is a subpage and previous was /our-people/
31        if (isOurPeoplePage() || currentPath.startsWith('/our-people/')) {
32            setCookie('previousPage', currentPath);
33        }
34    }
35
36    // Get a cookie value by name
37    function getCookie(name) {
38        var value = "; " + document.cookie;
39        var parts = value.split("; " + name + "=");
40        if (parts.length == 2) return parts.pop().split(";").shift();
41    }
42
43    // Set a cookie value
44    function setCookie(name, value) {
45        document.cookie = name + "=" + value + "; path=/";
46    }
47
48    // Function to check if the previous URL was a sub-page of "our people"
49    function wasPreviousPageSubPageOfOurPeople() {
50        var previousPage = getCookie('previousPage');
51        return previousPage && previousPage.startsWith('/our-people/') && previousPage !== '/our-people/' && previousPage !== '/our-people';
52    }
53
54    // Load data from "leadership" category (default selection)
55    function resetToDefault() {
56        jQuery.ajax({
57            type: "POST",
58            dataType: "json",
59            url: orix_object.ajax_url,
60            data: {
61                action: "orix_op_filter",
62                people_category: ['leadership'],
63                paged: 1,
64                page_id: 179
65            },
66            success: function (response) {
67                jQuery('div.card_people, .editor-content.not-result').remove();
68                if (response.found_posts > 0) {
69                    jQuery(".container_list").append(response.content);
70                } else {
71                    jQuery(".ct_people_list").append(response.content);
72                }
73                if (jQuery('.card_people').length) {
74                    gsap.fromTo('.card_people', {
75                        y: 40,
76                        opacity: 0,
77                    }, {
78                        y: 0,
79                        opacity: 1,
80                        duration: 1, // seconds
81                        delay: 0.4,
82                        ease: "power2.inOut",
83                        stagger: 0.1, // stagger start times
84                    });
85                }
86                jQuery('.page-our-people').removeClass('people-loading');
87
88                // Handle URL change and pushState
89                handleUrlAndPushState(current_page_url);
90                jQuery('input#leadership').prop("checked", true);
91            },
92            error: function (e) {
93                console.warn('ajax error', e);
94            }
95        });
96    }
97
98    // Function to handle the URL change and reset filters
99    function handleUrlChange() {
100        if (isOurPeoplePage() && wasPreviousPageSubPageOfOurPeople()) {
101            resetToDefault();
102        }
103    }
104
105    // Detect back button navigation
106    window.addEventListener('popstate', function(event) {
107        handleUrlChange();
108    });
109
110    // Store previous page on each AJAX call or page load
111    $(document).ajaxComplete(function() {
112        storePreviousPage();
113    });
114
115    // Also store the initial URL when the script runs
116    storePreviousPage();
117});

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.