PageSourceSearch

https://www.roboteq.com/templates/vp_smart/js/vmprices.js?vmver=0a76d648

js roboteq.com collected 2026-10-02 05:14:42 UTC 9,895 bytes, 312 lines download raw bytes

1/**
2 *---------------------------------------------------------------------------------------
3 * @package       VP Smart Template
4 *---------------------------------------------------------------------------------------
5 * @copyright     Copyright (C) 2012-2021 VirtuePlanet Services LLP. All rights reserved.
6 * @license       GNU General Public License version 2 or later; see LICENSE.txt
7 * @authors       Abhishek Das
8 * @email         [email protected]
9 * @link          https://www.virtueplanet.com
10 *---------------------------------------------------------------------------------------
11 */
12var Virtuemart = window.Virtuemart || {};
13
14Virtuemart.ajaxPool = {};
15
16Virtuemart.setproducttype = function(form, id) {
17	var $ = jQuery.noConflict();
18	form.view = null;
19	var datas = form.serialize();
20	var prices = form.closest(".vm-productdetails").find(".product-price-stock-sku-cont .product-price");
21	if (!prices.length) {
22		prices = form.closest(".product-item").find(".product-price");
23	}
24	datas = datas.replace('&view=cart', '');
25	prices.fadeTo('fast', 0.75);
26	if (Virtuemart.ajaxPool.hasOwnProperty('setproducttype') && Virtuemart.ajaxPool['setproducttype'].readystate != 4) {
27		Virtuemart.ajaxPool['setproducttype'].abort();
28	}
29	Virtuemart.ajaxPool['setproducttype'] = $.ajax({
30		dataType: 'JSON',
31		type: 'GET',
32		cache: false,
33		url: window.vmSiteurl + 'index.php?&option=com_virtuemart&view=productdetails&task=recalculate&format=json&nosef=1' + window.vmLang,
34		data: datas,
35		success: function(data, textStatus) {
36			prices.fadeTo('fast', 1);
37			$('#system-message-container #system-message div.vmprices-message').remove();
38			for (var key in data) {
39				var value = data[key];
40				if (key == 'messages') {
41					if ($.type(data[key]) == 'string') {
42						data[key] = $.parseHTML(data[key]);
43					}
44					var newmessages = $(data[key]).find('div.alert').addClass('vmprices-message');
45					if (!$('#system-message-container #system-message').length && newmessages.length) {
46						$('#system-message-container').append('<div id="system-message"></div>');
47						t("html, body").animate({
48							scrollTop: $('#system-message-container').offset().top - 50
49						}, 500);
50					}
51					newmessages.appendTo('#system-message-container #system-message');
52				} else {
53					if (!value) {
54						prices.find('.Price' + key).html(0).addClass('hide');
55					} else {
56						if (key == 'discountAmount' && value.indexOf('-') >= 0) {
57							value = value.replace('-', '');
58						}
59						prices.find('span.Price' + key).removeClass('hide').html(value);
60					}
61				}
62			}
63		}
64	});
65	return false;
66}
67
68Virtuemart.productUpdate = function() {
69	var $ = jQuery.noConflict();
70	$('body').trigger('updateVirtueMartCartModule');
71}
72
73Virtuemart.eventsetproducttype = function(event) {
74	Virtuemart.setproducttype(event.data.cart, event.data.virtuemart_product_id);
75}
76
77Virtuemart.incrQuantity = (function(event) {
78	var rParent = jQuery(this).parent().parent();
79	quantity = rParent.find('input[name="quantity[]"]');
80	virtuemart_product_id = rParent.find('input[name="virtuemart_product_id[]"]').val();
81	Ste = parseInt(quantity.attr("step"));
82	if (isNaN(Ste)) Ste = 1;
83	Qtt = parseInt(quantity.val());
84	if (!isNaN(Qtt)) {
85		quantity.val(Qtt + Ste);
86		maxQtt = parseInt(quantity.attr("max"));
87		if (!isNaN(maxQtt) && quantity.val() > maxQtt) {
88			quantity.val(maxQtt);
89		}
90		Virtuemart.setproducttype(event.data.cart, virtuemart_product_id);
91	}
92});
93
94Virtuemart.decrQuantity = (function(event) {
95	var rParent = jQuery(this).parent().parent();
96	var quantity = rParent.find('input[name="quantity[]"]');
97	var virtuemart_product_id = rParent.find('input[name="virtuemart_product_id[]"]').val();
98	var Ste = parseInt(quantity.attr("step"));
99	if (isNaN(Ste)) Ste = 1;
100	var minQtt = parseInt(quantity.attr("init"));
101	if (isNaN(minQtt)) minQtt = 1;
102	var Qtt = parseInt(quantity.val());
103
104	if (!isNaN(Qtt) && Qtt > Ste) {
105		quantity.val(Qtt - Ste);
106		if (!isNaN(minQtt) && quantity.val() < minQtt) {
107			quantity.val(minQtt);
108		}
109	} else quantity.val(minQtt);
110	Virtuemart.setproducttype(event.data.cart, virtuemart_product_id);
111});
112
113Virtuemart.addtocart = function(e) {
114	var targ;
115	if (!e) e = window.event;
116	e.preventDefault();
117	if (e.hasOwnProperty('stopSendtocart') && e.stopSendtocart == true) {
118		return false;
119	}
120	if (e.target) targ = e.target;
121	else if (e.srcElement) targ = e.srcElement;
122	if (targ.nodeType == 3) // defeat Safari bug
123		targ = targ.parentNode;
124
125	if (jQuery(targ).prop("type") == "submit" || jQuery(targ).prop("type") == "image") {
126		Virtuemart.sendtocart(e.data.cart);
127		return false;
128	}
129};
130
131Virtuemart.sendtocart = function(form) {
132	if (Virtuemart.addtocart_popup == 1) {
133		Virtuemart.cartEffect(form);
134	} else {
135		form.append('<input type="hidden" name="task" value="add" />');
136		form.submit();
137	}
138}
139
140Virtuemart.cartEffect = function(form) {
141	var $ = jQuery.noConflict();
142	if (Virtuemart.ajaxPool.hasOwnProperty('add') && Virtuemart.ajaxPool['add'].readystate != 4) {
143		Virtuemart.ajaxPool['add'].abort();
144	}
145	Virtuemart.ajaxPool['add'] = $.ajax({
146		dataType: 'JSON',
147		type: 'GET',
148		cache: false,
149		beforeSend: function() {
150			VPF.showVPFActivity();
151		},
152		url: window.vmSiteurl + 'index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json' + vmLang,
153		data: form.serialize(),
154		success: function(data, textStatus) {
155			VPF.stopVPFActivity();
156			// If Quick view show dialog in parent window
157			if ($('html').hasClass('tmpl-component') && $('html').hasClass('view-productdetails') && window.location != window.parent.location) {
158				window.parent.Virtuemart.renderDialog(data, textStatus);
159			} else {
160				Virtuemart.renderDialog(data, textStatus);
161			}
162		},
163		error: function(jqXHR, textStatus, errorThrown) {
164			console.log(jqXHR);
165			console.log(textStatus);
166			console.log(errorThrown);
167			VPF.stopVPFActivity();
168		}
169	});
170}
171
172Virtuemart.renderDialog = function(data, textStatus) {
173	var $ = jQuery.noConflict();
174	if ($.type(data.msg) == 'string') {
175		data.msg = $.parseHTML(data.msg);
176	}
177	var title,
178		$closeButton,
179		buttons,
180		$message = $(data.msg),
181		type = BootstrapDialog.TYPE_INFO;
182	if ($('.ajax-popup-buttons', $message).length) {
183		buttons = $('.ajax-popup-buttons', $message).html();
184		$('.ajax-popup-buttons', $message).remove();
185	}
186	if ($('.hasError', $message).length) {
187		title = '<span class="product-added-title">' + Joomla.JText._("WARNING") + '</span>';
188		type = BootstrapDialog.TYPE_WARNING;
189	} else if (data.stat == 1) {
190		title = '<span class="product-added-title">' + Joomla.JText._("COM_VIRTUEMART_PRODUCT_ADDED_SUCCESSFULLY") + '</span>';
191	} else if (data.stat == 2) {
192		title = form.find(".pname").val();
193		type = BootstrapDialog.TYPE_WARNING;
194	} else {
195		title = vmCartError;
196		type = BootstrapDialog.TYPE_DANGER;
197	}
198	var dialog = new BootstrapDialog({
199		title: title,
200		message: function(dialogRef) {
201			if (!title) {
202				$closeButton = $('<button type="button" class="btn btn-modal-close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>');
203				$closeButton.on('click', {
204					dialogRef: dialogRef
205				}, function(event) {
206					event.data.dialogRef.close();
207				});
208				var $temp = $('<div/>').append($closeButton).append($message);
209				$message = $temp.contents();
210			}
211
212			return $message;
213		},
214		type: type,
215		cssClass: 'modal-center'
216	});
217	dialog.realize();
218	if (!title) {
219		dialog.getModalHeader().remove();
220	}
221	if (buttons) {
222		dialog.getModalFooter().html(buttons).show();
223		dialog.getModalFooter().find('.show-cart-button').click(function() {
224			VPF.showVPFActivity();
225		});
226	} else {
227		dialog.getModalFooter().remove();
228	}
229	dialog.open();
230	Virtuemart.productUpdate();
231};
232
233Virtuemart.product = function(carts) {
234	carts.each(function() {
235		var cart = jQuery(this),
236			step = cart.find('input[name="quantity[]"]'),
237			addtocart = cart.find('input.addtocart-button, button[name="addtocart"], input[name="addtocart"], a[name="addtocart"]'),
238			plus = cart.find('.quantity-plus'),
239			minus = cart.find('.quantity-minus'),
240			select = cart.find('select:not(.no-vm-bind)'),
241			radio = cart.find('input:radio:not(.no-vm-bind)'),
242			virtuemart_product_id = cart.find('input[name="virtuemart_product_id[]"]').val(),
243			quantity = cart.find('.quantity-input');
244
245		var Ste = parseInt(step.val());
246		if (isNaN(Ste)) {
247			Ste = 1;
248		}
249		var quantityErrorAlert = function() {
250			var me = jQuery(this);
251			Virtuemart.checkQuantity(this, me.attr("step"), me.attr("data-errStr"));
252		};
253
254		plus
255			.off('click', Virtuemart.incrQuantity)
256			.on('click', {
257				cart: cart
258			}, Virtuemart.incrQuantity);
259
260		minus
261			.off('click', Virtuemart.decrQuantity)
262			.on('click', {
263				cart: cart
264			}, Virtuemart.decrQuantity);
265
266		select
267			.off('change', Virtuemart.eventsetproducttype)
268			.on('change', {
269				cart: cart,
270				virtuemart_product_id: virtuemart_product_id
271			}, Virtuemart.eventsetproducttype);
272
273		radio
274			.off('change', Virtuemart.eventsetproducttype)
275			.on('change', {
276				cart: cart,
277				virtuemart_product_id: virtuemart_product_id
278			}, Virtuemart.eventsetproducttype);
279
280		quantity
281			.off('keyup', Virtuemart.eventsetproducttype)
282			.on('keyup', {
283				cart: cart,
284				virtuemart_product_id: virtuemart_product_id
285			}, Virtuemart.eventsetproducttype)
286			.off('blur click change submit', quantityErrorAlert)
287			.on('blur click change submit', quantityErrorAlert);
288
289		this.action = "#";
290
291		jQuery(addtocart).off('click', Virtuemart.addtocart);
292		jQuery(addtocart).on('click', {
293			cart: cart
294		}, Virtuemart.addtocart);
295	});
296}
297
298Virtuemart.checkQuantity = function(obj, step, myStr) {
299	// Use modulus operator "%" to see if there is a remainder
300	var remainder = obj.value % step,
301		quantity = obj.value;
302	if (remainder != 0) {
303		alert(myStr.replace("%s", step));
304		if (quantity != remainder && quantity > remainder) {
305			obj.value = quantity - remainder;
306		} else {
307			obj.value = step;
308		}
309		return false;
310	}
311	return true;
312}

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.