PageSourceSearch

https://www.jamesbay.com/wp-content/plugins/umg-grand-royal-theme-…/js/shortcodes/locale/locale.js?ver=3.5.8

js jamesbay.com collected 2026-09-25 18:42:41 UTC 3,484 bytes, 88 lines download raw bytes

1(function ($) {
2
3    $(document).ready(function () {
4        UMGGR_Locale.init()
5    });
6
7    const UMGGR_Locale = {
8        LOCALE_TERRITORY_KEY: 'umggr-locale-territory',
9
10        init: function () {
11            UMGGR_Locale.setStoredTerritory()
12
13            $('[data-locale-territory]').click(function (e) {
14                e.preventDefault()
15                const selectedTerritory = $(this).attr('data-locale-territory')
16                UMGGR_Locale.setTerritory(selectedTerritory)
17                $.fancybox.close()
18            })
19
20            $('.umggr-locale-switch').fancybox()
21        },
22
23        setTerritory: function(territory) {
24            if (typeof localStorage !== 'undefined') {
25                localStorage.setItem(UMGGR_Locale.LOCALE_TERRITORY_KEY, territory)
26
27                const territoryIcon = $('[data-locale-switch]')
28
29                if (territoryIcon.length) {
30                    const currentTerritory = $(territoryIcon).attr('data-territory')
31
32                    $(territoryIcon).find('.flag-icon')
33                        .removeClass(`flag-icon-${currentTerritory}`)
34                        .addClass(`flag-icon-${territory}`)
35                    $(territoryIcon)
36                        .attr('data-territory', territory)
37
38                    var event = new CustomEvent('umggr-locale-territory-changed', {detail: territory})
39                    document.dispatchEvent(event)
40
41                    // Workaround to change territory for store in Tiles when store section opened in an iframe
42                    if (typeof window.UMGGRTiles !== "undefined") {
43                        var $iframe = $('.fancybox-iframe')
44                        if ($iframe.length) {
45                            var url = new URL($iframe.attr('src'))
46                            url.searchParams.set('forceVisitorCountry', territory)
47                            $iframe.attr('src', url.toString())
48                        }
49                    }
50                }
51
52                var territoryLink = $(`.umggr-locale-form [data-locale-territory="${territory}"]`)
53                if (territoryLink.length) {
54                    $(territoryLink)
55                        .parents('ul')
56                        .find('li')
57                        .removeClass('-is-active')
58                    $(territoryLink)
59                        .parents('li')
60                        .addClass('-is-active')
61                }
62            }
63        },
64
65        setStoredTerritory: function() {
66            if (typeof localStorage !== 'undefined') {
67                const storedTerritory = UMGGR_Locale.getTerritoryOverride() || localStorage.getItem(UMGGR_Locale.LOCALE_TERRITORY_KEY)
68                if (storedTerritory) {
69                    UMGGR_Locale.setTerritory(storedTerritory)
70                } else if (PUSH_GLOBAL.geo_ip_country) {
71                    UMGGR_Locale.setTerritory(PUSH_GLOBAL.geo_ip_country.toLocaleLowerCase())
72                }
73            }
74        },
75
76        getTerritoryOverride: function() {
77            const urlParams = new URLSearchParams(window.location.search)
78            if (urlParams && urlParams.get('forceVisitorCountry')) {
79                if (urlParams.get('forceVisitorCountry') === 'default') {
80                    return UMGGR_Locale_Settings.defaultTerritory.toLowerCase()
81                }
82                return urlParams.get('forceVisitorCountry').toLowerCase()
83            }
84            return false
85        },
86    }
87
88})(jQuery);

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.