PageSourceSearch

https://www.tifviking.no/wp-content/plugins/booking.personal.8.8.1/js/wpbc_time-selector.js?ver=8.8.1

js tifviking.no collected 2026-10-01 12:26:31 UTC 3,454 bytes, 120 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').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			}
84
85		} );
86
87		if ( '' == select_div ){
88			select_div = '<span class="wpbc_no_time_pickers">'
89							+ 'No available times'
90					   + '</span>'
91		}
92		return '<div class="wpbc_times_selector">' + select_div + '</div>';
93	}
94
95
96})( jQuery );
97
98
99
100jQuery(document).ready(function(){
101
102//	 setTimeout( function ( ) {					// Need to  have some delay  for loading of all  times in Garbage
103
104			// Load after page loaded
105			jQuery( 'select[name^="rangetime"]' ).wpbc_timeselector();
106			jQuery( 'select[name^="starttime"]' ).wpbc_timeselector();
107			jQuery( 'select[name^="endtime"]' ).wpbc_timeselector();
108			jQuery( 'select[name^="durationtime"]' ).wpbc_timeselector();
109
110			// This hook loading after each day selection																//FixIn: 8.7.11.9
111			jQuery( ".booking_form_div" ).on( 'wpbc_hook_timeslots_disabled', function ( event, bk_type, all_dates ){
112				jQuery( '#booking_form_div' + bk_type + ' select[name^="rangetime"]' ).wpbc_timeselector();
113				jQuery( '#booking_form_div' + bk_type + ' select[name^="starttime"]' ).wpbc_timeselector();
114				jQuery( '#booking_form_div' + bk_type + ' select[name^="endtime"]' ).wpbc_timeselector();
115				jQuery( '#booking_form_div' + bk_type + ' select[name^="durationtime"]' ).wpbc_timeselector();
116			} );
117
118//	}, 1000 );
119
120});

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.