PageSourceSearch

https://www.knjizare-vulkan.rs/nb-public/themes/nbshop7_v1_1/compo…roduct-button-with-bubble-5.js?ver=1053_3.1

js knjizare-vulkan.rs collected 2026-10-02 07:58:32 UTC 5,605 bytes, 144 lines download raw bytes

1function NBUI_ProductButtonWithBubble5() {}
2
3var modelNBUI_ProductAddToCart  = new NBUI_ProductAddToCart();
4var modelNBUI_MiniCartOffcanvas = new NBUI_MiniCartOffcanvas();
5
6NBUI_ProductButtonWithBubble5.prototype.appendBubbleWrapper = function ($element) {
7    let $wrapperWhereToAppend = $element.closest('.nb-mini-cart-offcanvas').find('.nbf-wrapper-for-size-picker');
8    if (!$wrapperWhereToAppend.length) return;
9
10    let $bubbleButtons   = $element.find('.nbf-open-bubble');
11
12    $bubbleButtons.off('click.nbAppendBubble').on('click.nbAppendBubble', function (e) {
13        e.preventDefault();
14        e.stopPropagation();
15
16        let $bubbleButton    = $(this);
17
18        let quantity = $bubbleButton.closest('.nbf-product-item').find('.nbf-quantity-input').val();
19
20        $bubbleButton.closest('.nbf-product-item').find('.nbf-product-bubble .nbf-add-to-cart').attr('data-product-quantity', quantity);
21
22
23        let $wrapperToAppend = $bubbleButton.siblings('.nbf-product-bubble');
24
25        if (!$wrapperWhereToAppend.hasClass('active')) {
26            $wrapperWhereToAppend.empty()
27                .append($wrapperToAppend.clone(true, true))
28                .addClass('active');
29        } else {
30            $element.append($wrapperToAppend);
31            $wrapperWhereToAppend.removeClass('active');
32        }
33
34    });
35};
36
37NBUI_ProductButtonWithBubble5.prototype.openBubble = function ($element) {
38    let $bubbleButtons        = $element.find('.nbf-open-bubble');
39
40    $bubbleButtons.off('click.nbOpenBubble').on('click.nbOpenBubble', function () {
41        let $bubbleButton = $(this);
42        let $bubbleWrapper = $bubbleButton.closest('.nbf-product-button-with-bubble');
43
44        $('.nbf-product-button-with-bubble').removeClass('active');
45        $bubbleWrapper.toggleClass('active');
46    });
47};
48
49NBUI_ProductButtonWithBubble5.prototype.closeBubble = function ($element) {
50
51    let $bubbleWrapper      = $element.closest('.nb-mini-cart-offcanvas').find('.nbf-wrapper-for-size-picker');
52    let $closeBubbleButtons = $element.find('.nbf-close-bubble-btn');
53
54    $closeBubbleButtons.off('click.nbCloseBubbleBtn').on('click.nbCloseBubbleBtn', function () {
55
56        let $closeBubbleBtn = $(this);
57
58        if ($bubbleWrapper.length && $bubbleWrapper.hasClass('active')) {
59            $bubbleWrapper.empty();
60            $bubbleWrapper.removeClass('active');
61        }
62
63        $closeBubbleBtn.closest('.nbf-product-button-with-bubble').removeClass('active');
64    });
65
66    $(document).off('click.nbDocumentCloseBubbleBtn').on('click.nbDocumentCloseBubbleBtn', function () {
67        $element.find('.nbf-product-button-with-bubble.active').each(function () {
68            let $bubbleWrapper = $(this).find('.nbf-bubble-wrapper');
69            if ($bubbleWrapper.length) $bubbleWrapper.empty();
70            $(this).removeClass('active');
71        });
72    });
73};
74
75NBUI_ProductButtonWithBubble5.prototype.checkQuantity = function(elementQuantity, $btnAddToCart){
76    let quantity    = elementQuantity.val();
77    let quantityBtn = $btnAddToCart.attr('data-product-quantity');
78    if(quantity != quantityBtn){
79        $btnAddToCart.attr('data-product-quantity', quantity);
80    }
81
82    return true;
83};
84
85NBUI_ProductButtonWithBubble5.prototype.addToCart = function ($element) {
86    let self = this;
87
88    let $btn = $element.find('.nbf-add-to-cart');
89
90    $btn.off('click.nbAddToCart').on('click.nbAddToCart', function (e) {
91        e.preventDefault();
92
93        let addToCartBtn = $(this);
94        let clickedProductSize = addToCartBtn.find('.nbf-size-value.active');
95        let addToCartBtnCombID = addToCartBtn.attr('data-productsize-combid');
96        let addToCartBtnSizeName = addToCartBtn.attr('data-productsize-name');
97        let miniCartType = $('#nb-mini-cart').data('mini-cart-type');
98        var elementQuantity  = $(this).parents('.nbf-product-item').find('.nbf-quantity-input');
99
100        if(elementQuantity.length > 0){
101            self.checkQuantity(elementQuantity, addToCartBtn);
102        }
103
104        if (addToCartBtnCombID != '-1' && addToCartBtnSizeName != '') {
105            let addToCart = modelNBUI_ProductAddToCart.addToCart(addToCartBtn);
106
107            if (addToCart.flag) {
108                setTimeout(function () {
109                    if (addToCart.ret.flag) {
110                        addToCartBtn.addClass('addingItem');
111
112                        modelNBUI_ProductAddToCart.resetButtonText(addToCartBtn);
113                        modelNBUI_ProductAddToCart.resetSize(clickedProductSize, addToCartBtn);
114
115                        setTimeout(function () {
116                            addToCartBtn.removeClass('addingItem');
117                            if (miniCartType === '1') {
118                                openMiniCart();
119                            } else {
120                                modelNBUI_MiniCartOffcanvas.reload();
121                            }
122                        }, 300);
123
124                    } else {
125                        modelNBUI_ProductAddToCart.resetButton(addToCartBtn);
126                        modelNBUI_ProductAddToCart.resetSize(clickedProductSize, addToCartBtn);
127                        nb7_infoError(addToCart.ret.info);
128                    }
129                }, 0);
130            } else {
131                modelNBUI_ProductAddToCart.errorMesage(addToCartBtn, addToCart.info);
132            }
133        } else {
134            return false;
135        }
136    });
137};
138
139NBUI_ProductButtonWithBubble5.prototype.init = function ($element) {
140    this.addToCart($element);
141    this.openBubble($element);
142    this.closeBubble($element);
143    this.appendBubbleWrapper($element);
144};

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.