1class rsQuickbookerJS { 2 constructor() { 3 this.documentReady = this.documentReady.bind( this ); 4 this.getReadyState = this.getReadyState.bind( this ); 5 this.refreshGuestValue = this.refreshGuestValue.bind( this ); 6 this.updateQuickbookerTimeout; 7 } 8 getReadyState() { 9 if ( document.readyState == 'complete' && window.jQuery ) { 10 this.documentReady(); 11 } else { 12 window.setTimeout( () => { 13 this.getReadyState(); 14 }, 100 ); 15 } 16 } 17 18 documentReady() { 19 console.info('customized quickbooker script is waiting'); 20 if ( $( '.number-of-guests-wrapper' ).length ) { 21 $( '.number-of-guests-wrapper' ).on( 'click', function () { 22 $( this ).find( '.number-of-guests-modal:not(.active)' ).addClass( 'active' ); 23 } ); 24 $( 'body' ).click( ( event ) => { 25 if ( !$( event.target ).closest( '.number-of-guests-wrapper' ).length ) { 26 $( '.number-of-guests-modal.active' ).removeClass( 'active' ); 27 28 } 29 } ); 30 $( '.number-of-guests-modal .minus' ).on( 'click', { param: this }, function ( e ) { 31 $( this ).closest( '.number-wrapper' ).find( 'input' ).val( ( ( parseInt( $( this ).closest( '.number-wrapper' ).find( 'input' ).val() ) - 1 ) >= 0 ) ? ( parseInt( $( this ).closest( '.number-wrapper' ).find( 'input' ).val() ) - 1 ) : 0 ); 32 e.data.param.refreshGuestValue( $( this ).closest( '.number-of-guests-modal' ) ); 33 if ( $( this ).closest( 'form' ).find( 'submit,button' ).length == 0 ) { 34 clearTimeout( e.data.param.updateQuickbookerTimeout ); 35 e.data.param.updateQuickbookerTimeout = window.setTimeout( () => { 36 $( this ).closest( 'form' ).submit(); 37 }, 1000 ); 38 } 39 } ); 40 $( '.number-of-guests-modal .plus' ).on( 'click', { param: this }, function ( e ) { 41 if ( typeof $( this ).closest( '.number-wrapper' ).find( 'input' ).attr( 'max' ) === typeof undefined || ( parseInt( $( this ).closest( '.number-wrapper' ).find( 'input' ).attr( 'max' ) ) > parseInt( $( this ).closest( '.number-wrapper' ).find( 'input' ).val() ) ) ) { 42 $(this).closest('.number-wrapper').find('input').val((parseInt($(this).closest('.number-wrapper').find('input').val()) + 1)); 43 e.data.param.refreshGuestValue($(this).closest('.number-of-guests-modal')); 44 if ($(this).closest('form').find('submit,button').length == 0) { 45 clearTimeout(e.data.param.updateQuickbookerTimeout); 46 e.data.param.updateQuickbookerTimeout = window.setTimeout(() => { 47 $(this).closest('form').submit(); 48 }, 1000); 49 } 50 } 51 } ); 52 } 53 54 // get form 55 let form = ''; 56 57 58 var easypick_custom_version = '1.4'; 59 60 // translation 61 let document_language = document.documentElement.lang, 62 language = 'de-DE', 63 translation = { 64 one: 'Tag', 65 other: 'Tage' 66 }; 67 if(document_language !== 'de') { 68 language = 'en-US'; 69 translation = { 70 one: 'day', 71 other: 'days' 72 }; 73 } 74 75 if ( $( '#arrival' ).length ) { 76 const pickerArrival = new easepick.create( { 77 element: '#arrival', 78 css: ['bundles/rapidskeleton/frontend/css/easypick.min.css', 'bundles/rapidskeleton/frontend/css/easypick.custom.css?v=' + easypick_custom_version], 79 zIndex: 10, 80 lang: language, 81 format: 'DD.MM.YYYY', 82 LockPlugin: { 83 minDate: new Date(), 84 minDays: 1, 85 selectForward: true, 86 }, 87 RangePlugin: { 88 elementEnd: '#departure', 89 locale: { 90 one: translation.one, 91 other: translation.other 92 } 93 }, 94 plugins: ['RangePlugin', 'LockPlugin'], 95 locale: { 96 nextMonth: '', 97 previousMonth: '', 98 }, 99 setup( picker ) { 100 picker.on( 'select', ( e ) => { 101 let element = this.element, 102 interalp_date_from = $('#interalp_date_from'), 103 interalp_date_to = $('#interalp_date_to'); 104 105 if(interalp_date_from.length) { 106 interalp_date_from.val(e.detail.start.format('YYYY') + '-' + e.detail.start.format('MM') + '-' + e.detail.start.format('DD')); 107 } 108 if(interalp_date_to.length) { 109 interalp_date_to.val(e.detail.end.format('YYYY') + '-' + e.detail.end.format('MM') + '-' + e.detail.end.format('DD')); 110 } 111 if ( $( element ).closest( 'form' ).find( 'submit,button' ).length == 0 ) {
112 clearTimeout( this.updateQuickbookerTimeout ); 113 this.updateQuickbookerTimeout = window.setTimeout( () => { 114 $( element ).closest( 'form' ).submit(); 115 }, 1000 ); 116 } 117 } ) 118 }, 119 } ); 120 121 form = $( '#arrival' ).parents('form'); 122 } 123 if ( $( '#header-qb-arrival' ).length ) { 124 const pickerArrivalHeader = new easepick.create( { 125 element: '#header-qb-arrival', 126 css: ['bundles/rapidskeleton/frontend/css/easypick.min.css', 'bundles/rapidskeleton/frontend/css/easypick.custom.css?v=' + easypick_custom_version], 127 zIndex: 10, 128 lang: language, 129 format: 'DD.MM.YYYY', 130 LockPlugin: { 131 minDate: new Date(), 132 minDays: 1, 133 selectForward: true, 134 }, 135 RangePlugin: { 136 elementEnd: '#header-qb-departure', 137 locale: { 138 one: translation.one, 139 other: translation.other 140 } 141 }, 142 plugins: ['RangePlugin', 'LockPlugin'], 143 locale: { 144 nextMonth: '', 145 previousMonth: '', 146 }, 147 setup( picker ) { 148 picker.on( 'select', ( e ) => { 149 let element = this.element; 150 if ( $( element ).closest( 'form' ).find( 'submit,button' ).length == 0 ) {
151 clearTimeout( this.updateQuickbookerTimeout ); 152 this.updateQuickbookerTimeout = window.setTimeout( () => { 153 $( element ).closest( 'form' ).submit(); 154 }, 1000 ); 155 } 156 } ) 157 }, 158 } ); 159 } 160 if ( $( '#arrival-filter' ).length ) { 161 const pickerArrivalFilter = new easepick.create( { 162 element: '#arrival-filter', 163 css: ['bundles/rapidskeleton/frontend/css/easypick.min.css', 'bundles/rapidskeleton/frontend/css/easypick.custom.css?v=' + easypick_custom_version], 164 zIndex: 10, 165 lang: language, 166 format: 'DD.MM.YYYY', 167 LockPlugin: { 168 minDate: new Date(), 169 minDays: 1, 170 selectForward: true, 171 }, 172 RangePlugin: { 173 elementEnd: '#departure-filter', 174 locale: { 175 one: translation.one, 176 other: translation.other 177 } 178 }, 179 plugins: ['RangePlugin', 'LockPlugin'], 180 locale: { 181 nextMonth: '', 182 previousMonth: '', 183 }, 184 setup( picker ) { 185 picker.on( 'select', ( e ) => { 186 let element = this.element; 187 if ( $( element ).closest( 'form' ).find( 'submit,button' ).length == 0 ) {
188 clearTimeout( this.updateQuickbookerTimeout ); 189 this.updateQuickbookerTimeout = window.setTimeout( () => { 190 $( element ).closest( 'form' ).submit(); 191 }, 1000 ); 192 } 193 } ) 194 }, 195 } ); 196 } 197 198 $( '.quickbooker input' ).on( 'change', function ( e ) { 199 if ( $( this ).closest( 'form' ).find( 'submit,button' ).length == 0 ) { 200 clearTimeout( this.updateQuickbookerTimeout ); 201 this.updateQuickbookerTimeout = window.setTimeout( () => { 202 $( this ).closest( 'form' ).submit(); 203 }, 1000 ); 204 } 205 } ); 206 this.refreshGuestValue( $( '.number-of-guests-modal' ) ); 207 208 // handling only for quickbooker in header 209 if(form.length && typeof form.attr('id') !== 'undefined' && form.attr('id') === 'quickbooker') { 210 form.on('submit', function (event) { 211 // if necessary 212 event.preventDefault(); 213 214 const target_form = event.target; 215 216 const formData = new FormData(target_form); 217 const noSubmit = [ 218 'FORM_SUBMIT', 219 'REQUEST_TOKEN', 220 'number-of-guests' 221 ]; 222 223 const params = new URLSearchParams(); 224 for (const [key, value] of formData.entries()) { 225 if(!noSubmit.includes(key)) { 226 if(key === 'children') { 227 if(value > 0) { 228 let children_value = '0'; 229 for (let i = 1; i < parseInt(value); i++) { 230 children_value += '-0'; 231 } 232 params.append(key, children_value); 233 } 234 } else { 235 params.append(key, value); 236 } 237 } 238 } 239 window.location.href = target_form.action + '?' + params.toString(); 240 }); 241 } 242 } 243 refreshGuestValue( modal ) { 244 // translation 245 let document_language = document.documentElement.lang, 246 translation = { 247 adult_short: 'Erw', 248 adult_short_plural: 'Erw', 249 adult_long: 'Erwachsener', 250 adult_long_plural: 'Erwachsene', 251 children: 'Kind', 252 children_plural: 'Kinder', 253 pets: 'Tier', 254 pets_plural: 'Tiere' 255 }; 256 if(document_language !== 'de') { 257 translation = { 258 adult_short: 'adult', 259 adult_short_plural: 'adults', 260 adult_long: 'adult', 261 adult_long_plural: 'adults', 262 children: 'child', 263 children_plural: 'children', 264 pets: 'pet', 265 pets_plural: 'pets' 266 }; 267 } 268 269 let numberOfGuests = ( modal.find( '[name="adults"]' ).val() > 0 ) ? (modal.find( '[name="adults"]' ).val() + ' ' + (parseInt(modal.find( '[name="adults"]' ).val()) === 1 ? translation.adult_short : translation.adult_short_plural)) : ''; 270 // numberOfGuests += ( modal.find( '[name="toddlers"]' ).val() > 0 ) ? ( ( numberOfGuests != '' ) ? ', ' : '' ) + modal.find( '[name="toddlers"]' ).val() + ' Kleinkinder' : ''; 271 /* only children, no additional toddlers field 272 * numberOfGuests += ( modal.find( '[name="children"]' ).val() > 0 || modal.find( '[name="toddlers"]' ).val() > 0 ) ? ( ( numberOfGuests !== '' ) ? ', ' : '' ) + ( parseInt( modal.find( '[name="children"]' ).val() ) + parseInt( modal.find( '[name="toddlers"]' ).val() ) ) + ' ' + ((parseInt( modal.find( '[name="children"]' ).val() ) + parseInt( modal.find( '[name="toddlers"]' ).val() )) === 1 ? translation.children : translation.children_plural) : ''; 273 */ 274 numberOfGuests += ( modal.find( '[name="children"]' ).val() > 0) ? ( ( numberOfGuests !== '' ) ? ', ' : '' ) + ( parseInt( modal.find( '[name="children"]' ).val() ) ) + ' ' + ((parseInt( modal.find( '[name="children"]' ).val() )) === 1 ? translation.children : translation.children_plural) : ''; 275 // numberOfGuests += ( modal.find( '[name="pets"]' ).val() > 0 ) ? ( ( numberOfGuests !== '' ) ? ', ' : '' ) + modal.find( '[name="pets"]' ).val() + ' ' + (parseInt(modal.find( '[name="pets"]' ).val()) === 1 ? translation.pets : translation.pets_plural) : ''; 276 277 $( '.number-of-guests-wrapper' ).each( function () { 278 if ( $( this ).find( '[name="number-of-guests"]' ).width() > 200 ) { 279 $( this ).find( '[name="number-of-guests"]' ).val( numberOfGuests.replace( translation.adult_long, translation.adult_short ) ); 280 } else { 281 $( this ).find( '[name="number-of-guests"]' ).val( numberOfGuests ); 282 } 283 } ); 284 } 285} 286 287const rs_quickbooker_class = new rsQuickbookerJS(); 288window.setTimeout( rs_quickbooker_class.getReadyState, 100 );
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.