PageSourceSearch

https://espejoaeronautico.com/georgiaprintco-shop.com/modules/mod_smartshop_cart/mod_smartshop_cart.js

js espejoaeronautico.com collected 2026-09-25 01:58:45 UTC 9,829 bytes, 276 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10class SmartshopCartModule {
11
12    constructor() {
13        window.onload = () => {
14			const form = document.querySelector('form[name="product"]');
15            if (form) form.addEventListener('submit', smartshopCartModule.add);
16            
17            this.config = JSON.parse(Joomla.getOptions('smartshopCartConfig'));
18			
19			window.addEventListener('click', function (evt) {
20				
21				const flyoutElement = document.querySelector(".smartshop-cart");
22				if (!flyoutElement.contains(evt.target)) {
23					document.querySelector('.smartshop-cart__link ').classList.remove('cart-triangle');
24					document.querySelector('.smartshop-cart__products ').classList.remove('show-menu');
25				}
26					
27			}, true);
28        }
29
30        this.add = this.add.bind(this);
31    }
32
33    async add (e) {
34    	const {
35            haveProducts,
36            showMessage,
37            redirectAfterBuy
38        } = this.config;
39        let isSmartEditorLink = (e.submitter && e.submitter.id && e.submitter.id == 'btn_add_product_to_editor');
40
41      	if (document.querySelector('#to').value == 'wishlist' || !redirectAfterBuy || isSmartEditorLink) {
42      		return true;
43      	} else {
44      		e.preventDefault();
45      	}
46
47        const body = new FormData(e.target);
48        body.append('ajax', 1);
49
50        const product_id = +body.get('product_id');
51
52        try {
53            const response = await fetch(e.target.action, { method: 'POST', body });
54            const data = await response.json();
55
56            if (!haveProducts) {
57                this._deleteEmptyProductBlock();
58                this._deleteHiddenClass();
59                this.config.haveProducts = true;
60            }
61			
62			if(!data.products){	
63				Joomla.renderMessages({"notice":[data[0].message]});				
64				window.scroll({top: 0, behavior: 'smooth'});
65			}
66			
67            if (!data[0] && showMessage && data.products) {
68                const product = this._getLastAddedProductById(data.products, product_id);
69                this._showMessage(product, data);
70            }
71			
72		if (!data[0]){
73            this._refresh(data);
74		}
75
76        } catch (e) { console.warn(e); }
77
78    }
79
80    _refresh({count_product, products, price_product_brutto, error_max}) {
81        const {
82			addProductMsg,
83            imagePath, 
84            showProductPrice, 
85            showProductSum, 
86            showTotalPrice,
87            showCounter
88        } = this.config;
89		
90		  
91        if (showCounter) {
92            document.querySelector('.smartsop-cart__count').textContent = count_product;
93        }
94
95        if (showTotalPrice) {
96            document.querySelector('.smartshop-cart__total-price').textContent = this._formatprice(price_product_brutto);
97        }
98
99        const productsBlock = document.querySelector('.smartshop-cart__products_wrapper');
100
101        let html = '';
102        products.forEach(prod => {
103            let quantity      = (prod.quantity > 1) ? ` (${prod.quantity})` : '';
104            let product_price = (showProductPrice)  ? ` x ${this._formatprice(prod.price)}` : '';
105            let product_sum   = (showProductSum)    ? ` = <span class="font-weight-bold"> ${this._formatprice(prod.total_price)} </span>` : '';
106            let image         = (prod.thumb_image)  ? prod.thumb_image : 'noimage.gif' ;
107
108            html += `
109                <div class="smartshop-cart__product smartshop-cart__product_show border-bottom pb-1 mb-1">
110                    <img src="${image}" alt="${prod.product_name}" class="smartshop-cart__product_image" />
111                    <div class="smartshop-cart__product_info">
112                        ${prod.product_name + quantity + product_price + product_sum}
113                    </div>
114                </div>
115            `;
116					
117					if(error_max){
118						Joomla.renderMessages({
119							 "notice": [error_max],
120							 "success": [addProductMsg]
121						});
122					}else{
123						Joomla.renderMessages({
124							 "success": [addProductMsg]
125						});
126					}
127        });
128        productsBlock.innerHTML = html;
129    }
130
131    toggleMenu(elem) {
132		if(elem.closest('.smartshop-cart').querySelector('.smartshop-cart__products._left')){
133            let offLeft = elem.closest('.smartshop-cart').offsetLeft;
134			let width = elem.closest('.smartshop-cart').querySelector('.smartshop-cart__products._left').offsetWidth;
135			width -= 50;
136			 if(offLeft < width){
137                 width = offLeft;
138             }
139            elem.closest('.smartshop-cart').querySelector('.smartshop-cart_animate._left').style.marginLeft = '-'+width+'px';
140		}else{
141            var offRight = window.innerWidth - elem.getBoundingClientRect().right;
142            let width = elem.closest('.smartshop-cart').querySelector('.smartshop-cart__products').offsetWidth;
143            if(offRight + elem.offsetWidth < width){
144                width = elem.offsetWidth ;
145                elem.closest('.smartshop-cart').querySelector('.smartshop-cart_animate._right ').style.right = '0px';
146            }
147
148        }
149        elem.classList.toggle('cart-triangle');
150        elem.closest('.smartshop-cart').querySelector('.smartshop-cart__products').classList.toggle('show-menu');
151    }
152
153    _formatprice(price) {
154        const {
155            currency, 
156            decimalCount, 
157            decimalSymbol,
158        } = this.config;
159
160        price = price.toFixed(decimalCount);
161
162        let result = new Intl.NumberFormat('de-DE').format(price);
163        result = result.replace('.', decimalSymbol);
164
165        return `${result} ${currency} `;
166    }
167
168    _deleteEmptyProductBlock() {
169        document.querySelector('.smartshop-cart__no-products').remove();
170    }
171
172    _deleteHiddenClass() {
173        document.querySelectorAll('.ssc-hidden').forEach(e => e.classList.remove('ssc-hidden') );
174    }
175
176    _showMessage({product_name, total_price, price, ...props}, data) {
177        const {
178            addProductMsg,
179            msgBackground,
180            messageWidth,
181            showMessagePrice,
182            showMessageSum,
183            cartLink,
184            toCart,
185            messageContinue,
186        } = this.config;
187
188        const productPrice = (showMessagePrice) ? ` x ${this._formatprice(price)}` : '';
189        const total        = (showMessageSum)   ? ` = <span class="font-weight-bold"> ${this._formatprice(total_price)} </span>` : '';
190
191        let quantity = document.querySelector('#quantity');
192        quantity = (quantity) ? +quantity.value : 1;
193
194		if(parseInt(data.add_quantity) > 0){ quantity = parseInt(data.add_quantity); }
195        const html = `
196            <div class="p-3 shadow smartshop-cart__message__wrapper"
197                style="
198                    background: ${msgBackground};
199                    max-width: ${messageWidth}px;
200                "
201            >
202                <div class="border-bottom border-white pb-1 font-weight-bold">
203                    ${addProductMsg}
204                </div>
205                <div class="py-2">
206                    ${product_name} (${quantity}) ${productPrice + total}
207                </div>
208                <div class="d-flex justify-content-between">
209                    <button class="btn btn-primary" onclick="smartshopCartModule.deleteMessage()">${messageContinue}</button>
210                    <a class="btn btn-success" href="${cartLink}" >${toCart}</a>
211                </div>
212            </div>
213        `;
214					Joomla.renderMessages({
215                        ['error']: [
216                            addProductMsg
217                        ]
218                    });
219		//Joomla.renderMessages({${addProductMsg}});
220        document.querySelector('.smartshop-cart__message').innerHTML = html;
221        this._addAnimation();
222        // this._hideMessage();
223    }
224
225    deleteMessage() {
226        const {
227            messageDelSec, 
228            messageAnimate
229        } = this.config;
230        
231
232        if (messageAnimate) {
233            this._deleteAnimation();
234            const seconds = parseFloat(messageDelSec * 1000);
235            setTimeout(() => document.querySelector('.smartshop-cart__message').innerHTML = '', seconds);
236        } else {
237            document.querySelector('.smartshop-cart__message').innerHTML = '';
238        }
239    }
240
241    _hideMessage() {
242        const {
243            messageSeconds,
244            messageHidden
245        } = this.config
246
247        if (messageHidden) {
248            const seconds = parseFloat(messageSeconds * 1000);
249            setTimeout(() => this.deleteMessage(), seconds);
250        }
251    }
252
253    _getLastAddedProductById(products, product_id) {
254        return products.filter(prod => prod.product_id === product_id )[0];
255    }
256
257    _addAnimation() {
258        if (this.config.messageAnimate) {
259            setTimeout(() => {
260                document.querySelector('.smartshop-cart__message__wrapper').classList.add('scc-message-animation');
261            }, 50);
262        }
263    }
264
265    _deleteAnimation() {
266        if (this.config.messageAnimate) {
267            setTimeout(() => {
268                document.querySelector('.smartshop-cart__message__wrapper').classList.remove('scc-message-animation')
269            }, 50);
270        }
271    }
272
273}
274
275const smartshopCartModule = new SmartshopCartModule();
276}

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.