PageSourceSearch

https://weinguide.at/sites/wein/modules/custom/wein_blocks/js/wein_blocks.js?tmhb94

js weinguide.at collected 2026-10-06 17:49:06 UTC 4,848 bytes, 99 lines download raw bytes

1/**
2 * @file
3 * Main js file for wein_blocks module.
4 */
5(function ($, Drupal) {
6    Drupal.behaviors.wein_blocks = {
7        attach: function (context, settings) {
8            hide_unrelated_filters(0);
9            var homeSearchForm = '#homepage-search-form ';
10            var toplistForm = '#toplist-filter ';
11            // Default, disable the search button from homepage search form.
12            //$(homeSearchForm + '.homepage-search-button ').attr('disabled', 'disabled');
13
14            $(document).ajaxStart(function () {
15                if (homeSearchForm != "undefined" && homeSearchForm) {
16                    $(homeSearchForm + '.homepage-search-button ').attr('disabled', true);
17                }
18                if (toplistForm != "undefined" && toplistForm) {
19                    $(toplistForm + '.toplist-search-button ').attr('disabled', true);
20                    $(toplistForm + '.form-item-product-edition .nice-select').attr('disabled', true);
21                    $(toplistForm + '.form-item-grape-variety .nice-select').attr('disabled', true);
22                    $(toplistForm + '.form-item-region .nice-select').attr('disabled', true);
23                    hide_unrelated_filters();
24                }
25            });
26            $(document).ajaxStop(function () {
27                if (homeSearchForm) {
28                    // If ajax stop activate the search button.
29                    $(homeSearchForm + '.homepage-search-button ').attr('disabled', false);
30                }
31                if (toplistForm) {
32                    $(toplistForm + '.toplist-search-button ').attr('disabled', false);
33                    $(toplistForm + '.form-item-product-edition .nice-select').attr('disabled', false);
34                    $(toplistForm + '.form-item-grape-variety .nice-select').attr('disabled', false);
35                    $(toplistForm + '.form-item-region .nice-select').attr('disabled', false);
36                    // Re-evaluate the visibility after the category select
37                    // may have been replaced by the ajax response.
38                    hide_unrelated_filters(0);
39                }
40            });
41
42            function hide_unrelated_filters(hideDuration = 500) { // <-- time in milliseconds
43
44                setTimeout(
45                    function () {
46                        // The category select is replaced via ajax when the
47                        // edition changes and gets a suffixed id then, so
48                        // select it by its data-drupal-selector instead.
49                        //if post is selected
50                        switch ($('#toplist-filter select[data-drupal-selector="edit-category"]').val()) {
51                            case "toplist_grape":
52                            case "toplist_grape_tip":
53                                $("#toplist-filter .form-item-grape-variety").show(hideDuration);
54                                $("#toplist-filter .form-item-region").hide(hideDuration);
55                                break;
56
57                            case "toplist_region":
58                                $("#toplist-filter .form-item-region").show(hideDuration);
59                                $("#toplist-filter .form-item-grape-variety").hide(hideDuration);
60                                break;
61                            default:
62                                $("#toplist-filter .form-item-grape-variety").hide(hideDuration);
63                                $("#toplist-filter .form-item-region").hide(hideDuration);
64                        }
65                    }, hideDuration/5);
66
67
68            }
69        }
70    }
71})(jQuery, Drupal);
72
73//toplist advertisment block isn't used atm
74/*
75document.addEventListener("DOMContentLoaded", () => {
76    //Show 1 single random Advertisment of the toplist-advertisment block
77    if (document.getElementsByClassName('toplist-advertisment')) {
78        var toplist_advertisment_elements = document.getElementsByClassName('toplist-advertisment');
79        var toplist_advertisment_element = toplist_advertisment_elements[0];
80        //get the amount of children in the block
81        if(toplist_advertisment_element && toplist_advertisment_element.hasChildNodes()){
82            var toplist_advertisment_element_children_count = toplist_advertisment_element.children.length;
83            //get a random id between 1 and childrencount
84            var random_adv_id = "toplist-advertisment-" + randomIntFromInterval(1, toplist_advertisment_element_children_count).toString();
85            //make the random element visible
86            var link_of_adv = document.getElementById(random_adv_id
86);
87            link_of_adv.removeAttribute("hidden");
88        }
89
90    }
91});
92
93
94
95//random function with min and max value
96function randomIntFromInterval(min, max) {
97    return Math.floor(Math.random() * (max - min + 1) + min)
98}
99*/

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.