PageSourceSearch

https://www.seehotel.at/wp-content/plugins/woocommerce-pdf-voucher…/js/woo-vou-code-details.js?ver=5.2.3

js seehotel.at collected 2026-10-07 01:37:13 UTC 15,115 bytes, 433 lines download raw bytes

1"use strict";
2
3jQuery( document ).ready( function( $ ) { 
4	
5	// JS foe showing tooltip on voucher code details page
6	 var tiptip_args = {
7	    'attribute': 'data-tip',
8	    'fadeIn': 50,
9	    'fadeOut': 50,
10	    'delay': 200
11	   };
12	 $( '.woocommerce-help-tip' ).tipTip( tiptip_args );
13
14	// Edit recipient details on voucher details page
15	$('#woo-vou-voucher-recipient-details .woo-vou-recipient-value-edit').hide();
16	$( document ).on( 'click', '#woo-vou-voucher-recipient-details .woo-vou-recipient-details-title a.edit_recipient_details', function() {
17		$('#woo-vou-voucher-recipient-details table.woo-vou-history-table tr.woo-vou-history-title-row th.woo-vou-uneditable').hide();
18		$('#woo-vou-voucher-recipient-details .woo-vou-recipient-value').hide();
19		$('#woo-vou-voucher-recipient-details .woo-vou-recipient-value-edit').show();
20		$(this).hide();
21		return false;
22	});
23 
24	//repeater field add more
25	jQuery( document ).on( "click", ".woo-vou-info-repeater-add", function() {
26		
27	
28		jQuery(this).prev('div.woo-vou-info-repater-block:first')
29			.clone(true,true)
30			.insertAfter('.woo-vou-info-repeat div.woo-vou-info-repater-block:last');
31			
32		jQuery(this).parent().find('div.woo-vou-info-repater-block:last input').val('');
33		jQuery(this).parent().find('div.woo-vou-info-repater-block:last .woo-vou-repeater-remove').show();
34		jQuery(this).trigger( "afterclone", [ jQuery(this) ] );
35	});
36	//remove repeater field
37	jQuery( document ).on( "click", ".woo-vou-repeater-remove", function() {
38	   jQuery(this).parent('.woo-vou-info-repater-block').remove();
39	});
40	
41	
42
43	// Code for validating data while editing recipient infomation on voucher code details page
44	$(document).on('click', '#woo_vou_recipient_details_update', function(e){
45
46		e.preventDefault();
47		var error = false;
48
49		$('.woo-vou-recipient-error').hide();
50		$('.woo-vou-recipient-invalid-email-err-message').detach();
51		$('.woo-vou-recipient-invalid-giftdate-err-message').detach();
52
53		$('table.woo-vou-edit-history-table td').each(function(){
54			if($(this).find(':first-child').data('required') && !$.trim($(this).find(':first-child').val())){
55
56				$(this).find('.woo-vou-recipient-error').show();
57				error = true;
58			}
59		});
60
61		if(!error){
62
63			var data = {
64							action				: 'woo_vou_check_redeem_info',
65							product_id			: $('input#woo_vou_product_id').val()
66						};
67
68			$('.woo_vou_cust_email_field').each(function(){
69
70				data[$(this).data('dash-val')] = $(this).val();
71			});
72
73			$('.woo_vou_cust_date_field').each(function(){
74
75				data[$(this).data('dash-val')] = $(this).val();
76			});
77
78			//call ajax to change voucher code expiry date
79			jQuery.post( WooVouCode.ajaxurl, data, function( response ) {
80
81				var response_data = jQuery.parseJSON(response);
82				if(response_data.valid){
83					$('form.woo-vou-recipient-details-edit-form').submit();
84				} else {
85
86					$.each( response_data.not_valid_fields, function( key, value ) {
87
88						$(document).find('#_woo_vou_'+key).after(value);
89						$(document).find('#_woo_vou_'+key).next().show();
90					});
91				}
92			});
93		}
94	});
95
96	$( document ).on( 'click', '#woo-vou-voucher-recipient-details .woo-vou-recipient-details-edit-cancel', function() {
97		$('#woo-vou-voucher-recipient-details table.woo-vou-history-table tr.woo-vou-history-title-row th.woo-vou-uneditable').show();
98		$('#woo-vou-voucher-recipient-details .woo-vou-recipient-value').show();
99		$('#woo-vou-voucher-recipient-details .woo-vou-recipient-value-edit').hide();
100		$('#woo-vou-voucher-recipient-details .woo-vou-recipient-details-title a.edit_recipient_details').show();
101		return false;
102	});
103
104	// Set datepicker for Recipient Gift Date
105	$('.woo_vou_cust_date_field').each(function(){
106		var format = $(this).attr('rel');
107		$(this).datepicker({
108					dateFormat : format,
109				});
110	});
111
112	// Edit Voucher Information on front end voucher details page
113	$('#woo-vou-voucher-details .woo-vou-history-value-row-edit').hide();
114	$( document ).on( 'click', '#woo-vou-voucher-details a.edit_history_details', function() {
115
116		if(!WooVouCode.vou_change_expiry_date || WooVouCode.vou_change_expiry_date == 'no'){
117			$('#woo-vou-voucher-details tr.woo-vou-history-title-row th:nth-child(3)').hide();
118			$('#woo-vou-voucher-details tr.woo-vou-history-value-row-edit td:nth-child(3)').hide();
119		}
120		$('#woo-vou-voucher-details .woo-vou-history-value-row').hide();
121		$('#woo-vou-voucher-details .woo-vou-history-value-row-edit').show();
122		$('#woo-vou-voucher-details .woo-vou-history-value-row-edit').closest("table").addClass("woo-vou-voucher-details-edit");
123		$(this).hide();
124		return false;
125	});
126
127	$( document ).on( 'click', '#woo-vou-voucher-details .woo-vou-voucher-information-edit-cancel', function() {
128		$('#woo-vou-voucher-details tr.woo-vou-history-title-row th:nth-child(3)').show();
129		$('#woo-vou-voucher-details .woo-vou-history-value-row').show();
130		$('#woo-vou-voucher-details .woo-vou-history-value-row-edit').hide();
131		$('#woo-vou-voucher-details a.edit_history_details').show();
132		$('#woo-vou-voucher-details .woo-vou-history-value-row-edit').closest("table").removeClass("woo-vou-voucher-details-edit");
133		return false;
134	});
135
136	// Edit Voucher Extra Note on backend voucher details page
137	$('#woo-vou-voucher-extra-note .woo-vou-extra-note-row-edit').hide();
138	$( document ).on( 'click', '#woo-vou-voucher-extra-note a.edit_extra_note', function() {
139		$('#woo-vou-voucher-extra-note .woo-vou-extra-note-row').hide();
140		$('#woo-vou-voucher-extra-note .woo-vou-extra-note-row-edit').show();
141		$(this).hide();
142		return false;
143	});
144	$( document ).on( 'click', '#woo-vou-voucher-extra-note .woo-vou-extra-note-edit-cancel', function() {
145		$('#woo-vou-voucher-extra-note .woo-vou-extra-note-row').show();
146		$('#woo-vou-voucher-extra-note .woo-vou-extra-note-row-edit').hide();
147		$('#woo-vou-voucher-extra-note a.edit_extra_note').show();
148		return false;
149	});
150
151	// Date time picher of expires date
152	if( $(".woo-vou-history-value-row-edit .woo-vou-expires-date").length ) {
153		
154		jQuery('.woo-vou-history-value-row-edit .woo-vou-expires-date').each( function() {
155	
156			var jQuerythis  = jQuery(this),
157		    format = jQuerythis.attr('rel'),
158		    MinDate = jQuerythis.data('min-date'),
159		    id = jQuerythis.attr('id');
160	
161		  		jQuerythis.datetimepicker({
162					dateFormat : format,
163					timeFormat: "HH:mm",
164					minDate: MinDate,
165				});
166		});
167	}
168	
169	if( $(".woo-vou-history-value-row-edit .woo-vou-start-date").length ) {
170		
171		jQuery('.woo-vou-history-value-row-edit .woo-vou-start-date').each( function() {
172	
173			var jQuerythis  = jQuery(this),
174		    format = jQuerythis.attr('rel'),
175		    MaxDate = jQuerythis.data('max-date'),
176		    id = jQuerythis.attr('id');
177	
178		  		jQuerythis.datetimepicker({
179					dateFormat : format,
180					timeFormat: "HH:mm",
181					maxDate: MaxDate,
182				});
183		});
184	}
185
186	// WP 3.5+ uploader
187	// Set media uploader for voucher logo selection
188	if( $(".woo-vou-meta-upload_image_button").length ) {
189		var formfield1;
190		var formfield2;
191    
192		jQuery( document ).on('click','.woo-vou-meta-upload_image_button',function(e){
193
194			e.preventDefault();
195			formfield1 = jQuery(this).prev();
196			formfield2 = jQuery(this).prev().prev();
197			var button = jQuery(this);
198
199			if(typeof wp == "undefined" || WooVouCode.new_media_ui != '1' ){// check for media uploader//
200				 
201				  tb_show('', 'media-upload.php?post_id='+ jQuery('#post_ID').val() + '&type=image&TB_iframe=true');
202				  //store old send to editor function
203				  window.restore_send_to_editor = window.send_to_editor;
204				  //overwrite send to editor function
205				  window.send_to_editor = function(html) {
206					
207					imgurl = jQuery('img',html).attr('src');
208					
209					if(jQuery('img',html).attr('class')) {
210						
211						img_calsses = jQuery('img',html).attr('class').split(" ");
212						att_id = '';
213						jQuery.each(img_calsses,function(i,val){
214						  if (val.indexOf("wp-image") != -1){
215							att_id = val.replace('wp-image-', "");
216						  }
217						});
218				
219						jQuery(formfield2).val(att_id);
220					}
221					
222					jQuery(formfield1).val(imgurl);
223					wooVouLoadImagesMuploader();
224					tb_remove();
225					//restore old send to editor function
226					window.send_to_editor = window.restore_send_to_editor;
227				  }
228				  return false;
229				  
230			} else {
231				
232				
233				var file_frame;
234				
235				// If the media frame already exists, reopen it.
236				if ( file_frame ) {
237					file_frame.open();
238				  return;
239				}
240		
241				// Create the media frame.
242				file_frame = wp.media.frames.file_frame = wp.media({
243					frame: 'post',
244					state: 'insert',
245					title: button.data( 'uploader_title' ),
246					button: {
247						text: button.data( 'uploader_button_text' ),
248					},
249					multiple: true  // Set to true to allow multiple files to be selected
250				});
251		
252				file_frame.on( 'menu:render:default', function(view) {
253					// Store our views in an object.
254					var views = {};
255		
256					// Unset default menu items
257					view.unset('library-separator');
258					view.unset('gallery');
259					view.unset('featured-image');
260					view.unset('embed');
261		
262					// Initialize the views in our view object.
263					view.set(views);
264				});
265		
266				// When an image is selected, run a callback.
267				file_frame.on( 'insert', function() {
268		
269					// Get selected size from media uploader
270					var selected_size = $('.attachment-display-settings .size').val();
271					
272					var selection = file_frame.state().get('selection');
273					selection.each( function( attachment, index ) {
274						attachment = attachment.toJSON();
275						
276						// Selected attachment url from media uploader
277						var attachment_url = attachment.sizes[selected_size].url;
278						
279						if(index == 0){
280							// place first attachment in field
281							jQuery(formfield2).val(attachment.id);
282							jQuery(formfield1).val(attachment_url);
283							wooVouLoadImagesMuploader();
284						
285						} else{
286							
287							jQuery(formfield2).val(attachment.id);
288							jQuery(formfield1).val(attachment_url);
289							wooVouLoadImagesMuploader();
290						}
291					});
292				});
293		
294				// Finally, open the modal
295				file_frame.open();
296			}
297			
298		});
299		
300	  //new image upload field
301	  function wooVouLoadImagesMuploader(){
302		jQuery(".mupload_img_holder").each(function(i,v){
303		  if (jQuery(this).next().next().val() != ''){
304			if (!jQuery(this).children().size() > 0){
305			  jQuery(this).append('<img src="' + jQuery(this).next().next().val() + '" style="height: 150px;width: 150px;" />');
306			  jQuery(this).next().next().next().val("Delete Image");
307			  jQuery(this).next().next().next().removeClass('woo-vou-meta-upload_image_button').addClass('woo-vou-meta-delete_image_button');
308			}
309		  }
310		});
311	  }
312	  
313	  wooVouLoadImagesMuploader();
314	  //delete img button
315	  
316	  jQuery( document ).on('click','.woo-vou-meta-delete_image_button',function(e){
317		jQuery(this).prev().val('');
318		jQuery(this).prev().prev().val('');
319		jQuery(this).prev().prev().prev().html('');
320		jQuery(this).val("Upload Image");
321		jQuery(this).removeClass('woo-vou-meta-delete_image_button').addClass('woo-vou-meta-upload_image_button');
322	  });
323	 
324	} // end of vocher logo uploader
325
326	//click on  button
327	$(document).on('focusout', '.woo-vou-website-url', function(e) {
328
329		e.preventDefault();
330		woo_vou_toggle_site_url_err();
331	});
332
333	$(document).on('click', '#woo_vou_voucher_information_update', function(e) {
334
335		var err = false;
336		err = woo_vou_toggle_site_url_err();
337
338		if( err == true ) {
339
340			e.preventDefault();
341		}
342	});
343
344	$(document).on('click', '.woo-vou-send-gift-email', function(){
345
346    	$('div.woo-vou-popup-content').show();
347    	$('#woo_vou_recipient_email').val($('#woo_vou_send_gift_recipient_email').val());
348    	$('div.woo-vou-popup-overlay').show();
349    });
350
351    $(document).on('click', '.woo-vou-close-button, .woo-vou-expiry-date-overlay', function(){
352    	$('div.woo-vou-popup-content').hide();
353    	$('div.woo-vou-popup-overlay').hide();
354    });
355
356    $(document).on('click', '.woo-vou-send-gift-notification-email', function(e){
357
358    	$('.woo-vou-recipient-email-message').hide().html('');
359    	var email_list 			= $(document).find('table.woo-vou-voucher-gift-notification-table input#woo_vou_recipient_email').val();
360
361    	if( !$.trim(email_list) ) {
362    		$('.woo-vou-recipient-email-message').addClass('woo-vou-recipient-email-errors').removeClass('woo-vou-recipient-email-success');
363    		$('.woo-vou-recipient-email-message').html(WooVouCode.invalid_email);
364    		$('.woo-vou-recipient-email-message').show();
365    		return false;
366    	}
367
368    	$(document).find('.woo-vou-send-gift-notification-email').hide();
369    	$(document).find('span.woo-vou-loader-wrap').show();
370    	$(document).find('img.woo-vou-loader').show();
371    	var first_name 			= $('#woo_vou_send_gift_first_name').val();
372    	var last_name			= $('#woo_vou_send_gift_last_name').val();
373    	var recipient_name  	= $('#woo_vou_send_gift_recipient_name').val();
374    	var recipient_email 	= $('#woo_vou_send_gift_recipient_email').val();
375    	var recipient_message	= $('#woo_vou_send_gift_recipient_message').val();
376    	var order_id			= $('#woo_vou_order_id').val();
377    	var item_id				= $('#woo_vou_item_id').val();
378    	var product_id			= $('#woo_vou_product_id').val();
379    	var code_id				= $('#woo_vou_code_id').val();
380
381    	var data = {
382						action				: 'woo_vou_resend_gift_notification_email',
383						email_list			: email_list,
384						first_name			: first_name,
385						last_name			: last_name,
386						recipient_name		: recipient_name,
387						recipient_email		: recipient_email,
388						recipient_message 	: recipient_message,
389						order_id			: order_id,
390						item_id				: item_id,
391						product_id			: product_id,
392						code_id				: code_id,
393						security 			: WooVouCode.security,
394					};
395
396		//call ajax to save voucher code
397		jQuery.post( WooVouCode.ajaxurl, data, function( response ) {
398
399			var response_data = jQuery.parseJSON(response);
400			$(document).find('.woo-vou-send-gift-notification-email').show();
401    		$(document).find('span.woo-vou-loader-wrap').hide();
402    		$(document).find('img.woo-vou-loader').hide();
403
404			if( response_data.success ) {
405			
406				$('.woo-vou-recipient-email-message').removeClass('woo-vou-recipient-email-errors').addClass('woo-vou-recipient-email-success');
407				$('.woo-vou-recipient-email-message').html(response_data.success).show();
408				window.location.replace(document.location.href+"&message=woo_vou_gift_email_sent");
409			} else {
410				$('.woo-vou-recipient-email-message').addClass('woo-vou-recipient-email-errors').removeClass('woo-vou-recipient-email-success');
411    			$('.woo-vou-recipient-email-message').html(response_data.error).show();
412			}
413		});
414    });
415
416	function woo_vou_toggle_site_url_err(){
417
418		var err = false;
419		var url_pattern	= /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
420		var site_url = $('input.woo-vou-website-url').val();
421
422		jQuery('input.woo-vou-website-url').next().detach();
423
424		if( $.trim(site_url) && !url_pattern.test( $('input.woo-vou-website-url').val() ) ) {
425
426			jQuery('input.woo-vou-website-url').parent().append( '<div class="woo-vou-site-url-error">'+ WooVouCode.invalid_url +'</div>' );
427			jQuery('input.woo-vou-website-url').val('');
428			err = true;
429		}
430
431		return err;
432	}
433});

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.