PageSourceSearch

https://www.hovita.com.sg/wp-content/plugins/wc-quantity-plus-minus-button/assets/js/scripts.js?ver=1.0.0

js hovita.com.sg collected 2026-10-04 05:36:00 UTC 3,029 bytes, 80 lines download raw bytes

1jQuery(function ($) {
2
3    // Make the code work after page load.
4    $(document).ready(function () {
5        QuantityChange();
6    });
7
8    // Make the code work after executing AJAX.
9    $(document).ajaxComplete(function () {
10        QuantityChange();
11    });
12
13    function QuantityChange() {
14        $(document).off("click", ".qib-button").on("click", ".qib-button", function () {
15            // Find quantity input field corresponding to increment button clicked.
16            var qty = $(this).siblings(".quantity").find(".input-text");
17            // Read value and attributes min, max, step.
18            var val = parseFloat(qty.val());
19            var max = parseFloat(qty.attr("max"));
20            var min = parseFloat(qty.attr("min"));
21            var step = parseFloat(qty.attr("step"));
22            // var static = 8;
23            
24            var qtyObj = $(this).siblings(".quantity");
25            var last_step = qtyObj.attr('data-last_step');
26            last_step = parseFloat( last_step );
27            var prev_step = qtyObj.attr('data-prev_step');
28            prev_step = parseFloat( prev_step );
29            // Change input field value if result is in min and max range.
30            // If the result is above max then change to max and alert user about exceeding max stock.
31            // If the field is empty, fill with min for "-" (0 possible) and step for "+".
32            if ($(this).is(".plus")) {
33                if (val === max){
34                    return false;
35                }
36                    
37                if (isNaN(val)) {
38                    qty.val(step);
39                    return false;
40                }
41                if (val + step > max) {
42                    qtyObj.attr('data-last_step', ( max-val < 0 ? 1 : max-val ) );
43                    qtyObj.attr('data-prev_step', ( step ) );
44                    qtyObj.find(".input-text").removeAttr('step' );
45                    qty.val(max);
46                } else {
47                    qty.val(val + step);
48                }
49            } else {
50
51                if (last_step) {
52                    
53                    qty.val(max - last_step);
54                    qtyObj.removeAttr('data-last_step');
55                    qtyObj.find(".input-text").attr('step', prev_step );
56                    qtyObj.removeAttr('data-prev_step');
57                    return false;
58                }
59                if (val === min){
60                    return false;
61                }
62                    
63                if (isNaN(val)) {
64                    qty.val(min);
65                    return false;
66                }
67                if (val - step < min) {
68                    qty.val(min);
69                } else {
70                    qty.val(val - step);
71                }
72            }
73
74            qty.val(Math.round(qty.val() * 100) / 100);
75            qty.trigger("change");
76            $("body").removeClass("sf-input-focused");
77        });
78    }
79
80});

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.