PageSourceSearch

https://www.zukunftaltbau.de/typo3conf/ext/ep_template_zab/Resources/Public/JavaScripts/Cart.js?1720973634

js zukunftaltbau.de collected 2026-10-02 17:25:19 UTC 6,537 bytes, 167 lines download raw bytes

1/* !!! WICHTIG: siehe auch newsletter.js - Zeile 522 */
2
3/*$(document).ready(function(){
4    if ($('.cart .cart-items .cartListItem').length == 1) {
5        if($('.cart .cart-items .cartListItem').hasClass('dummy')){
6            $('#noItems').show();
7        }
8    }
9
10    $('.cart-items').bind('DOMSubtreeModified', function(){
11        if ($('.cart .cart-items .cartListItem').length == 1) {
12            if($('.cart .cart-items .cartListItem').hasClass('dummy')){
13                $('#noItems').show();
14            } else {
15                $('#noItems').hide();
16            }
17        }
18
19        if ($('.cart .cart-items .cartListItem').length > 1) {
20            $('#noItems').hide();
21        }
22
23        if ($('.cart .cart-items .cartListItem').length < 1) {
24            $('#noItems').show();
25        }
26    });
27
28}); */
29
30$.fn.addMinusClickEvent = function () {
31    this.click(function (e) {
32        e.preventDefault();
33        var amountField = $(this).siblings('input.amount').eq(0);
34        var maxLimit = parseInt(amountField.data('max'));
35        var currentAmount = parseInt(amountField.val());
36        if (currentAmount > 1) {
37            /* update current */
38            currentAmount = currentAmount - 1;
39            amountField.val(currentAmount);
40            if (currentAmount <= 1) {
41                $(this).prop('disabled', true);
42            }
43            if (currentAmount < maxLimit) {
44                var buttonPlus = $(this).siblings('button.plus').eq(0);
45                buttonPlus.prop('disabled', false);
46            }
47        }
48    });
49};
50
51$.fn.addPlusClickEvent = function () {
52    this.click(function (e) {
53        e.preventDefault();
54        var amountField = $(this).siblings('input.amount').eq(0);
55        var maxLimit = parseInt(amountField.data('max'));
56        var currentAmount = parseInt(amountField.val());
57        if (currentAmount < maxLimit) {
58            /* update current */
59            currentAmount = currentAmount + 1;
60            amountField.val(currentAmount);
61            if (currentAmount >= maxLimit) {
62                $(this).prop('disabled', true);
63            }
64            if (currentAmount > 1) {
65                var buttonMinus = $(this).siblings('button.minus').eq(0);
66                buttonMinus.prop('disabled', false);
67            }
68        }
69    });
70};
71
72/* !!! WICHTIG: siehe auch newsletter.js - Zeile 522 */ 
73(function ($) {
74    var $container = $('#cart-container');
75
76    $('.cart-actions button.minus', $container).addMinusClickEvent();
77
78    $('.cart-actions button.plus', $container).addPlusClickEvent();
79
80    $('.cart-actions button.add-cart', $container).click(function (e) {
81        e.preventDefault();
82        var amountField = $(this).siblings('input.amount').eq(0);
83        var amount = parseInt(amountField.val());
84        var maxLimit = parseInt(amountField.data('max'));
85        var dataId = parseInt(amountField.data('item'));
86        var title = amountField.data('title');
87        if (amount <= maxLimit) {
88            var $item = $('.cart-items .dummy', $container).eq(0).clone();
89            $item.removeClass('dummy').addClass('cart-item');
90            $item.attr('data-item', dataId);
91            $('.title', $item).text(title);
92            $('input.amount', $item).val(amount).data('max', maxLimit).attr('data-max', maxLimit);
93            $('input.amount', $item).attr('name', 'tx_eptemplatezab_cart[cart][' + dataId + '][amount]');
94            $('input.amount', $item).attr('id', 'tx_eptemplatezab_cart[cart][' + dataId + '][amount]');
95            $('label', $item).attr('for', 'tx_eptemplatezab_cart[cart][' + dataId + '][amount]');
96            $('input.title', $item).val(title).attr('name', 'tx_eptemplatezab_cart[cart][' + dataId + '][title]');
97
98            if(amount == 1) {
99                $('button.minus', $item).prop('disabled', true);
100            }
101
102            if(amount == maxLimit) {
103                $('button.plus', $item).prop('disabled', true);
104            }
105
106            $('button.plus', $item).addPlusClickEvent();
107            $('button.minus', $item).addMinusClickEvent();
108            $('button.delete', $item).click(function (e) {
109                e.preventDefault();
110                $(this).closest('.cart-item').remove();
111            });
112            $item.appendTo($('.cart-items', $container));
113
114            var itemCount = $('.cart-items > div').length - 1;
115            $('.cart-content', $container).data('count', itemCount);
116            $('.cart-content', $container).attr('data-count', itemCount);
117
118            /* reset amount and disable minus button */
119            var buttonMinus = $(this).siblings('button.minus').eq(0);
120            buttonMinus.prop('disabled', true);
121            amountField.val(1);
122        }
123    });
124
125    $('button.submit', $container).click(function (e) {
126        $button = $(this);
127        if ($('.cart-items .cart-item', $container).length == 0) {
128            var $message = $button.prev('.error');
129            if ($message.length <= 0) {
130                $button.before('<ul class="error"><li>Warenkorb ist leer!</li></ul>');
131            }
132            e.preventDefault();
133        }
134        if ($('[name="tx_eptemplatezab_cart[address][zip]"]').val().length !== 5) {
135            var $message = $button.prev('.error');
136            if ($message.length <= 0) {
137                $button.before('<ul class="error"><li>Ungültige PLZ!</li></ul>');
138            }
139            e.preventDefault();
140        }
141    });
142
143    var $cartElement = $('.tx-eptemplatezab-cart', $container);  
144    if ($cartElement.find('.error').length > 0) {
145        $cartElement.find('.cart-toggle').attr('checked', true);
146        $(window).scrollTop($cartElement.offset().top);
147    }
148
149    $(window).on('scroll', function () {
150        $('.tx-eptemplatezab-cart').each(function () {
151            var $cartElement = $(this),
152                offset = $cartElement.offset(),
153                height = $cartElement.height(),
154                $cart = $cartElement.find('.cart');
155            if (offset.top < $(window).scrollTop()) {
156                $cart.addClass('fixed');
157            } else {
158                $cart.removeClass('fixed');
159            }
160            if (height + offset.top - $cart.height() < $(window).scrollTop()) {
161                $cart.addClass('toBottom');
162            } else {
163                $cart.removeClass('toBottom');
164            }
165        });
166    });
167})(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.