PageSourceSearch

https://efratlobel.com/wp-content/plugins/jet-woo-builder-custom-q…/assets/js/main.js?ver=1.0.0

js efratlobel.com collected 2026-09-27 11:47:36 UTC 6,883 bytes, 201 lines download raw bytes

1( function( $, elementorFrontend ) {
2
3	"use strict";
4
5	let JetWooBuilderCQS = {
6		init: function () {
7			let widgets = {
8				'jet-woo-products.default' : JetWooBuilderCQS.quantitySelector,
9				'jet-single-add-to-cart.default' : JetWooBuilderCQS.quantitySelector,
10				'jet-woo-products-list.default' : JetWooBuilderCQS.quantitySelector,
11				'jet-woo-builder-archive-add-to-cart.default' : JetWooBuilderCQS.quantitySelector,
12				'jet-cart-table.default' : JetWooBuilderCQS.quantitySelector
13			};
14
15			$.each( widgets, function( widget, callback ) {
16				elementorFrontend.hooks.addAction( 'frontend/element_ready/' + widget, callback );
17			});
18
19			( function() {
20				let send = XMLHttpRequest.prototype.send
21				XMLHttpRequest.prototype.send = function() {
22					this.addEventListener( 'load', function() {
23						JetWooBuilderCQS.reInitQuantitySelector( '.quantity:not(.jet-woo-quantity-button-added)' );
24					} )
25
26					return send.apply(this, arguments)
27				}
28			} )();
29
30		},
31
32		quantitySelector: function ( $scope ) {
33			$scope.each( function () {
34
35				let settings = JetWooBuilderCQS.getElementorElementSettings( $( this ) );
36
37				if ( settings && settings.enable_custom_quantity_selector ) {
38					let $quantityWrap = $( this ).find( '.quantity:not(.jet-woo-quantity-button-added)' ),
39						increaseControl = settings.selected_quantity_increase_button_icon.value,
40						decreaseControl = settings.selected_quantity_decrease_button_icon.value,
41						controlsPosition = settings.quantity_buttons_position,
42						increaseHtml = '',
43						decreaseHtml = '';
44
45					if ( 'object' === typeof increaseControl ) {
46						increaseHtml = '<img class="icon-svg" src="' + increaseControl.url + '" alt="increase icon">';
47					} else {
48						increaseHtml = '<i class="' + increaseControl + '"></i>';
49					}
50
51					if ( 'object' === typeof decreaseControl ) {
52						decreaseHtml = '<img class="icon-svg" src="' + decreaseControl.url + '" alt="decrease icon">';
53					} else {
54						decreaseHtml = '<i class="' + decreaseControl + '"></i>';
55					}
56
57					$quantityWrap.each( function () {
58						let $quantityBox = $( this ).find( '.qty' );
59
60						if ( $quantityBox && 'date' !== $quantityBox.attr( 'type' ) && 'hidden' !== $quantityBox.attr( 'type' ) ) {
61							let $quantityParent = $quantityBox.parent();
62
63							$quantityParent.addClass( 'jet-woo-quantity-button-added position-' + controlsPosition );
64
65							switch ( controlsPosition ) {
66								case 'horizontal':
67								case 'vertical':
68									$quantityParent.prepend( '<a href="javascript:void(0)" class="jet-woo-qty-control decrease">' + decreaseHtml + '</a>' );
69									$quantityParent.append( '<a href="javascript:void(0)" class="jet-woo-qty-control increase">' + increaseHtml + '</a>' );
70
71									break;
72								case 'start':
73								case 'top':
74									$quantityParent.prepend( '<div class="jet-woo-qty-controls-holder"><a href="javascript:void(0)" class="jet-woo-qty-control increase">' + increaseHtml + '</a><a href="javascript:void(0)" class="jet-woo-qty-control decrease">' + decreaseHtml + '</a></div>');
75									break;
76								case 'end':
77								case 'bottom':
78									$quantityParent.append( '<div class="jet-woo-qty-controls-holder"><a href="javascript:void(0)" class="jet-woo-qty-control increase">' + increaseHtml + '</a><a href="javascript:void(0)" class="jet-woo-qty-control decrease">' + decreaseHtml + '</a></div>');
79									break;
80							}
81
82							$( this ).find( '.icon-svg' ).each( function() {
83								let img = $( this ),
84									image_uri   = img.attr( 'src' );
85
86								$.get( image_uri, function( data ) {
87									let svg = $( data ).find( 'svg' );
88
89									svg.removeAttr( 'xmlns:a' );
90									img.replaceWith( svg );
91								}, 'xml' );
92							} );
93
94							let $min = $quantityBox.attr( 'min' );
95
96							if ( $min && $min > 0 && parseFloat( $quantityBox.val() ) < $min ) {
97								$quantityBox.val( $min );
98							}
99
100							let increaseDecreaseObject = $( this ).find( '.jet-woo-qty-control' );
101
102							increaseDecreaseObject.each( function () {
103								$( this ).on( 'click', function( e ) {
104									e.preventDefault();
105
106									let $currentQuantityValue = parseFloat( $quantityBox.val() ),
107										$maxQuantity = parseFloat( $quantityBox.attr( 'max' ) ),
108										$minQuantity = parseFloat( $quantityBox.attr( 'min' ) ),
109										$step = parseFloat( $quantityBox.attr( 'step' ) );
110
111									if ( ! $currentQuantityValue || '' === $currentQuantityValue || 'NaN' === $currentQuantityValue ) {
112										$currentQuantityValue = 0;
113									}
114
115									if ( '' === $maxQuantity || 'NaN' === $maxQuantity ) {
116										$maxQuantity = '';
117									}
118
119									if ( '' === $minQuantity || 'NaN' === $minQuantity ) {
120										$minQuantity = 0;
121									}
122
123									if ( 'any' === $step || '' === $step || undefined === $step || '
123NaN' === $step ) {
124										$step = 1;
125									}
126
127									if ( $( e.target ).parents( '.jet-woo-qty-control' ).hasClass( 'increase' ) || $( e.target ).parent().hasClass( 'increase' ) || $( e.target ).hasClass( 'increase' ) ) {
128										if ( $maxQuantity && ( $maxQuantity === $currentQuantityValue || $currentQuantityValue > $maxQuantity ) ) {
129											$quantityBox.val( $maxQuantity );
130											return;
131										} else {
132											$quantityBox.val( $currentQuantityValue + $step );
133										}
134									} else {
135										if ( $minQuantity && ( $minQuantity === $currentQuantityValue || $currentQuantityValue < $minQuantity ) ) {
136											$quantityBox.val( $minQuantity );
137										} else if ( $currentQuantityValue > 0 ) {
138											$quantityBox.val( $currentQuantityValue - $step );
139										}
140									}
141
142									// Trigger change event.
143									$quantityBox.trigger( 'change' );
144								} );
145							} );
146						}
147					} );
148				}
149
150			} );
151		},
152
153		getElementorElementSettings: function( $scope ) {
154
155			if ( window.elementorFrontend && window.elementorFrontend.isEditMode() ) {
156				return JetWooBuilderCQS.getEditorElementSettings( $scope );
157			}
158
159			return $scope.data( 'settings' ) || {};
160
161		},
162
163		getEditorElementSettings: function( $scope ) {
164
165			var modelCID = $scope.data( 'model-cid' ),
166				elementData;
167
168			if ( ! modelCID ) {
169				return {};
170			}
171
172			if ( ! window.elementorFrontend.hasOwnProperty( 'config' ) ) {
173				return {};
174			}
175
176			if ( ! window.elementorFrontend.config.hasOwnProperty( 'elements' ) ) {
177				return {};
178			}
179
180			if ( ! window.elementorFrontend.config.elements.hasOwnProperty( 'data' ) ) {
181				return {};
182			}
183
184			elementData = window.elementorFrontend.config.elements.data[ modelCID ];
185
186			if ( ! elementData ) {
187				return {};
188			}
189
190			return elementData.toJSON();
191
192		},
193
194		reInitQuantitySelector: function ( element ) {
195			JetWooBuilderCQS.quantitySelector( $( element ).closest( '.elementor-element' ) );
196		}
197	};
198
199	$( window ).on( 'elementor/frontend/init', JetWooBuilderCQS.init );
200
201}( jQuery, window.elementorFrontend ) );

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.