PageSourceSearch

https://nzcmhn.org.nz/wp-content/plugins/eventon-tickets/assets/tx_wc_variable.js?ver=2.4.19

js nzcmhn.org.nz collected 2026-10-07 10:12:59 UTC 11,615 bytes, 281 lines download raw bytes

1/*
2 *  Tickets Variable Product Javascript
3 *  @version: 2.4.4
4 */
5
6jQuery(document).ready(function($){
7
8
9
10//if( $('body').find('.evotx_show_variations').length  == 0) return;
11
12//* Variations Plugin
13(function (e, t, n, r) {
14
15
16    e.fn._wc_variation_form = function () {
17        e.fn._wc_variation_form.find_matching_variations = function (t, n) {
18            var r = [];
19            for (var i = 0; i < t.length; i++) {
20                var s = t[i],
21                o = s.variation_id;
22                e.fn._wc_variation_form.variations_match(s.attributes, n) && r.push(s)
23            }
24            return r
25        };
26        e.fn._wc_variation_form.variations_match = function (e, t) {
27            var n = !0;
28            for (attr_name in e) {
29                var i = e[attr_name],
30                s = t[attr_name];
31                i !== r && s !== r && i.length != 0 && s.length != 0 && i != s && (n = !1)
32            }
33            return n
34        };
35
36        this.unbind("check_variations update_variation_values found_variation");
37        this.find(".reset_variations").unbind("click");
38        this.find(".variations select").unbind("change focusin");
39        return this.on("click", ".reset_variations", function (t) {
40        e(this).closest("form.variations_form").find(".variations select").val("").change();
41        var n = e(this).closest(".product").find(".sku"),
42        r = e(this).closest(".product").find(".product_weight"),
43        i = e(this).closest(".product").find(".product_dimensions");
44        n.attr("data-o_sku") && n.text(n.attr("data-o_sku"));
45        r.attr("data-o_weight") && r.text(r.attr("data-o_weight"));
46        i.attr("data-o_dimensions") && i.text(i.attr("data-o_dimensions"));
47        return !1
48        }).on("change", ".variations select", function (t) {
49
50            //console.log('rr');
51            
52            var SECTION = $(this).closest('.evotx_ticket_purchase_section');
53            $('body').trigger('evotx_calculate_total', [ SECTION ]); 
54
55            $variation_form = e(this).closest("form.variations_form");
56            $variation_form.find("input[name=variation_id]").val("").change();
57            $variation_form.trigger("woocommerce_variation_select_change").trigger("check_variations", ["", !1]);
58            e(this).blur();
59            e().uniform && e.isFunction(e.uniform.update) && e.uniform.update()
60        }).on("focusin", ".variations select", function (t) {
61            $variation_form = e(this).closest("form.variations_form");
62            $variation_form.trigger("woocommerce_variation_select_focusin").trigger("check_variations", [e(this).attr("name"), !0])
63        }).on("check_variations", function (n, r, i) {
64            var s = !0,
65            o = !1,
66            u = !1,
67            a = {},
68            f = e(this),
69            l = f.find(".reset_variations");
70            f.find(".variations select").each(function () {
71            e(this).val().length == 0 ? s = !1 : o = !0;
72            if (r && e(this).attr("name") == r) {
73            s = !1;
74            a[e(this).attr("name")] = ""
75            } else {
76            value = e(this).val();
77            a[e(this).attr("name")] = value
78            }
79            });
80            var c = parseInt(f.data("product_id")),
81            h = f.data("product_variations");
82            h || (h = t.product_variations[c]);
83            h || (h = t.product_variations);
84            h || (h = t["product_variations_" + c]);
85            var p = e.fn._wc_variation_form.find_matching_variations(h, a);
86            if (s) {
87                var d = p.pop();
88                if (d) {
89                    f.find("input[name=variation_id]").val(d.variation_id).change();
90                    f.trigger("found_variation", [d])
91                } else {
92                    f.find(".variations select").val("");
93                    i || f.trigger("reset_image");
94                    alert(woocommerce_params.i18n_no_matching_variations_text)
95                }
96            } else {
97                f.trigger("update_variation_values", [p]);
98                i || f.trigger("reset_image");
99                r || f.find(".single_variation_wrap").slideUp("200")
100            }
101        o ? l.css("visibility") == "hidden" && l.css("visibility", "visible").hide().fadeIn() : l.css("visibility", "hidden")
102        }).on("reset_image", function (t) {
103            var n = e(this).closest(".product"),
104            r = n.find("div.images img:eq(0)"),
105            i = n.find("div.images a.zoom:eq(0)"),
106            s = r.attr("data-o_src"),
107            o = r.attr("data-o_title"),
108            u = i.attr("data-o_href");
109            s && r.attr("src", s);
110            u && i.attr("href", u);
111            if (o) {
112                r.attr("alt", o).attr("title", o);
113                i.attr("title", o)
114            }
115        }).on("update_variation_values", function (t, n) {
116            $variation_form = e(this).closest("form.variations_form");
117            $variation_form.find(".variations select").each(function (t, r) {
118                current_attr_select = e(r);
119                current_attr_select.data("attribute_options") || current_attr_select.data("attribute_options", current_attr_select.find("option:gt(0)").get());
120                current_attr_select.find("option:gt(0)").remove();
121                current_attr_select.append(current_attr_select.data("attribute_options"));
122                current_attr_select.find("option:gt(0)").removeClass("active");
123                var i = current_attr_select.attr("name");
124                 
125                for (num in n)
126                if (typeof n[num] != "undefined") {
127                    var s = n[num].attributes;
128                    for (attr_name in s) {
129                        var o = s[attr_name];
130                        if (attr_name == i) if (o) {
131                            o = e("<div/>").html(o).text();
132                            o = o.replace(/'/g, "\\'");
133                            o = o.replace(/"/g, '\\"');
134                            current_attr_select.find('option[value="' + o + '"]').addClass("active")
135                        } else current_attr_select.find("option:gt(0)").addClass("active")
136                    }
137                }
138                current_attr_select.find("option:gt(0):not(.active)").remove()
139            });
140            $variation_form.trigger("woocommerce_update_variation_values")
141        }).on("found_variation", function (t, n) {
142
143            var r = e(this),
144            i = e(this).closest(".product"),
145            s = i.find("div.images img:eq(0)"),
146            o = i.find("div.images a.zoom:eq(0)"),
147            u = s.attr("data-o_src"),
148            a = s.attr("data-o_title"),
149            f = o.attr("data-o_href"),
150            l = n.image_src,
151            c = n.image_link,
152            h = n.image_title;
153            r.find(".variations_button").show();
154            r.find(".single_variation").html(n.price_html + n.availability_html).show();
155            if (!u) {
156                u = s.attr("src") ? s.attr("src") : "";
157                s.attr("data-o_src", u)
158            }
159            if (!f) {
160                f = o.attr("href") ? o.attr("href") : "";
161                o.attr("data-o_href", f)
162            }
163            if (!a) {
164                a = s.attr("title") ? s.attr("title") : "";
165                s.attr("data-o_title", a)
166            }
167            if (l && l.length > 1) {
168                s.attr("src", l).attr("alt", h).attr("title", h);
169                o.attr("href", c).attr("title", h)
170            } else {
171                s.attr("src", u).attr("alt", a).attr("title", a);
172                o.attr("href", f).attr("title", a)
173            }
174            var p = r.find(".single_variation_wrap"),
175            d = i.find(".product_meta").find(".sku"),
176            v = i.find(".product_weight"),
177            m = i.find(".product_dimensions");
178            d.attr("data-o_sku") || d.attr("data-o_sku", d.text());
179            v.attr("data-o_weight") || v.attr("data-o_weight", v.text());
180            m.attr("data-o_dimensions") || m.attr("data-o_dimensions", m.text());
181            n.sku ? d.text(n.sku) : d.text(d.attr("data-o_sku"));
182             
183            n.weight ? v.text(n.weight) : v.text(v.attr("data-o_weight"));
184            n.dimensions ? m.text(n.dimensions) : m.text(m.attr("data-o_dimensions"));
185            p.find(".quantity").show();
186            !n.is_in_stock && !n.backorders_allowed && r.find(".variations_button").hide();
187
188            n.min_qty ? 
189                p.find("input[name=quantity]").attr("min", n.min_qty).val(n.min_qty) : 
190                p.find("input[name=quantity]").removeAttr("min");
191            n.max_qty ? 
192                p.find("input[name=quantity]").attr("max", n.max_qty) : 
193                p.find("input[name=quantity]").removeAttr("max");
194
195            if (n.is_sold_individually == "yes") {
196                p.find("input[name=quantity]").val("1");
197                p.find(".quantity").hide()
198            }
199            p.slideDown("200").trigger("show_variation", [n])
200        });
201         
202        /**
203        * Initial states and loading
204        */
205        jQuery('form.variations_form .variations select').change();
206         
207        /**
208        * Helper functions for variations
209        */
210         
211        // Search for matching variations for given set of attributes     
212        function find_matching_variations(product_variations, settings) {
213            var matching = [];
214             
215            for (var i = 0; i < product_variations.length; i++) {
216                var variation = product_variations[i];
217                var variation_id = variation.variation_id;
218                 
219                if (variations_match(variation.attributes, settings)) {
220                    matching.push(variation);
221                }
222            }
223            return matching;
224        }
225         
226        // Check if two arrays of attributes match 
227        function variations_match(attrs1, attrs2) {
228            var match = true;
229            for (attr_name in attrs1) {
230                var val1 = attrs1[attr_name];
231                    var val2 = attrs2[attr_name];
232                if (val1 !== undefined && val2 !== undefined && val1.length != 0 && val2.length != 0 && val1 != val2) {
233                    match = false;
234                }
235            }
236            return match;
237        }
238     
239    };
240   
241
242})(jQuery, window, document); // JavaScript Document
243
244
245
246// when clicked on  order now button run custom variations function
247    $('body').on('click', '.evotx_show_variations',function(){
248
249        console.log('dd');
250
251        var O = jQuery(this);
252
253        O.parent().hide();
254        var _this_form = O.parent().siblings('.variations_form');
255
256        _this_form.show();
257
258        _this_form._wc_variation_form();
259
260        setTimeout(function(){
261            vars = O.data('defv');
262
263            _this_form.find('.variations select').each(function(){
264                sO = jQuery(this);
265                sF = sO.attr('id');
266                if( sF in vars){
267                    sO.find('option[value="'+ vars[sF] +'"]').prop('select',true);                    
268                }else{
269                    sO.find('option:eq(2)').prop('select',true);      
270                }
271
272                
273                sO.change();
274            });
275        },200);   
276    });
277
278//} // end if
279
280
281});

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.