PageSourceSearch

https://valeille.fr/wp-content/plugins/booking/js/wpbc_time-selector.js?ver=10.3

js valeille.fr collected 2026-10-02 21:34:47 UTC 3,691 bytes, 123 lines download raw bytes

1//FixIn: 8.7.11.10
2(function ( $ ){
3
4	$.fn.extend( {
5
6		wpbc_timeselector: function (){
7
8			var times_options = [];
9
10			this.each( function (){
11
12				var el = $( this );
13
14				// On new days click we are searching for old time items,  and remove them from this booking form
15				if ( el.parent().find( '.wpbc_times_selector' ).length ) {
16					el.parent().find( '.wpbc_times_selector' ).remove();
17				}
18
19				el.find( 'option' ).each( function ( ind ){
20
21					times_options.push( {
22										  title   : jQuery( this ).text()
23										, value   : jQuery( this ).val()
24										, disabled: jQuery( this ).is( ':disabled' )
25										, selected: jQuery( this ).is( ':selected' )
26										} );
27
28				} );
29
30				var times_options_html = $.fn.wpbc_timeselector.format( times_options );
31
32				el.after( times_options_html );
33
34				el.next('.wpbc_times_selector').find('div').not('.wpbc_time_picker_disabled').on( "click", function() {
35
36					// Get data value of clicked DIV time-slot
37					var selected_value = jQuery( this ).attr( 'data-value' );
38
39					// Remove previos selected class
40					jQuery( this ).parent( '.wpbc_times_selector' ).find( '.wpbc_time_selected' ).removeClass( 'wpbc_time_selected' );
41					// Set  time item with  selected Class
42					jQuery( this ).addClass('wpbc_time_selected');
43
44					el.find( 'option' ).prop( 'selected', false );
45					// Find option in selectbox with this value
46					el.find( 'option[value="' + selected_value + '"]' ).prop( 'selected', true );
47
48					el.trigger( 'change' );
49				});
50
51				el.hide();
52
53				times_options = [];
54			} );
55
56			return this;				// Chain
57		}
58	} );
59
60
61	// Get HTML structure of times selection
62	$.fn.wpbc_timeselector.format = function ( el_arr ) {
63
64		var select_div = '';
65		var css_class='';
66
67		$.each( el_arr, function (index, el_item){
68
69			if ( !el_item.disabled ){
70
71				if (el_item.selected){
72					css_class = 'wpbc_time_selected';
73				} else {
74					css_class = '';
75				}
76
77				select_div += '<div '
78									+ ' data-value="' + el_item.value + '" '
79									+ ' class="' + css_class + '" '
80					         + '>'
81									+ el_item.title
82							 + '</div>'
83			} else {
84				// Uncomment row bellow to Show booked time slots as unavailable RED slots		//FixIn: 9.9.0.2
85				// select_div += '<div class="wpbc_time_picker_disabled">' + el_item.title + '</div>';
86			}
87
88		} );
89
90		if ( '' == select_div ){
91			select_div = '<span class="wpbc_no_time_pickers">'
92							+ 'No available times'
93					   + '</span>'
94		}
95		return '<div class="wpbc_times_selector">' + select_div + '</div>';
96	}
97
98
99})( jQuery );
100
101
102
103jQuery(document).ready(function(){
104
105//	 setTimeout( function ( ) {					// Need to  have some delay  for loading of all  times in Garbage
106
107			// Load after page loaded
108			jQuery( 'select[name^="rangetime"]' ).wpbc_timeselector();
109			jQuery( 'select[name^="starttime"]' ).wpbc_timeselector();
110			jQuery( 'select[name^="endtime"]' ).wpbc_timeselector();
111			jQuery( 'select[name^="durationtime"]' ).wpbc_timeselector();
112
113			// This hook loading after each day selection																//FixIn: 8.7.11.9
114			jQuery( ".booking_form_div" ).on( 'wpbc_hook_timeslots_disabled', function ( event, bk_type, all_dates ){
115				jQuery( '#booking_form_div' + bk_type + ' select[name^="rangetime"]' ).wpbc_timeselector();
116				jQuery( '#booking_form_div' + bk_type + ' select[name^="starttime"]' ).wpbc_timeselector();
117				jQuery( '#booking_form_div' + bk_type + ' select[name^="endtime"]' ).wpbc_timeselector();
118				jQuery( '#booking_form_div' + bk_type + ' select[name^="durationtime"]' ).wpbc_timeselector();
119			} );
120
121//	}, 1000 );
122
123});

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.