PageSourceSearch

https://nirshop.it/wp-content/plugins/back-in-stock-notifier-for-w…/assets/js/cwg-popup.min.js?ver=1791526423

js nirshop.it collected 2026-10-10 00:36:43 UTC 7,472 bytes, 248 lines download raw bytes

1"use strict";
2var get_bot_type = cwginstock.get_bot_type;
3var recaptcha_enabled = cwginstock.enable_recaptcha;
4var is_v3_recaptcha = cwginstock.is_v3_recaptcha;
5var recaptcha_site_key = cwginstock.recaptcha_site_key;
6// turnstile
7var turnstile_enabled = cwginstock.enable_turnstile;
8var turnstile_site_key = cwginstock.turnstile_site_key;
9
10var gtoken = '';
11var cwg_popup_language = cwginstock.current_lang || cwginstock.wpml_current_lang || cwginstock.polylang_current_lang || '';
12
13if (typeof wc_bulk_variations_params !== 'undefined') {
14	document.addEventListener(
15		'click',
16		function (event) {
17			if (event.target.matches('.cwg_popup_submit')) {
18				console.log(event.target.dataset.product_id);
19				console.log('Captured click before stopPropagation!');
20				var e = event.target;
21				jQuery.blockUI({ message: null });
22				var product_id = e.dataset.product_id;
23				var variation_id = e.dataset.variation_id;
24				var quantity = e.dataset.quantity
25				var security = e.dataset.security
26
27				var data = {
28					action: 'cwg_trigger_popup_ajax',
29					product_id: product_id,
30					variation_id: variation_id,
31					quantity: quantity,
32					security: security,
33					cwg_lang: cwg_popup_language
34				};
35				if (get_bot_type == 'recaptcha' && recaptcha_enabled == '1' && is_v3_recaptcha == 'yes') {
36					popup_notifier.popup_generate_v3_response(this);
37				} else {
38					popup_notifier.perform_ajax(data);
39				}
40				return false;
41			}
42		},
43		true // This enables the capturing phase
44	);
45}
46
47var popup_notifier = {
48	init: function () {
49		jQuery(document).on(
50			'click',
51			'.cwg_popup_submit',
52			function () {
53
54				jQuery.blockUI({ message: null });
55				var current = jQuery(this);
56				var product_id = current.attr('data-product_id');
57				var variation_id = current.attr('data-variation_id');
58				var quantity = current.attr('data-quantity');
59				var security = current.attr('data-security');
60
61				var data = {
62					action: 'cwg_trigger_popup_ajax',
63					product_id: product_id,
64					variation_id: variation_id,
65					quantity: quantity,
66					security: security,
67					cwg_lang: cwg_popup_language
68				};
69				if (get_bot_type == 'recaptcha' && recaptcha_enabled == '1' && is_v3_recaptcha == 'yes') {
70					popup_notifier.popup_generate_v3_response(this);
71				} else {
72					popup_notifier.perform_ajax(data);
73				}
74				return false;
75			}
76		);
77	},
78	popup_generate_v3_response: function (currentel) {
79		if (get_bot_type == 'recaptcha' && recaptcha_enabled == '1' && is_v3_recaptcha == 'yes') {
80			grecaptcha.ready(
81				function () {
82					grecaptcha.execute(recaptcha_site_key, { action: 'popup_form' }).then(
83						function (token) {
84							console.log(token);
85
86							var current = jQuery(currentel);
87							var product_id = current.attr('data-product_id');
88							var variation_id = current.attr('data-variation_id');
89							var quantity = current.attr('data-quantity');
90
91							var data = {
92								action: 'cwg_trigger_popup_ajax',
93								product_id: product_id,
94								variation_id: variation_id,
95								quantity: quantity,
96								security: token
97							};
98							popup_notifier.perform_ajax(data);
99							gtoken = token;
100						}
101					);
102				}
103			);
104		}
105	},
106	/**
107	 * Render the returned form inside a native modal (no SweetAlert).
108	 * Used when a custom popup design is selected in settings.
109	 *
110	 * @since 7.4.0
111	 */
112	render_native_modal: function (html, design) {
113		// Remove any modal left over from a previous open.
114		jQuery('.cwg-modal-overlay').remove();
115
116		var skin = 'cwg-modal-' + String(design).replace('modal_', '');
117		var overlay = document.createElement('div');
118		overlay.className = 'cwg-modal-overlay ' + skin;
119		overlay.setAttribute('role', 'dialog');
120		overlay.setAttribute('aria-modal', 'true');
121
122		var box = document.createElement('div');
123		box.className = 'cwg-modal-box';
124
125		var close = document.createElement('button');
126		close.type = 'button';
127		close.className = 'cwg-modal-close';
128		close.innerHTML = '×';
129		close.setAttribute('aria-label', (typeof cwginstock !== 'undefined' && cwginstock.popup_close_label) ? cwginstock.popup_close_label : 'Close');
130
131		var content = document.createElement('div');
132		content.className = 'cwg-modal-content';
133		content.innerHTML = html;
134
135		box.appendChild(close);
136		box.appendChild(content);
137		overlay.appendChild(box);
138		document.body.appendChild(overlay);
139
140		function closeModal() {
141			overlay.classList.remove('cwg-modal-visible');
142			jQuery(document).trigger('cwginstock_popup_close_callback');
143			setTimeout(function () { jQuery(overlay).remove(); }, 250);
144			document.removeEventListener('keydown', onKey);
145		}
146		function onKey(e) { if (e.key === 'Escape') { closeModal(); } }
147
148		close.addEventListener('click', closeModal);
149		overlay.addEventListener('click', function (e) { if (e.target === overlay) { closeModal(); } });
150		document.addEventListener('keydown', onKey);
151
152		// Render bot protection widgets inside the modal, same as the SweetAlert flow.
153		if ('recaptcha' == get_bot_type) {
154			if ('1' == recaptcha_enabled) {
155				jQuery(overlay).find('.g-recaptcha').before('<div id="cwg-google-recaptcha"></div>');
156				jQuery(overlay).find('.g-recaptcha').remove();
157			}
158		} else if ('1' == turnstile_enabled && typeof turnstile !== 'undefined') {
159			try {
160				turnstile.render(
161					jQuery(overlay).find('.cf-turnstile')[0],
162					{
163						sitekey: turnstile_site_key,
164						theme: 'light',
165						callback: function (token) { cwginstock_turnstile_callback(token); }
166					}
167				);
168			} catch (e) { }
169		}
170
171		// Trigger the transition on the next frame so it animates in.
172		requestAnimationFrame(function () { overlay.classList.add('cwg-modal-visible'); });
173		jQuery(document).trigger('cwginstock_popup_open_callback');
174	},
175
176	perform_ajax: function (data) {
177		jQuery.ajax(
178			{
179				type: "post",
180				url: cwginstock.default_ajax_url,
181				data: data,
182				success: function (msg) {
183					jQuery.unblockUI();
184					var popup_design = (typeof cwginstock !== 'undefined' && cwginstock.popup_design) ? cwginstock.popup_design : 'sweetalert';
185					if (popup_design !== 'sweetalert') {
186						popup_notifier.render_native_modal(msg, popup_design);
187						return;
188					}
189					Swal.fire(
190						{
191							html: msg,
192							showCloseButton: true,
193							showConfirmButton: false,
194							willOpen: function () {
195								if ('recaptcha' == get_bot_type) {
196									if ('1' == recaptcha_enabled) {
197										jQuery('.g-recaptcha').before('<div id="cwg-google-recaptcha"></div>');
198										jQuery('.g-recaptcha').remove();
199									}
200								} else {
201									if ('1' == turnstile_enabled) {
202										turnstile.render(
203											'.cf-turnstile',
204											{
205												sitekey: turnstile_site_key,
206												theme: 'light',
207												callback: function (token) {
208													cwginstock_turnstile_callback(token);
209												},
210											}
211										);
212									}
213								}
214							},
215							didOpen: function () {
216								jQuery(document).trigger('cwginstock_popup_open_callback');
217							},
218							willClose: function () {
219								jQuery(document).trigger('cwginstock_popup_close_callback');
220							},
221						}
222					);
223
224				},
225				error: function (request, status, error) {
226					jQuery.unblockUI();
227				}
228			}
229		);
230	},
231};
232popup_notifier.init();
233
234
235jQuery(document).on(
236	'cwginstock_popup_open_callback',
237	function () {
238		instock_notifier.onloadcallback();
239		instock_notifier.initialize_phone();
240	}
241);
242
243jQuery(document).on(
244	'cwginstock_popup_close_callback',
245	function () {
246		instock_notifier.resetcallback();
247	}
248);

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.