1(function ($) { 2 $(document).ready(function () { 3 var $window = $(window); 4 $('#btn-booking-now').click(function () { 5 $("html, body").animate({scrollTop: $('#hotel-room-box').offset().top}, 1000); 6 }); 7 8 checkWidth(); 9 $(window).resize(checkWidth); 10 11 function checkWidth() { 12 if ($('#hotel-room-box').length) { 13 var windowsize = $window.width(); 14 if (windowsize < 992) { 15 $(window).scroll(function () { 16 if ($(this).scrollTop() > ($('#hotel-room-box').offset().top - ($('#hotel-room-box').height()))) { 17 $('#btn-booking-now').fadeOut(); 18 } else { 19 $('#btn-booking-now').fadeIn(); 20 } 21 }); 22 } 23 } 24 } 25 26 if ($('.mega-menu').length > 0) { 27 $('.mega-menu').each(function (e) { 28 if ($(this).find('.current-menu-item').length !== 0) { 29 $(this).parent().addClass('current-menu-ancestor'); 30 } 31 }) 32 } 33 34 /* Contact form author page*/ 35 $('.author-contact-form').submit(function (e) { 36 e.preventDefault(); 37 var t = $(this); 38 var check = true; 39 var data = t.serializeArray(); 40 t.find('input[type="text"], textarea').removeClass('error'); 41 t.find('input[type="text"], textarea').each(function () { 42 if ($(this).val() == '') { 43 check = false; 44 $(this).addClass('error'); 45 } 46 }) 47 var checkEmail = ValidateEmail(data[2]['value']); 48 if (!check || !checkEmail) { 49 if (!checkEmail && data[2]['value'] != '') { 50 t.find('input[name="au_email"]').addClass('error'); 51 if (data[0]['value'] == '' || data[3]['value'] == '') { 52 t.find('#author-message').html('<div class="alert alert-danger">' + st_checkout_text.validate_form + '<br />' + st_checkout_text.email_validate + '</div>'); 53 } else { 54 t.find('#author-message').html('<div class="alert alert-danger">' + st_checkout_text.email_validate + '</div>'); 55 } 56 } else { 57 t.find('#author-message').html('<div class="alert alert-danger">' + st_checkout_text.validate_form + '</div>'); 58 } 59 } else { 60 t.find('#author-message').empty(); 61 t.find('input[type="submit"]').attr('disabled', 'disabled'); 62 t.find('i.fa-spin').show(); 63 $.ajax({
64 url: st_params.ajax_url, 65 dataType: 'json', 66 type: 'post', 67 data: { 68 action: 'st_author_contact', 69 data: data, 70 }, 71 success: function (doc) { 72 if (doc.status == true) { 73 t.find('#author-message').html('<div class="alert alert-success">' + doc.message + '</div>'); 74 } else { 75 t.find('#author-message').html('<div class="alert alert-danger">' + doc.message + '</div>'); 76 } 77 t.find('i.fa-spin').hide(); 78 t.find('input[type="submit"]').removeAttr('disabled', 'disabled'); 79 }, 80 complete: function () { 81 } 82 }); 83 } 84 }) 85 86 function ValidateEmail(mail) { 87 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) { 88 return (true) 89 } 90 return (false) 91 } 92 93 $('#author-write-review-form').submit(function (e) { 94 e.preventDefault(); 95 var t = $(this); 96 97 //var data = t.serializeArray(); 98 t.find('input[type="text"], textarea').removeClass('error'); 99 var check = true; 100 t.find('input[type="text"], textarea').each(function () { 101 if ($(this).val() == '') { 102 check = false; 103 $(this).addClass('error'); 104 } 105 }); 106 if (!check) { 107 t.find('#author-wreview-message').html('<div class="alert alert-danger">' + st_checkout_text.validate_form + '</div>'); 108 } else { 109 var arr_star = []; 110 /*t.find("input[name='au_review_star[]']").each(function () { 111 arr_star.push($(this).data('title') + '|' + $(this).val()); 112 });*/ 113 var values = $("input[name='au_review_star[]']") 114 .map(function () { 115 return $(this).data('title') + '|' + $(this).val(); 116 }).get(); 117 118 t.find('#author-wreview-message').empty(); 119 t.find('i.fa-spin').show(); 120 $.ajax({
121 url: st_params.ajax_url, 122 dataType: 'json', 123 type: 'post', 124 data: { 125 action: 'st_author_write_review', 126 title: t.find('input[name="au_review_title"]').val(), 127 content: t.find('textarea[name="au_review_content"]').val(), 128 user_id: t.find('input[name="user_id"]').val(), 129 partner_id: t.find('input[name="partner_id"]').val(), 130 star: JSON.stringify(values), 131 }, 132 success: function (doc) { 133 if (doc.status == true) { 134 t.find('#author-wreview-message').html('<div class="alert alert-success">' + doc.message + '</div>'); 135 } 136 t.find('i.fa-spin').hide(); 137 t.find('input[type="submit"]').removeAttr('disabled', 'disabled'); 138 }, 139 complete: function () { 140 } 141 }); 142 } 143 144 145 }); 146 147 148 /** 149 * Friendly select 150 * Nếu focus và o input text kiá»m tra sụ kiá»n 151 * Nếu List location mà có length > 0 thì bắt Äầu bắt sá»± kiá»n dùng phÃm Äá» select + phÃm enter 152 */ 153 /*$('#field-rental-locationid').focusin(function(){ 154 if($('.st-option-wrapper').length > 0){ 155 console.log('Focus'); 156 var li = $('.st-option-wrapper .option'); 157 var liSelected; 158 $(window).keydown(function(e){ 159 if(e.which === 40){ 160 if(liSelected){ 161 liSelected.removeClass('active'); 162 next = liSelected.next(); 163 if(next.length > 0){ 164 liSelected = next.addClass('active'); 165 }else{ 166 liSelected = $('.st-option-wrapper .option').eq(0).addClass('active'); 167 } 168 }else{ 169 liSelected = $('.st-option-wrapper .option').eq(0).addClass('active'); 170 } 171 }else if(e.which === 38){ 172 if(liSelected){ 173 liSelected.removeClass('active'); 174 next = liSelected.prev(); 175 if(next.length > 0){ 176 liSelected = next.addClass('active'); 177 }else{ 178 liSelected = $('.st-option-wrapper .option').last().addClass('active'); 179 } 180 }else{ 181 liSelected = $('.st-option-wrapper .option').last().addClass('active'); 182 } 183 } 184 185 }); 186 } 187 188 }); 189 $("#field-rental-locationid").on('keyup', function (e) { 190 if (e.keyCode == 13) { 191 console.log('ENTER111'); 192 $('.option-wrapper').html('').hide(); 193 $('#field-rental-checkin').focus(); 194 } 195 });*/ 196 }); 197 $(document).on('show','.accordion', function (e) { 198 //$('.accordion-heading i').toggleClass(' '); 199 alert('OK'); 200 $(e.target).prev('.accordion-heading').addClass('accordion-opened'); 201 }); 202 203 $(document).on('hide','.accordion', function (e) { 204 $(this).find('.accordion-heading').not($(e.target)).removeClass('accordion-opened'); 205 //$('.accordion-heading i').toggleClass('fa-chevron-right fa-chevron-down'); 206 }); 207 208 var body = $('body'); 209 var flag = false; 210 body.on('click', '#save_ical', function(event){ 211 event.preventDefault(); 212 var parent = $(this).parent(), 213 t = $(this), 214 spinner = $('.spinner-import', parent), 215 message = $('.form-message', parent); 216 if(flag){ 217 return false; 218 } 219 flag = true; 220 spinner.show(); 221 var data = { 222 'action' : 'st_import_ical', 223 'url' : $('input.ical_input', parent).val(), 224 'post_id' : $('input[name="post_id"]', parent).val() 225 }; 226 227 $.post(st_params.ajax_url, data, function(respon){ 228 if(typeof respon === 'object'){ 229 message.html(respon.message); 230 } 231 flag = false; 232 spinner.hide(); 233 },'json'); 234 });
235 236 // Tour package 237 $(document).on('click', 'a[href="#package_tab"]', function () { 238 var t = $(this); 239 var parent = $(this).closest('.tabs_partner'); 240 var parentType = $('.stour-package'); 241 242 var locations = []; 243 $('.list-location-wrapper .item', parent).each(function () { 244 var me = $(this); 245 if (me.find('input').is(':checked')) { 246 locations.push(me.find('input').val()); 247 } 248 }); 249 250 var address = $('input[name="address"]', parent).val(); 251 252 if (locations.length == 0 && address == '') { 253 $('.form-message', parentType).html('<div class="alert alert-danger">' + $('#stour-no-location').val() + '</div>'); 254 } else { 255 $('.form-message', parentType).html(''); 256 } 257 }); 258 259 $(document).on('click', '.tour-package-load-hotel', function (e) { 260 e.preventDefault(); 261 262 var t = $(this); 263 var parent = t.closest('.tab-content-parent'); 264 var parentType = t.closest('.stour-tab-content'); 265 var parentBox = t.closest('.stour-package'); 266 267 var locations = []; 268 $('#locations .st-field-multi_location .dropdown .item').each(function () { 269 var me = $(this); 270 if (me.find('input').is(':checked')) { 271 locations.push(me.find('input').val()); 272 } 273 }); 274 275 var address = $('input[name="address"]', parent).val(); 276 277 parentBox.find('.overlay-form').show(); 278 $('.form-message', parentBox).html(''); 279 280 $.ajax({
281 url: st_params.ajax_url, 282 dataType: 'json', 283 type: 'post', 284 data: { 285 action: 'st_load_hotel_tour_package', 286 locations: locations.toString(), 287 address: address, 288 post_id: t.data('post-id'), 289 post_type: t.data('type') 290 }, 291 success: function (respond) { 292 if (respond.status == false) { 293 $('.form-message', parentBox).html('<div class="alert alert-danger">' + respond.message + '</div>'); 294 } else { 295 $('.form-message', parentBox).html('<div class="alert alert-success">' + respond.message + '</div>'); 296 $('.list-content', parentType).html(respond.content); 297 } 298 parentBox.find('.overlay-form').hide(); 299 }, 300 error: function (e) { 301 console.log('Can not get the availability slot. Lost connect with your sever'); 302 } 303 }); 304 }); 305 306 if($('.stour-list-hotel').length) { 307 $(document).on('click', '#cb-select-all-1', function (e) { 308 var t = $(this); 309 var parent = $(this).closest('.stour-list-hotel'); 310 parent.find('input:checkbox').not(this).prop('checked', this.checked); 311 }); 312 $(document).on('click', '.stour-list-hotel .cb-select-child1', function (e) { 313 var t = $(this); 314 var parent = $(this).closest('.stour-list-hotel'); 315 parent.find('input#cb-select-all-1').prop('checked', false); 316 var check = 0; 317 $('.stour-list-hotel .cb-select-child1').each(function (e) { 318 if (!$(this).is(":checked")) { 319 check++; 320 } 321 }); 322 if (check == 0) { 323 parent.find('input#cb-select-all-1').prop('checked', true); 324 } 325 }); 326 } 327 328 $(document).on('click', '#tour-package-save-hotel', function (e) { 329 e.preventDefault(); 330 var t = $(this); 331 var table = $('.stour-list-hotel'); 332 var data = {}; 333 var data_activity = {}; 334 var data_car = {}; 335 var data_flight = {}; 336 337 table.each(function (index) { 338 var i = 0; 339 var me = $(this); 340 var type = me.data('type'); 341 if(type == 'hotel') { 342 me.find('.the-list tr').each(function () { 343 var item = $(this); 344 if ($('input[type="checkbox"]', item).is(':checked')) { 345 data[i] = { 346 'hotel_id': $('input[type="checkbox"]', item).data('id'), 347 'hotel_price': $('input[type="text"]', item).val() 348 }; 349 i++; 350 } 351 }); 352 } 353 if(type == 'activity') { 354 me.find('.the-list tr').each(function () { 355 var item = $(this); 356 if ($('input[type="checkbox"]', item).is(':checked')) { 357 data_activity[i] = { 358 'activity_id': $('input[type="checkbox"]', item).data('id'), 359 'activity_price': $('input[type="text"]', item).val() 360 }; 361 i++; 362 } 363 }); 364 } 365 if(type == 'car') { 366 me.find('.the-list tr').each(function () { 367 var item = $(this); 368 if ($('input[type="checkbox"]', item).is(':checked')) { 369 data_car[i] = { 370 'car_id': $('input[type="checkbox"]', item).data('id'), 371 'car_price': $('input[type="text"]', item).val(), 372 'car_quantity': $('input[type="number"]', item).val(), 373 }; 374 i++; 375 } 376 }); 377 } 378 if(type == 'flight'){ 379 me.find('.the-list tr').each(function () { 380 var item = $(this); 381 if ($('input[type="checkbox"]', item).is(':checked')) { 382 data_flight[i] = { 383 'flight_id': $('input[type="checkbox"]', item).data('id'),
384 'flight_price_economy': $('input.price-economy[type="text"]', item).val(), 385 'flight_price_business': $('input.price-business[type="text"]', item).val(), 386 }; 387 i++; 388 } 389 }); 390 } 391 }); 392 393 //Data custom 394 var table_custom = $('.stour-list-custom-hotel'); 395 var data_custom = {}; 396 var data_custom_car = {}; 397 var data_custom_activity = {}; 398 var data_custom_flight = {}; 399 table_custom.each(function(index){ 400 var me = $(this); 401 var type = me.data('type'); 402 if(type == 'hotel'){ 403 var j = 0; 404 me.find('tbody tr').not('.parent-row').each(function () { 405 var item_custom = $(this); 406 data_custom[j] = { 407 'hotel_name': $('input.hotel-name', item_custom).val(), 408 'hotel_star': $('input.hotel-star', item_custom).val(), 409 'hotel_price': $('input.hotel-price', item_custom).val(), 410 }; 411 j++; 412 }); 413 } 414 if(type == 'activity'){ 415 var j = 0; 416 me.find('tbody tr').not('.parent-row').each(function () { 417 var item_custom = $(this); 418 data_custom_activity[j] = { 419 'activity_name': $('input.activity-name', item_custom).val(), 420 'activity_price': $('input.activity-price', item_custom).val(), 421 }; 422 j++; 423 }); 424 } 425 if(type == 'car'){ 426 var j = 0; 427 me.find('tbody tr').not('.parent-row').each(function () { 428 var item_custom = $(this); 429 data_custom_car[j] = { 430 'car_name': $('input.car-name', item_custom).val(), 431 'car_price': $('input.car-price', item_custom).val(), 432 'car_quantity': $('input.car-quantity', item_custom).val(), 433 }; 434 j++; 435 }); 436 } 437 if(type == 'flight'){ 438 var j = 0; 439 me.find('tbody tr').not('.parent-row').each(function () { 440 var item_custom = $(this); 441 data_custom_flight[j] = { 442 'flight_origin': $('input.flight-origin', item_custom).val(), 443 'flight_destination': $('input.flight-destination', item_custom).val(), 444 'flight_departure_time': $('input.flight-depature-time', item_custom).val(), 445 'flight_duration': $('input.flight-duration', item_custom).val(), 446 'flight_price_economy': $('input.flight-price-economy', item_custom).val(), 447 'flight_price_business': $('input.flight-price-business', item_custom).val(), 448 }; 449 j++; 450 }); 451 } 452 }); 453 454 var parentType = $('.stour-package'); 455 var boxList = $('#stour-list-hotel', parentType); 456 boxList.find('.overlay-form').show(); 457 $('.form-message', parentType).html(''); 458 459 $.ajax({
460 url: st_params.ajax_url, 461 dataType: 'json', 462 type: 'post', 463 data: { 464 action: 'st_save_hotel_tour_package', 465 tour_package: JSON.stringify(data), 466 tour_package_car: JSON.stringify(data_car), 467 tour_package_activity: JSON.stringify(data_activity), 468 tour_package_flight: JSON.stringify(data_flight), 469 tour_package_custom: JSON.stringify(data_custom), 470 tour_package_custom_car: JSON.stringify(data_custom_car), 471 tour_package_custom_activity: JSON.stringify(data_custom_activity), 472 tour_package_custom_flight: JSON.stringify(data_custom_flight), 473 post_id: t.data('post-id') 474 }, 475 success: function (respond) { 476 if (respond.status == false) { 477 $('.form-message', parentType).html('<div class="alert alert-danger">' + respond.message + '</div>'); 478 } else { 479 $('.form-message', parentType).html('<div class="alert alert-success">' + respond.message + '</div>'); 480 } 481 boxList.find('.overlay-form').hide(); 482 }, 483 error: function (e) { 484 console.log('Can not get the availability slot. Lost connect with your sever'); 485 } 486 }); 487 }); 488 489 $(document).on('click', '.hotel-price', function (e) { 490 var parent = $(this).closest('tr'); 491 if (!parent.find('input[type="checkbox"]').is(':checked')) { 492 console.log(parent.find('input[type="checkbox"]')); 493 parent.find('input[type="checkbox"]').prop("checked", true); 494 } 495 }); 496 497 $(document).on('click', '.btn-add-custom-package', function (e) { 498 e.preventDefault(); 499 var t = $(this); 500 var parent = t.closest('.custom-hotel-data-item'); 501 var table = parent.find('table.stour-list-custom-hotel tbody'); 502 var tr = table.find("tr.parent-row").clone().removeClass('parent-row').show(); 503 tr.insertAfter(table.find('tr:last')); 504 }); 505 $(document).on('click', '.hotel-del', function (e) { 506 e.preventDefault(); 507 var t = $(this); 508 t.closest('tr').remove(); 509 }); 510 // End Tour package 511 512 /* Approve Booking for partner */ 513 var checkStatus = true; 514 $(document).on('click', '.suser-approve', function (e) { 515 e.preventDefault(); 516 var t = $(this); 517 if(!checkStatus) 518 return; 519 t.css({ 520 'visibility': 'visible' 521 }); 522 t.closest('td').find('.suser-message').show(); 523 $.ajax({
524 url: st_params.ajax_url, 525 dataType: 'json', 526 type: 'post', 527 data: { 528 action: 'st_partner_approve_booking', 529 post_id: t.data('id'), 530 order_id: t.data('order-id') 531 }, 532 beforeSend: function () { 533 checkStatus = false; 534 }, 535 success: function (respond) { 536 if(respond.status == true){ 537 t.closest('td').find('.suser-status').html('<div class="text-success"><b>'+ respond.message +'</b></div>'); 538 t.closest('td').find('.suser-message').hide(); 539 t.remove(); 540 checkStatus = true; 541 }else{ 542 alert(respond.message); 543 checkStatus = true; 544 } 545 } 546 }); 547 548 }); 549 /* End Approve Booking for partner */ 550 551 /*Enquire email*/ 552 var body = $('body'); 553 $(".form-st-send-mail .st_send-mail-form").submit(function(e){ 554 return false; 555 }); 556 $('.form-st-send-mail .st_send-mail-form .sent-email-st').click(function (ev) { 557 ev.preventDefault(); 558 var type_service = $("input[name=type_service]").val(); 559 var name_service = $("input[name=name_service]").val(); 560 var name_st = $("input[name=name_st]").val(); 561 var email_st = $("input[name=email_st]").val(); 562 var phone_st = $("input[name=phone_st]").val(); 563 var content_st = $("textarea[name=content_st]").val(); 564 var email_owl = $("input[name=email_owl]").val(); 565 $('.st-sent-mail-customer .overlay-form').show(); 566 console.log(content_st); 567 $.ajax({
568 url: st_params.ajax_url, 569 type: "GET", 570 data: { 571 'action': "st_send_email_single_service", 572 'type_service': type_service, 573 'name_service': name_service, 574 'name_st': name_st, 575 'email_st': email_st, 576 'phone_st': phone_st, 577 'content_st': content_st, 578 'email_owl': email_owl 579 }, 580 dataType: "json", 581 beforeSend: function () { 582 }, 583 error : function(jqXHR, textStatus, errorThrown) { 584 }, 585 success : function(res){ 586 587 }, 588 complete: function (xhr, status) { 589 590 if(xhr.responseJSON.status != 0){ 591 var mess = '<div class="ccv-success"><div class="content-message">'+xhr.responseJSON.message+'</div></div>'; 592 $('.form-st-send-mail .st_send-mail-form').html(mess); 593 $('.st-sent-mail-customer .overlay-form').hide(); 594 } else{ 595 var mess = '<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">Ã</span></button>'+xhr.responseJSON.message+'</div>'; 596 $('.form-st-send-mail .message-wrapper-sendemail').html(mess); 597 $('.st-sent-mail-customer .overlay-form').hide(); 598 } 599 } 600 }); 601 }); 602 603})(jQuery)
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.