1/*$(document).ready(function () { 2 Filter.init(); 3 Excursion.init(); 4});*/ 5function start_excursion_module(){ 6 Filter.init(); 7 Excursion.init(); 8} 9 10let Excursion = { 11 _peopleAmount: 1, 12 _season: 1, 13 _priceTransfer: {}, 14 _priceExcursion: {}, 15 _rentTime : 0, 16 _isPackage : 0, 17 _cars : {}, 18 _activeModule : 'desktop', 19 20 _id_excursion: 0, 21 languageKoeff : 1.07, 22 23 init: function () { 24 this._id_excursion = parseInt($('#excursion-id_excursion').val()); 25 26 $('.request-from-booking-form').on('click', function () { 27 let type = 'desktop', version = 1; 28 if ($(this).hasClass('request-from-booking-form__mobile')) { 29 type = 'mobile'; 30 version = 2; 31 } 32 33 let options = {}; 34 let transportation = $('input[name=Transportation-'+type+']:checked').val(); 35 let lang = $('#dropdownLanguage-'+type+'Value').val(); 36 if (transportation !== undefined) options['transport'] = transportation; 37 if (lang !== '') options['lang'] = lang; 38 39 //console.info(type); 40 $('#QuickRequestModal #request_travellers').val($('#people_amount_' + type).val()); 41 $('#QuickRequestModal input[name*=date_start]').val($('#tour-date-' + type).val()); 42 $('#QuickRequestModal #request-options').val(JSON.stringify(options)); 43 $('#QuickRequestModal #request-id_excursion').val($('#excursion-id_excursion').val()); 44 $('#QuickRequestModal #request-source').val(2); 45 $('#QuickRequestModal #request-version').val(version); 46 $('#QuickRequestModal').modal('show'); 47 }); 48 49 this.initBookingForm('excursion-form'); 50 this.initBookingForm('excursion-form-mobile'); 51 this.firstFormChanged(); 52 }, 53 54 initBookingForm: function (id) { 55 let form = $('#' + id); 56 let self = this; 57 58 form.find('input').on('change', function () { 59 self.firstFormChanged(); 60 }); 61 form.find('.btn').on('click', function () { 62 self.firstFormChanged(); 63 }); 64 /*form.find('.dropdown-item').on('click', function () { 65 self.firstFormChanged(); 66 });*/ 67 68 form.on('beforeSubmit', function () { 69 if (self.checkFirstForm()){ 70 let form = $(this); 71 let data = form.serialize(); 72 $.ajax({ 73 // ÐеÑод оÑпÑавки даннÑÑ (Ñип запÑоÑа) 74 type: 'POST', 75 // URL Ð´Ð»Ñ Ð¾ÑпÑавки запÑоÑа 76 url: W_ABSPATH + '/cart/add', 77 // ÐаннÑе ÑоÑÐ¼Ñ 78 data: data 79 }).done(function (data) { 80 if (data.error == null) { 81 // ÐÑли оÑÐ²ÐµÑ ÑеÑвеÑа ÑÑпеÑно полÑÑен 82 83 //form.parents('.modal').modal('toggle'); 84 //$('#ThanksModal').modal('toggle'); 85 //window.location = data.data.url; 86 //Alert.show(data.data.html); 87 Alert.showType('cart_added'); 88 $('.navbar-nav .icon-shopping_card').addClass('icon-shopping_card-full').removeClass('icon-shopping_card'); 89 90 } else { 91 // ÐÑли пÑи обÑабоÑке даннÑÑ Ð½Ð° ÑеÑвеÑе пÑоизоÑла оÑибка 92 Alert.show(data.error); 93 94 } 95 }).fail(function () { 96 // ÐÑли пÑоизоÑла оÑибка пÑи оÑпÑавке запÑоÑа 97 Alert.show(translate['Failed']); 98 99 }); 100 } 101 102 return false; 103 }); 104 105 }, 106 107 checkFirstForm: function () { 108 Hash.saveEvent('Cart action', 'Check excursion'); 109 110 let transportType = $(":radio[name=Transportation-"+this._activeModule+"]:checked").val(); 111 112 if (transportType === undefined) transportType = $(":hidden[name=Transportation-"+this._activeModule+"]").val(); 113 if ($('#tour-date-' + this._activeModule).val() === '') { 114 Alert.show('To send your order, kindly select the tour date.'); 115 return false;
116 } 117 if (transportType === undefined) { 118 Alert.show('To send your order, kindly select the transport option.'); 119 return false; 120 } 121 if ($('#dropdownLanguage-'+this._activeModule+'Value').val() === '') { 122 Alert.show('To send your order, kindly select the guide language.'); 123 return false; 124 } 125 if (parseInt($('#excursion-price_' + this._activeModule).val()) === 0){ 126 return false; 127 } 128 129 Hash.saveEvent('Cart action', 'Add excursion'); 130 return true; 131 }, 132 133 loadPriceInfo: function () { 134 let self = this; 135 136 $.post(W_AJAX + 'excursion/get_price', { 137 'elemId': self._id_excursion 138 }, 139 function (objData) { 140 if (objData.result === 'OK') { 141 Hash.save( 142 {'excursion': self._id_excursion}, 143 { 144 'transfer': objData.data.rent, 145 'cars': objData.data.cars, 146 'price': objData.data.excursion, 147 'rent_time' : objData.data.rent_time, 148 'is_package': objData.data.provider_package_tour 149 }); 150 self.updateParams(); 151 } else Alert.show(objData.error); 152 }, 'json'); 153 }, 154 155 updateParams: function () { 156 157 //if (!$('.rtjs-tour-filter-mobile.tour-filter-mobile').hasClass('d-none')) this._activeModule = 'mobile'; 158 if ($('.tour__filter-desktop').is(':visible')) this._activeModule = 'desktop' ; else this._activeModule = 'mobile'; 159 160 let elemUpgradeCar = $('#UpgradeCarClass_'+this._activeModule); 161 let choosedPeopleAmount = parseInt($('#people_amount_' + this._activeModule).val()); 162 163 if (this._activeModule === 'mobile'){ 164 $('#people-amount-title').html(choosedPeopleAmount + ' person'); 165 } 166 167 let transportType = $(":radio[name=Transportation-"+this._activeModule+"]:checked").val(); 168 if (transportType === undefined) transportType = $(":hidden[name=Transportation-"+this._activeModule+"]").val(); 169 if (transportType === undefined) transportType =0; 170 transportType = parseInt(transportType); 171 172 if (transportType == 0 ||transportType == 2 || !(choosedPeopleAmount === 1 || choosedPeopleAmount === 2)){ 173 elemUpgradeCar.hide(); 174 } 175 else elemUpgradeCar.show(); 176 177 178 let seasonType = 2; 179 let month = parseInt($('#tour-date-'+ this._activeModule).val().substr(3, 2)); 180 if (month && month > 9 || month < 5) seasonType = 1; 181 182 $('#excursion-format').val(this._activeModule); 183 184 let cached_info = Hash.load({'excursion': this._id_excursion}); 185 if (cached_info && month) { 186 $('#price_info_full').show(); 187 this._priceTransfer = cached_info['transfer']; 188 this._cars = cached_info['cars']; 189 this._priceExcursion = cached_info['price']; 190 this._rentTime = cached_info['rent_time']; 191 this._season = seasonType; 192 this._peopleAmount = choosedPeopleAmount; 193 this._isPackage = cached_info['is_package']; 194 195 this.recalcPriceExcursion(); 196 } 197 }, 198 199 recalcPriceExcursion: function () { 200 let id_car = 0; 201 let carInfo; 202 203 for (let k in this._cars) { 204 205 if (id_car === 0) { 206 carInfo = this._cars[k]; 207 if (carInfo.people_min <= this._peopleAmount && carInfo.people_max >= this._peopleAmount) id_car = parseInt(carInfo.ID_transfer_car); 208 } 209 } 210 211 if (id_car === 1 && this._peopleAmount < 3) { 212 213 let upgrade = parseInt($('input[name=UpgradeCarClass-'+this._activeModule+']:checked').val()); 214 215 if (upgrade) { 216 if (upgrade === 1) id_car = 2; 217 else if (upgrade === 2) id_car = 3; 218 else if (upgrade === 0) id_car = 1; 219 } 220 } 221 222 let transportType = $(":radio[name=Transportation-"+this._activeModule+"]:checked").val(); 223 if (transportType === undefined) transportType = $(":hidden[name=Transportation-"+this._activeModule+"]").val(); 224 if (transportType === undefined) transportType = 0; 225 transportType = parseInt(transportType); 226 227 let language = $('#dropdownLanguage-'+this._activeModule+'Value').val(); 228 if (language === undefined || language === '') language = 'en'; 229 let langKoeff = 1; 230 if (language !== 'en') langKoeff = this.languageKoeff; 231 232 let people = Math.min(this._peopleAmount, 11); 233 let fullPrice = 0; 234 235 let price = 0; 236 237 if (typeof this._priceExcursion[this._season] != 'undefined' && this._peopleAmount < 16) { 238 let transferTime = this._rentTime; 239 if ( 240 transportType === 0 || transportType === 2 241 //parseInt(this._priceExcursion[this._season]['transport_type']) === 1 242 //&& $('input[name=transport_type]:checked').val() === 0 243 ) transferTime = 0; 244 245 price = parseInt(this._priceExcursion[this._season]['people_' + people] || 0);
246 price = Math.ceil(price * langKoeff); 247 248 let priceCar = 0; 249 if (!this._isPackage) { 250 switch (transportType) { 251 case 1: 252 /*if (this._id_excursion == 17) priceCar = 0; 253 else*/ priceCar = Math.ceil(this._priceTransfer['price_' + id_car] * transferTime / this._peopleAmount); 254 break; 255 case 2: 256 priceCar = Math.ceil((1600 * (this._peopleAmount +1))/this._peopleAmount); 257 break; 258 } 259 } 260 else if (id_car <= 3 && id_car > 1) { 261 //пÑоÑÑиÑÑваем upgrage car; 262 //fixme пÑовеÑиÑÑ Ð½Ð° upgrade cars 263 price = 0; 264 } 265 266 if (price > 0) price += priceCar; 267 268 fullPrice = price * this._peopleAmount; 269 } 270 271 let fullPriceElem = $('.filter-'+this._activeModule+'__total .value'); 272 let singlePriceElem = $('.price__value'); 273 if (price > 0) { 274 singlePriceElem.html('<span class="price" data-price_rub="' + price + '">' + Currency.recalcPrice(price) + '</span>'); 275 fullPriceElem.html('<span class="price" data-price_rub="' + (price * this._peopleAmount) + '">' + Currency.recalcPrice(fullPrice) + '</span>'); 276 Currency.recalcElem(singlePriceElem.find('.price'), $.cookie('currency')); 277 Currency.recalcElem(fullPriceElem.find('.price'), $.cookie('currency')); 278 this.changeButtons(true); 279 } else { 280 singlePriceElem.html('<span>' + 'Upon request' + '</span>'); 281 fullPriceElem.html('<span>' + 'Upon request' + '</span>'); 282 this.changeButtons(false); 283 } 284 285 //$('#car_type').val(id_car); 286 //$('#price').val((price * this._peopleAmount)); 287 $('#excursion-price_' + this._activeModule).val(fullPrice); 288 289 }, 290 291 changeButtons: function(hasPrice){ 292 if (hasPrice){ 293 $('.add-cart__button').show(); 294 $('.request-from-booking-form').show(); 295 $('.request-quote').hide(); 296 } 297 else{ 298 $('.add-cart__button').hide(); 299 $('.request-from-booking-form').hide(); 300 $('.request-quote').show(); 301 } 302 }, 303 304 firstFormChanged: function () { 305 //console.log('form changed'); 306 //return; 307 let idExcursion = parseInt(this._id_excursion); 308 if (idExcursion){ 309 let cached_info = Hash.load({'excursion': idExcursion}); 310 311 if (!cached_info) { 312 this.loadPriceInfo(idExcursion); 313 } else { 314 this.updateParams(); 315 } 316 } 317 318 }, 319}; 320 321let Filter = { 322 init: function () { 323 this.initActivities(); 324 this.inizializeSlider(); 325 326 }, 327 328 inizializeSlider : function(){ 329 let minPrice = parseInt($('#filterMinPrice').val()); 330 let maxPrice = parseInt($('#filterMaxPrice').val()); 331 332 let minPriceCurr = Math.floor(Currency.recalcPrice(minPrice)); 333 let maxPriceCurr = Math.ceil(Currency.recalcPrice(maxPrice)); 334 335 if (null !== document.getElementById('filterRangeSlider') && minPrice !== maxPrice) this.initPriceSlider(minPriceCurr, maxPriceCurr); 336 }, 337 338 resetSlider: function(){ 339 $('#filterRangeSlider').replaceWith('<div id="filterRangeSlider" class="rangeslider"></div>'); 340 this.inizializeSlider(); 341 let inputs = [document.getElementById('input-with-keypress-0'), document.getElementById('input-with-keypress-1')]; 342 Filter.filterCardsByPrice(inputs[0].value, inputs[1].value); 343 }, 344 345 346 initActivities: function () { 347 $('#filterCoolapse input.custom-control-input').on('click', function () { 348 if (null !== document.getElementById('input-with-keypress-0')){ 349 let input0 = document.getElementById('input-with-keypress-0'); 350 let input1 = document.getElementById('input-with-keypress-1'); 351 let inputs = [input0, input1]; 352 Filter.filterCardsByPrice(inputs[0].value, inputs[1].value); 353 } 354 else Filter.filterCardsByPrice('0', '0'); 355 356 }); 357 358 }, 359 __getActivities: function () { 360 let amountActivities = $('#filterCoolapse input.custom-control-input:checked'); 361 let checkedIds = []; 362 amountActivities.each(function () { 363 checkedIds.push($(this).data('id')); 364 }); 365 return checkedIds; 366 }, 367 368 __formatPrice: function (price) { 369 price = price.replace('.', ''); 370 return parseFloat(price.replace(' ', '')); 371 }, 372 373 374 filterCardsByPrice: function (minPrice, maxPrice) { 375 let checkedIds = this.__getActivities(); 376 377 let checkPrices = true; 378 minPrice = this.__formatPrice(minPrice);
379 maxPrice = this.__formatPrice(maxPrice); 380 if (minPrice == 0 && maxPrice == 0) checkPrices = false; 381 382 if (checkPrices){ 383 let currency = Currency.getCurrency(); 384 385 minPrice = Math.floor(Currency.recalcPrice(minPrice, 'rub', currency)); 386 maxPrice = Math.floor(Currency.recalcPrice(maxPrice, 'rub', currency)); 387 } 388 389 $('.error-message').remove(); 390 391 $('.tour-card-item').filter(function () { 392 let card = $(this); 393 let isActive = false; 394 checkedIds.forEach(function (value, index, array) { 395 if (card.data('active' + value) === 1) isActive = true; 396 }); 397 398 if (checkPrices){ 399 let cardPriceRub = card.find('.price').data('price_rub'); 400 //let cardPrice = 0; 401 //if (cardPriceRub > 0) cardPrice = (cardPriceRub / Currency.currencyCoefficients[currency]).toFixed(2); 402 if (cardPriceRub > maxPrice) isActive = false; 403 if (cardPriceRub > 0 && cardPriceRub < minPrice) isActive = false; 404 } 405 406 407 if (isActive) card.addClass('tour-card-item-active'); 408 else { 409 card.removeClass('tour-card-item-active'); 410 } 411 return isActive; 412 }) 413 // .addClass( "tour-card-item-active") 414 ; 415 416 //if (checkedIds.length == 0) $('.tour-card-item').addClass('tour-card-item-active'); 417 418 419 $('.tour-card-item').not('.tour-card-item-active').hide(); 420 $('.tour-card-item-active').show(); 421 422 if ($('.tour-card-item-active').length === 0) { 423 $('.tour-card-item:eq(0)').before('<div class="col-12 error-message"><h2>No results</h2><p>We did not find any tours based on your filters. Try searching with more general terms, or get in touch and we\'ll help you find the perfect experience.</p></div>'); 424 } 425 426 427 }, 428 initPriceSlider: function (minPrice, maxPrice) { 429 430 //Filter Range Slider 431 var filterRangeSlider = document.getElementById('filterRangeSlider'); 432 var input0 = document.getElementById('input-with-keypress-0'); 433 var input1 = document.getElementById('input-with-keypress-1'); 434 var inputs = [input0, input1]; 435 436 noUiSlider.create(filterRangeSlider, { 437 start: [minPrice, maxPrice], 438 connect: true, 439 range: { 440 'min': minPrice, 441 'max': maxPrice 442 }, 443 format: wNumb({ 444 decimals: 3, 445 thousand: '.', 446 suffix: '' 447 }) 448 }); 449 450 filterRangeSlider.noUiSlider.on('update', function (values, handle) { 451 inputs[handle].value = values[handle]; 452 453 Filter.filterCardsByPrice(inputs[0].value, inputs[1].value); 454 }); 455 456 inputs.forEach(function (input, handle) { 457 458 input.addEventListener('change', function () { 459 filterRangeSlider.noUiSlider.setHandle(handle, this.value); 460 }); 461 462 input.addEventListener('keydown', function (e) { 463 464 var values = filterRangeSlider.noUiSlider.get(); 465 var value = Number(values[handle]); 466 467 var steps = filterRangeSlider.noUiSlider.steps(); 468 469 var step = steps[handle]; 470 471 var position; 472 473 switch (e.which) { 474 case 13: 475 filterRangeSlider.noUiSlider.setHandle(handle, this.value); 476 break; 477 case 38: 478 position = step[1]; 479 if (position === false) { 480 position = 1; 481 } 482 if (position !== null) { 483 filterRangeSlider.noUiSlider.setHandle(handle, value + position); 484 } 485 break; 486 case 40: 487 position = step[0]; 488 if (position === false) { 489 position = 1; 490 } 491 if (position !== null) { 492 filterRangeSlider.noUiSlider.setHandle(handle, value - position); 493 } 494 break; 495 } 496 }); 497 }); 498 } 499};
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.