PageSourceSearch

https://www.sonoma.com/wp-content/themes/napavalley/js/functions.js

js sonoma.com collected 2026-10-02 03:43:00 UTC 4,874 bytes, 173 lines download raw bytes

1;
2(function ($, window, document, undefined) {
3    var $win = $(window);
4    var $doc = $(document);
5    var $classes = {
6        FsrHolder: 'fsr-holder',
7        FsrImage: 'image-full',
8        Open: 'open',
9        ShowSearch: 'show-search',
10        Hide: 'hide-item',
11        ShowNav: 'show-nav',
12        ShowFilters: 'show-filters'
13    }
14    var $isotopeListCallout, $body;
15
16    $doc.ready(function () {
17
18        $body = $('body');
19        $isotopeListCallout = $('.list-callout');
20
21        $('.btn-search, .form-search .btn-close').on('click', function (event) {
22            event.preventDefault();
23
24            $body.toggleClass($classes.ShowSearch);
25
26            // Doesn't have any effect, see http://stackoverflow.com/questions/17384464/jquery-focus-not-working-in-chrome
27//            setTimeout(function () {
28//                $("#s").focus();
29//            }, 1);
30//
31//            //$(this).focus();
32        });
33
34
35        fullscreener($('.' + $classes.FsrImage));
36    });
37
38    $win.on('load', function () {
39
40        setMinHeights();
41
42        if (typeof Packery == "function")
43        {
44            $('.list-callout').packery({
45                itemSelector: '.list-grid',
46                gutter: 0,
47                columnWidth: ".grid-sizer",
48                percentPosition: true
49            });
50        }
51    });
52
53    $win.on('resize orientationchange', function () {
54        setMinHeights();
55    });
56
57    function setMinHeights()
58    {
59        minHeight($('div.widgets-content-secondary'));
60        minHeight($('.article-map .article-body p:first-child'));
61
62        // WineCountry specific
63        minHeight($('.seventytwo-hours-bonus > div'));
64    }
65
66    function fullscreener(_container) {
67        _container.each(function () {
68            var _this = $(this);
69            //debugger;
70            var _src = _this.attr('src');
71            var _srcset = _this.attr('srcset');
72            if (_srcset != null)
73            {
74                var screenWidth = $(window).width();
75                var src_arr = _parse_srcset(_srcset);
76                for (i in src_arr)
77                {
78                    if (src_arr[i].width >= screenWidth)
79                    {
80                        _src = src_arr[i].url;
81                        break;
82                    }
83                }
84            }
85            _this.parent().addClass($classes.FsrHolder).attr('style', 'background-image: url(' + _src + ');');
86        });
87    }
88
89    /**
90     * parse_srcset - A much simplified version of https://github.com/albell/parse-srcset
91     *
92     * @param string str
93     * @returns array of objects of the form {url: $url, width: $width}, sorted in order of increasing width
94     */
95    function _parse_srcset(str)
96    {
97        var arr = str.split(', ')
98        var srcset = new Array();
99        for (var i in arr)
100        {
101            var tokens = arr[i].split(' ');
102            var url = tokens[0];
103            var w = tokens[1].replace('w', '');
104            srcset.push({url: url, width: w});
105        }
106
107        srcset.sort(function (a, b) {
108            return parseFloat(a.w) - parseFloat(b.w);
109        });
110        return srcset;
111    }
112
113    function minHeight(_container) {
114
115        if (_container.length) {
116            var _max = 0;
117
118            _container.removeAttr('style');
119
120            _container.each(function () {
121                if (_max < $(this).height()) {
122                    _max = $(this).height();
123                }
124            });
125
126            _container.css('min-height', _max);
127        }
128    }
129
130})(jQuery, window, document);
131
132/* TypeKit */
133(function (d) {
134    var config = {
135        kitId: document.location.host.match(/winecountry/) ? 'muo6vkq' : 'pyq8jqg',
136        scriptTimeout: 3000,
137        async: true
138    },
139            h = d.documentElement, t = setTimeout(function () {
140                h.className = h.className.replace(/\bwf-loading\b/g, "") + " wf-inactive";
141            }, config.scriptTimeout), tk = d.createElement("script"), f = false, s = d.getElementsByTagName("script")[0], a;
142    h.className += " wf-loading";
143    tk.src = 'https://use.typekit.net/' + config.kitId + '.js';
144    tk.async = true;
145    tk.onload = tk.onreadystatechange = function () {
146        a = this.readyState;
147        if (f || a && a != "complete" && a != "loaded")
148            return;
149        f = true;
150        clearTimeout(t);
151        try {
152            Typekit.load(config)
153        } catch (e) {
154        }
155    };
156    s.parentNode.insertBefore(tk, s)
157
158})(document);
159
160/* Smooth scroll to anchor link with offset for heater */
161
162(function($) {
163  $(function() {
164    $(document).on('click', "a.anchorScroll", function(e) {
165      e.preventDefault();
166      var offset = $('header').innerHeight() + 30;
167      var target = this.hash;
168      $('html, body').stop().animate({
169        'scrollTop': $(target).offset().top - offset
170      }, 500);
171    });
172  });
173})(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.