PageSourceSearch

https://discovercaliforniawines.com/wp-content/themes/wp-discover-…/js/livefilter-initialize.js?ver=1

js discovercaliforniawines.com collected 2026-10-02 06:17:04 UTC 4,526 bytes, 128 lines download raw bytes

1/**
2 * livefilter-initialize.js
3 *
4 * Function to initialize jquery.livefilter.js on archive pages.
5 * Also handles incoming URL hashes.
6 * https://github.com/straps/jquery-livefilter/blob/master/README.md
7 */
8
9jQuery(document).ready(function($) {
10    // livefilter now handles select options also
11    // https://stackoverflow.com/questions/25720986/bootstrap-select-how-to-fire-event-on-change
12    // https://stackoverflow.com/questions/4547363/jquery-filter-by-an-attribute-value
13    // https://stackoverflow.com/questions/18951861/filter-divs-by-data-attr-containing-string
14    var filterInput = $(".filterable"),
15        filterLists = function() {
16            $(filterInput).livefilter({
17                selector: ".list-filtered .nav-item",
18                showFn: "fadeIn",
19                hideFn: "fadeOut",
20                debounce: true
21            })
22        }
23
24    $(".default-hide.list-filtered .nav-item").hide()
25
26    filterLists()
27
28    // https://stackoverflow.com/questions/11235622/jquery-disable-form-submit-on-enter#11235672
29    // $(input).submit(function(e){ e.preventDefault(); });
30    $(filterInput).on("keyup keypress", function(e) {
31        var keyCode = e.keyCode || e.which
32        if (keyCode === 13) {
33            e.preventDefault()
34            return false
35        }
36    })
37
38    // https://stackoverflow.com/questions/5646851/split-and-parse-window-location-hash/5647103
39    // WINDOW.LOCATION.HASH
40    // handle incoming URL hashes
41    var search = window.location.search,
42        hash = window.location.hash,
43        filterHash = function() {
44            if (window.location.hash) {
45                hash2Obj = window.location.hash
46                    .substr(1)
47                    .split("&")
48                    .map(el => el.split("="))
49                    .reduce((pre, cur) => {
50                        pre[cur[0]] = cur[1]
51                        return pre
52                    }, {})
53
54                // console.log( hash2Obj );
55
56                if (hash2Obj.region) {
57                    // console.log( hash2Obj.region );
58                    $(window).load(function() {
59                        $("#region_select").selectpicker("val", hash2Obj.region)
60                    })
61                }
62                if (hash2Obj.varietal) {
63                    $(window).load(function() {
64                        $("#varietal_select").selectpicker(
65                            "val",
66                            hash2Obj.varietal
67                        )
68                    })
69                }
70                if (hash2Obj.amenity) {
71                    $(window).load(function() {
72                        $("#amenity_select").selectpicker(
73                            "val",
74                            hash2Obj.amenity
75                        )
76                    })
77                }
78                if (hash2Obj.timeframe) {
79                    $(window).load(function() {
80                        $("#timeframe_select").selectpicker(
81                            "val",
82                            hash2Obj.timeframe
83                        )
84                    })
85                }
86                if (hash2Obj.feature) {
87                    $(window).load(function() {
88                        $("#feature_select").selectpicker(
89                            "val",
90                            hash2Obj.feature
91                        )
92                    })
93                }
94                if (hash2Obj.search) {
95                    $(window).load(function() {
96                        $('input.filterable[type="search"]')
97                            .val(decodeURI(hash2Obj.search))
98                            .keyup()
99                    })
100                }
101                if (hash2Obj.winery) {
102                    $(window).load(function() {
103                        $(
104                            'a.ajax-link[data-id="' + hash2Obj.winery + '"]'
105                        ).click()
106                    })
107                }
108                if (hash2Obj.event) {
109                    $(window).load(function() {
110                        $(
111                            'a.ajax-link[data-id="' + hash2Obj.event + '"]'
112                        ).click()
113                    })
114                }
115            }
116        }
117
118    filterHash()
119
120    if (
121        /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
122            navigator.userAgent
123        )
124    ) {
125        $('.selectpicker').selectpicker('destroy');
126        $(".selectpicker").selectpicker("mobile")
127    }
128})

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.