1var GLF = GLF || {}; 2 3(function ($) { 4 "use strict"; 5 6 var $body = $('body'); 7 8 var ajax_url = golo_template_vars.ajax_url, 9 item_amount = golo_template_vars.item_amount, 10 default_icon = golo_template_vars.marker_default_icon, 11 not_place = golo_template_vars.not_place, 12 no_results = golo_template_vars.no_results, 13 wishlist_color = golo_template_vars.wishlist_color, 14 wishlist_save = golo_template_vars.wishlist_save, 15 wishlist_saved = golo_template_vars.wishlist_saved, 16 booking_success = golo_template_vars.booking_success, 17 booking_error = golo_template_vars.booking_error, 18 enable_city_map = golo_template_vars.enable_city_map, 19 enable_archive_map = golo_template_vars.enable_archive_map, 20 sending_text = golo_template_vars.sending_text; 21 22 23 var markers = []; 24 var markers_prop = []; 25 var search_markers = []; 26 var golo_map; 27 var place_maps_filter; 28 var menu_filter_wrap = $('.golo-menu-filter'); 29 // Only take visible one 30 menu_filter_wrap.each(function () { 31 if ($(this).closest('.archive-filter').is(':visible') ) { 32 menu_filter_wrap = $(this); 33 } 34 }) 35 36 var mapbox_type = $('.maptype').data( 'maptype' ); 37 if( mapbox_type == 'google_map' ){ 38 place_maps_filter = $('#place-map-filter'); 39 } else if( mapbox_type == 'openstreetmap' ){ 40 place_maps_filter = $('#maps'); 41 } else { 42 place_maps_filter = $('#map'); 43 } 44 var has_map = ''; 45 var cached_html = {}; 46 var cached_location = {}; 47 48 if( enable_city_map && place_maps_filter.length ) { 49 has_map = 'yes'; 50 } 51 52 var ajax_call = false; 53 var drgflag = true; 54 var is_mobile = false; 55 var click_marker = false; 56 57 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 58 is_mobile = true; 59 } 60 61 function checkValue(value,arr){ 62 var status = 'notexist'; 63 64 for(var i=0; i<arr.length; i++){ 65 var name = arr[i]; 66 if(name == value){ 67 status = 'exist'; 68 break; 69 } 70 } 71 72 return status; 73 } 74 75 GLF.element = { 76 init: function() { 77 GLF.element.waypoints(); 78 GLF.element.click_outside(); 79 GLF.element.place_layout(); 80 GLF.element.nice_select(); 81 GLF.element.select2(); 82 GLF.element.sticky_element(); 83 GLF.element.light_gallery(); 84 GLF.element.click_to_demo(); 85 GLF.element.booking_form(); 86 GLF.element.toggle_panel(); 87 GLF.element.toggle_social(); 88 GLF.element.toggle_content(); 89 GLF.element.nav_scroll(); 90 GLF.element.filter_toggle(); 91 GLF.element.slick_carousel(); 92 GLF.element.pagination(); 93 GLF.element.filter_single(); 94 GLF.element.filter_clear(); 95 GLF.element.add_to_wishlist(); 96 GLF.element.click_search_location(); 97 GLF.element.contact_agent_by_email(); 98 99 $('.filter-open-time').on('click', 'a', function (e) { 100 e.preventDefault(); 101 if ($(this).hasClass('open-filter')) { 102 $(this).attr('data-open', ''); 103 $(this).removeClass('open-filter'); 104 $(this).parent().find('i').removeClass().addClass('fal fa-clock icon-small'); 105 } else { 106 $(this).attr('data-open', 1); 107 $(this).addClass('open-filter'); 108 $(this).parent().find('i').removeClass().addClass('las la-door-open icon-medium'); 109 } 110 111 ajax_call = true; 112 GLF.element.ajax_load(ajax_call); 113 }) 114 115 if ($( window ).width() > 992) { 116 $( '.btn-canvas-filter.hidden-md-up' ).remove(); 117 $( 'select.hidden-md-up' ).remove(); 118 } 119 120 if( place_maps_filter.length > 0 ){ 121 GLF.element.ajax_load(); 122 } 123 124 $('.golo-menu-filter').on('input', 'input.input-control', function() { 125 $('.golo-pagination').find('input[name="paged"]').val(1); 126 ajax_call = true; 127 GLF.element.ajax_load(ajax_call); 128 }); 129 130 $('.archive-layout select.sort-by').on('change', function() { 131 $('.golo-pagination').find('input[name="paged"]').val(1); 132 ajax_call = true; 133 GLF.element.ajax_load(ajax_call); 134 }); 135 136 var timer; 137 $('.golo-ajax-search').on('keyup input focus', 'input', function(event, status){ 138 var $this = $(this); 139 if( $this.val() ){ 140 clearInterval(timer); 141 timer = setTimeout(function() { 142 if( $this.attr('name') == 's' ) { 143 GLF.element.ajax_search($this); 144 } 145 146 if( $this.attr('name') == 'place_location' ) { 147 var $input = $this.closest('.golo-ajax-search').find('input[name="s"]'); 148 GLF.element.ajax_search($input, 'hide'); 149 if (status == 'hide') { 150 GLF.element.ajax_search_location($this, 'hide'); 151 } else { 152 GLF.element.ajax_search_location($this, 'show'); 153 } 154 } 155 156 }, 50); 157 }else{ 158 clearInterval(timer); 159 } 160 }); 161 162 $('.golo-ajax-search').on('focus input', 'input', function(event, status){ 163 var $this = $(this); 164 $('.form-field .area-result').hide(); 165 if( $this.val() ){ 166 $this.closest('.area-search').find('.focus-result').hide(); 167 if (status == 'hide') { 168 $this.closest('.form-field').find('.area-result').hide(); 169 } else { 170 $this.closest('.form-field').find('.area-result').show(); 171 } 172 }else{ 173 $this.closest('.form-field').find('.focus-result').show(); 174 $this.closest('.form-field').find('.area-result').hide(); 175 } 176 }); 177 178 GLF.element.click_outside('.input-field','.focus-result'); 179 GLF.element.click_outside('.location-field','.focus-result'); 180 GLF.element.click_outside('.type-field','.focus-result'); 181 GLF.element.click_outside('.location-field','.area-result'); 182 183 $('.formBooking').on('submit', function(e){
184 e.preventDefault(); 185 var $this = $(this); 186 var coupon = $( this ).find( 'input[name="place_coupon"]' ).val(); 187 var coupon_code = $( this ).find( 'input[name="place_coupon_code"]' ).val(); 188 if ( coupon_code != '' && coupon != '' && coupon != coupon_code ) { 189 $( '.form-coupon + p.error' ).fadeIn(); 190 } else { 191 GLF.element.ajax_booking_form($this); 192 $( '.form-coupon + p.error' ).fadeOut(); 193 } 194 195 }); 196 197 $('.formClaim').validate({ 198 rules: { 199 your_name: { 200 required: true, 201 }, 202 your_email: { 203 required: true, 204 }, 205 your_username: { 206 required: true, 207 }, 208 your_listing: { 209 required: true, 210 }, 211 }, 212 submitHandler: function(form) { 213 GLF.element.ajax_claim_form($('.formClaim')); 214 } 215 }); 216 217 $('body').on('click', '.btn-maps-filter', function(e) { 218 e.preventDefault(); 219 $('html, body').animate({scrollTop: 0}, 500); 220 $('body').css('overflow', 'hidden'); 221 $('.filter-place-search').fadeIn(); 222 GLF.element.ajax_load(); 223 }); 224 225 $('body').on('click', '.filter-place-search .btn-close', function(e) { 226 e.preventDefault(); 227 $('body').css('overflow', 'inherit'); 228 $('.filter-place-search').fadeOut(); 229 ajax_call = false; 230 }); 231 232 $('.golo-payment-method-wrap .radio').on('click', function() { 233 $('.golo-payment-method-wrap .radio').removeClass('active'); 234 $(this).addClass('active'); 235 }); 236 237 $('.btn-hide-map input[type="checkbox"]').on('change', function() { 238 var elem = $('.archive-layout .inner-content'); 239 var ltf = $('.layout-top-filter .nav-bar'); 240 if($(this).attr('checked')){ 241 $("input[value='hide_map']").prop('checked',false); 242 }else{ 243 $("input[value='hide_map']").prop('checked',true); 244 } 245 if( elem.hasClass('has-map') ) { 246 elem.removeClass('has-map'); 247 elem.addClass('no-map'); 248 ltf.removeClass('has-map'); 249 ltf.addClass('no-map'); 250 }else{ 251 elem.removeClass('no-map'); 252 elem.addClass('has-map'); 253 ltf.removeClass('no-map'); 254 ltf.addClass('has-map'); 255 } 256 ajax_call = true; 257 GLF.element.ajax_load(ajax_call); 258 }); 259 260 $('.toggle-select').on('click', '.toggle-show', function() { 261 $(this).closest('.toggle-select').find('.toggle-list').slideToggle(); 262 }); 263 GLF.element.click_outside('.toggle-select', '.toggle-list', 'slide'); 264 }, 265 266 waypoints: function() { 267 var $elem = $( '.offset-item' ); 268 269 var waypoints = $elem.waypoint(function(direction) { 270 // Fix for different ver of waypoints plugin. 271 var _self = this.element ? this.element : this; 272 var $self = $( _self ); 273 $self.addClass( 'animate' ); 274 }, { 275 offset: '85%', 276 triggerOnce: true 277 }); 278 }, 279 280 light_gallery: function() { 281 $('.single-place-thumbs.enable').lightGallery({ 282 thumbnail: true, 283 selector: '.lgbox' 284 }); 285 286 $('.single-place-thumbs .btn-gallery').on('click', function(e) { 287 e.preventDefault(); 288 $(this).closest('.single-place-thumbs').find('.slick-slide.slick-current.slick-active .lgbox').trigger('click'); 289 }); 290 }, 291 292 scroll_to: function(element) { 293 var offset = $(element).offset().top; 294 $('html, body').animate({ 295 scrollTop: offset - 100 296 }, 500); 297 }, 298 299 click_to_demo: function() { 300 $('.menu a').on('click', function(e) { 301 var id = $(this).attr('href'); 302 if( id == '#demo' ) { 303 e.preventDefault(); 304 scroll_to(id); 305 } 306 }); 307 }, 308 309 click_outside: function(element, child, type = '') { 310 $(document).on('click', function(event){ 311 var $this = $(element); 312 if($this !== event.target && !$this.has(event.target).length){ 313 if( type ) { 314 if( child ) { 315 $this.find(child).slideUp(); 316 }else{ 317 $this.slideUp(); 318 } 319 }else{ 320 if( child ) { 321 $this.find(child).hide(); 322 }else{ 323 $this.hide(); 324 } 325 } 326 } 327 }); 328 }, 329 330 removeClassStartingWith: function(node, begin) { 331 node.removeClass (function (index, className) { 332 return (className.match ( new RegExp("\\b"+begin+"\\S+", "g") ) || []).join(' '); 333 }); 334 }, 335 336 place_layout: function() { 337 $('.place-layout a').on('click', function(event){ 338 event.preventDefault(); 339 var layout = $(this).attr('data-layout'); 340 var type_pagination = $('.golo-pagination').attr('data-type'); 341 if( type_pagination == 'loadmore' ) { 342 $('.golo-pagination').find('input[name="paged"]').val(1); 343 } 344 $(this).closest('.place-layout').find('>a').removeClass('active'); 345 $(this).addClass('active'); 346 GLF.element.removeClassStartingWith( $('.archive-layout>.inner-content'), 'layout-' ); 347 $(this).closest('.inner-content').addClass(layout); 348 349 $('.area-places .place-item').each( function() { 350 GLF.element.removeClassStartingWith( $(this), 'layout-' ); 351 $(this).addClass(layout); 352 }); 353 354 ajax_call = true; 355 GLF.element.ajax_load(ajax_call); 356 }); 357 }, 358 359 nice_select: function() { 360 $( '.nice-select' ).niceSelect(); 361 }, 362 363 select2: function() { 364 $( '.golo-select2' ).select2(); 365 }, 366 367 sticky_element: function() { 368 var offset = ''; 369 if( $('.uxper-sticky').length > 0 ){ 370 offset = $('.uxper-sticky').offset().top; 371 } 372 var has_wpadminbar = $('#wpadminbar').length; 373 var height_sticky = $('.uxper-sticky').height(); 374 var wpadminbar = 0; 375 var lastScroll = 0; 376 if( has_wpadminbar > 0 ){ 377 wpadminbar = $('#wpadminbar').height(); 378 $('.uxper-sticky').addClass('has-wpadminbar'); 379 } 380 381 var lastScrollTop = 0; 382 $(window).scroll(function(event){ 383 var st = $(this).scrollTop(); 384 if (st < lastScrollTop){ 385 $('.uxper-sticky').addClass('on'); 386 }else{ 387 $('.uxper-sticky').removeClass('on'); 388 } 389 390 if( st < height_sticky + wpadminbar ) { 391 $('.uxper-sticky').removeClass('on'); 392 } 393 lastScrollTop = st; 394 }); 395 }, 396 397 booking_form: function() { 398 $('.datepicker').datetimepicker({ 399 timepicker:false, 400 format:'d.m.Y', 401 }); 402 $('.timepicker').datetimepicker({ 403 datepicker:false, 404 format:'H:i', 405 }); 406 407 var language = $('.datepicker').data( 'language' ); 408 if (language != '') { 409 $.datetimepicker.setLocale(language); 410 } 411 412 $('body').on('click', '.datepicker', function() { 413 $(this).parent().find('.xdsoft_datetimepicker').addClass('on'); 414 var width = $('.datepicker').outerWidth(); 415 $('.xdsoft_datetimepicker').width(width - 10); 416 }); 417 418 $('body').on('click', '.timepicker', function() { 419 $(this).parent().find('.xdsoft_timepicker').addClass('on'); 420 var width = $('.timepicker').outerWidth(); 421 $('.xdsoft_datetimepicker').width(width - 10); 422 }); 423 424 $('.booking-bar .golo-button a').on('click', function(e){
425 e.preventDefault(); 426 $('body').addClass( 'open-popup' ); 427 $('#secondary .place-booking').toggleClass('open'); 428 $( '.site-header' ).addClass( 'show-popup' ); 429 }); 430 431 $('#secondary .place-booking .bg-overlay').on('click', function(e){ 432 e.preventDefault(); 433 $('body').removeClass( 'open-popup' ); 434 $(this).parent().removeClass('open'); 435 $( '.popup' ).removeClass('open'); 436 $( '.site-header' ).removeClass( 'show-popup' ); 437 $('body').css('overflow', 'auto'); 438 }); 439 440 $( '.widget-area > div' ).wrapAll( '<div class="widget-area-inner"></div>' ); 441 442 $( '.place-booking' ).each( function() { 443 var _this = $( this ); 444 if( _this.hasClass( 'has-sticky' ) ){ 445 _this.removeClass( 'has-sticky' ); 446 _this.parents( '.widget-area-inner' ).addClass( 'has-sticky' ); 447 } 448 }); 449 450 var lastScrollTop = 0; 451 $(window).scroll(function(event){ 452 var st = $(this).scrollTop(); 453 if (st > lastScrollTop){ 454 $('.booking-bar').addClass('on'); 455 } else { 456 $('.booking-bar').removeClass('on'); 457 } 458 lastScrollTop = st; 459 }); 460 461 }, 462 463 toggle_panel: function() { 464 $('.block-panel').on('click', '.block-tab', function(){ 465 var parent = $(this).closest('.block-panel'); 466 if( parent.hasClass('active') ){ 467 parent.removeClass('active'); 468 parent.find('.block-content').slideUp(300); 469 }else{ 470 $('.entry-property-element .block-panel').removeClass('active'); 471 $('.entry-property-element .block-panel .block-content').slideUp(300); 472 parent.addClass('active'); 473 parent.find('.block-content').slideDown(300); 474 } 475 }); 476 }, 477 478 toggle_social: function() { 479 $('.toggle-social').on('click', '.btn-share', function (e) { 480 e.preventDefault(); 481 $(this).parent().toggleClass('active'); 482 $(this).parent().find('.social-share').slideToggle(300); 483 }); 484 }, 485 486 toggle_content: function() { 487 var h_desc = $('.single-place .place-content .inner-content .entry-visibility').height(); 488 if( h_desc > 130 ) { 489 $('.single-place .place-content').addClass('on'); 490 } 491 492 $('.show-more').on('click', function(e) { 493 e.preventDefault(); 494 $(this).parents('.place-area').addClass('active'); 495 }); 496 497 $('.hide-all').on('click', function(e) { 498 e.preventDefault(); 499 $(this).parents('.place-area').removeClass('active'); 500 }); 501 502 $('.open-toggle').on('click', function (e) { 503 e.preventDefault(); 504 $(this).parent().toggleClass('active'); 505 }); 506 507 $(document).on('click', function(event){ 508 var $this = $('.form-toggle'); 509 if($this !== event.target && !$this.has(event.target).length){ 510 $this.removeClass('active'); 511 } 512 513 // Update Booking From Guest Text when open 514 var bookingFormGuest = $('.area-booking .btn-quantity'); 515 if (bookingFormGuest) { 516 var val = $(bookingFormGuest).parent().find('input').val(); 517 var name = $(bookingFormGuest).parent().find('input').attr('name'); 518 if( parseInt(val) > 0 ){ 519 $(bookingFormGuest).parents('.area-booking').find('.open-toggle').addClass('active'); 520 $(bookingFormGuest).parents('.area-booking').find('.' + n
520ame + ' span').text(parseInt(val)); 521 }else{ 522 $(bookingFormGuest).parents('.area-booking').find('.open-toggle').removeClass('active'); 523 } 524 } 525 }); 526 527 $('.area-booking').on('click','.btn-quantity', function() { 528 var val = $(this).parent().find('input').val(); 529 var name = $(this).parent().find('input').attr('name'); 530 if( parseInt(val) > 0 ){ 531 $(this).parents('.area-booking').find('.open-toggle').addClass('active'); 532 $(this).parents('.area-booking').find('.' + name + ' span').text(parseInt(val)); 533 }else{ 534 $(this).parents('.area-booking').find('.open-toggle').removeClass('active'); 535 } 536 }); 537 538 $('body').on('click', '.area-booking .plus', function(e) { 539 var input = $(this).parents('.product-quantity').find('.input-text.qty'); 540 var name = $(this).parents('.product-quantity').find('.input-text.qty').attr('name'); 541 var val = parseInt(input.val()) + 1; 542 input.attr('value',val); 543 $(this).parents('.area-booking').find('.open-toggle').addClass('active'); 544 if( val > 0 ){ 545 $(this).parents('.area-booking').find('.' + name + ' span').text(parseInt(val)); 546 }else{ 547 $(this).parents('.area-booking').find('.' + name + ' span').text(0); 548 } 549 }); 550 551 $('body').on('click', '.area-booking .minus', function(e) { 552 var input = $(this).parents('.product-quantity').find('.input-text.qty'); 553 var name = $(this).parents('.product-quantity').find('.input-text.qty').attr('name'); 554 var val = parseInt(input.val()) - 1; 555 556 // Adult cannot be 0 557 if (val == 0 && $(this).parents('.adult').length > 0) { 558 val = 1; 559 } 560 561 if(input.val() > 0) input.attr('value',val); 562 $(this).parents('.area-booking').find('.open-toggle').addClass('active'); 563 if( val > 0 ){ 564 $(this).parents('.area-booking').find('.' + name + ' span').text(parseInt(val)); 565 }else{ 566 $(this).parents('.area-booking').find('.' + name + ' span').text(0); 567 } 568 }); 569 }, 570 571 nav_scroll: function() { 572 $('.nav-scroll a[href^="#"]').on('click', function(event) { 573 event.preventDefault(); 574 var target = $(this.getAttribute('href')); 575 var has_wpadminbar = 0; 576 if($("#wpadminbar").height()) { 577 has_wpadminbar = $("#wpadminbar").height(); 578 } 579 if( target.length ) { 580 if ($(window).width() > 767) { 581 var top = target.offset().top - 15 - has_wpadminbar; 582 } else { 583 var top = target.offset().top - 15 - has_wpadminbar; 584 } 585 $('html, body').stop().animate({ 586 scrollTop: top 587 }, 500); 588 } 589 590 $( '.nav-scroll li' ).removeClass( 'active' ); 591 $( this ).parent().addClass( 'active' ); 592 }); 593 594 $(window).scroll(function() { 595 var scrollDistance = $(window).scrollTop(); 596 597 // Assign active class to nav links while scolling 598 $('.group-field').each(function(i) { 599 if ($(this).offset().top <= scrollDistance + 50) { 600 var href = $(this).attr('id'), 601 id = '#' + href; 602 $('.nav-scroll a').parent().removeClass('active'); 603 $('.nav-scroll a').each(function(){ 604 var attr = $(this).attr('href'); 605 // For some browsers, `attr` is undefined; for others, `attr` is false. Check for both. 606 if ( attr == id ) { 607 // Element has this attribute 608 $(this).parent().addClass('active'); 609 } 610 }); 611 } 612 }); 613 }); 614 }, 615 616 filter_toggle: function() { 617 $('.filter-toggle .golo-filter-toggle').on('click', function() { 618 $(this).toggleClass('active'); 619 $(this).parents('.filter-toggle').find('.golo-menu-filter').slideToggle(200); 620 }); 621 622 $('.filter-dropdown .entry-filter>h4').on('click', function() { 623 $(this).parents('.entry-filter').toggleClass('active'); 624 $(this).parents('.entry-filter').find('.filter-control').slideToggle(200); 625 }); 626 627 $('.btn-canvas-filter').on('click', function(event) { 628 event.preventDefault(); 629 $('body').css('overflow', 'hidden'); 630 $('body').addClass('open-popup'); 631 $(this).toggleClass('active'); 632 $('.archive-filter').toggleClass('open-canvas'); 633 }); 634 635 $('.archive-filter').on('click', '.btn-close,.bg-overlay', function(e) { 636 e.preventDefault(); 637 $('body').css('overflow', 'inherit'); 638 $('body').removeClass('open-popup'); 639 $(this).parents('.archive-filter').removeClass('open-canvas'); 640 $('.btn-canvas-filter').removeClass('active'); 641 }); 642 643 GLF.element.click_outside_filter('.nav-bar .filter-price .entry-filter'); 644 GLF.element.click_outside_filter('.nav-bar .filter-city .entry-filter'); 645 GLF.element.click_outside_filter('.nav-bar .filter-categories .entry-filter'); 646 GLF.element.click_outside_filter('.nav-bar .filter-type .entry-filter'); 647 GLF.element.click_outside_filter('.nav-bar .filter-amenities .entry-filter'); 648 GLF.element.click_outside_filter('.nav-bar .filter-neighborhood .entry-filter'); 649 }, 650 651 click_outside_filter: function(element, child) { 652 $(document).on('click', function(event){ 653 var $this = $(element); 654 if($this !== event.target && !$this.has(event.target).length){ 655 $this.removeClass('active'); 656 $this.find('.filter-control').slideUp(200); 657 } 658 }); 659 }, 660 661 slick_carousel: function() { 662 var rtl = false; 663 if( $( 'body' ).hasClass( 'rtl' ) ) { 664 rtl = true; 665 } 666 $('.golo-slick-carousel').each(function () { 667 var slider = $(this); 668 var defaults = { 669 slidesToShow: 1, 670 slidesToScroll: 1, 671 arrows: true, 672 prevArrow: '<div class="gl-prev slick-arrow"><i class="la la-angle-left large"></i></div>', 673 nextArrow: '<div class="gl-next slick-arrow"><i class="la la-angle-right large"></i></div>', 674 dots: false, 675 fade: false, 676 infinite: false, 677 centerMode: false, 678 adaptiveHeight: true, 679 pauseOnFocus: true, 680 pauseOnHover: true, 681 swipe: true, 682 draggable: true, 683 rtl: rtl, 684 autoplay: false, 685 autoplaySpeed: 250, 686 speed: 250, 687 }; 688 689 if( slider.hasClass('slick-nav') ){ 690 defaults['prevArrow'] = '<div class="gl-prev"><i class="la la-angle-left large"></i></div>'; 691 defaults['nextArrow'] = '<div class="gl-next"><i class="la la-angle-right large"></i></div>'; 692 } 693 694 var config = $.extend({}, defaults, slider.data("slick")); 695 // Initialize Slider 696 slider.slick(config); 697 }); 698 }, 699 700 pagination: function() { 701 $('body').on('click','.golo-pagination.ajax-call a.page-numbers', function(e) { 702 e.preventDefault(); 703 $('.golo-pagination .pagination').addClass('active'); 704 $('.golo-pagination li .page-numbers').removeClass('current'); 705 $(this).addClass('current'); 706 var paged = $(this).text(); 707 var current_page = 1; 708 if( $('.golo-pagination').find('input[name="paged"]').val() ) { 709 current_page = $('.golo-pagination').find('input[name="paged"]').val(); 710 } 711 if( $(this).hasClass('next') ){ 712 paged = parseInt(current_page) + 1; 713 } 714 if( $(this).hasClass('prev') ){ 715 paged = parseInt(current_page) - 1; 716 } 717 $('.golo-pagination').find('input[name="paged"]').val(paged); 718 ajax_call = true; 719 if( $(this).attr('data-type') == 'number' ){ 720 GLF.element.scroll_to('.area-places'); 721 GLF.element.ajax_load(ajax_call); 722 }else{ 723 GLF.element.ajax_load(ajax_call, 'loadmore'); 724 } 725 726 }); 727 }, 728 729 filter_single: function() { 730 $('.golo-menu-filter ul.filter-control a').on('click', function(e) { 731 e.preventDefault(); 732 $('.golo-pagination').find('input[name="paged"]').val(1); 733 if( $(this).parent().hasClass('active') ){ 734 $(this).parents('.golo-menu-filter ul.filter-control').find('li').removeClass('active'); 735 $(this).closest('.entry-filter').removeClass('open'); 736 }else{ 737 $(this).parents('.golo-menu-filter ul.filter-control').find('li').removeClass('active'); 738 $(this).parent().addClass('active'); 739 $(this).closest('.entry-filter').addClass('open'); 740 } 741 ajax_call = true; 742 GLF.element.ajax_load(ajax_call); 743 }); 744 }, 745 746 display_clear: function() { 747 if( $('.golo-menu-filter ul.filter-control li.active').length > 0 ){ 748 $('.golo-nav-filter').addClass('active'); 749 }else{ 750 $('.golo-nav-filter').removeClass('active'); 751 } 752 753 $('.golo-menu-filter input[type="checkbox"]:checked').each( function() { 754 if ( $(this).length > 0 ) { 755 $('.golo-nav-filter').addClass('active'); 756 $(this).closest('.entry-filter').addClass('open'); 757 }else{ 758 $('.golo-nav-filter').removeClass('active'); 759 $(this).closest('.entry-filter').removeClass('open'); 760 } 761 }); 762 763 $('.golo-menu-filter .entry-filter').each( function() { 764 if ( $(this).find('input[type="checkbox"]:checked').length > 0 ) { 765 $(this).addClass('open'); 766 }else{ 767 $(this).removeClass('open'); 768 } 769 770 if( $(this).closest('.filter-price').length > 0 ) { 771 if( $(this).find('ul.filter-control li.active').length > 0 ){ 772 $(this).addClass('open'); 773 }else{ 774 $(this).removeClass('open'); 775 } 776 } 777 }); 778 }, 779 780 filter_clear: function() { 781 $('.golo-clear-filter').on('click', function() { 782 $('.golo-menu-filter ul.filter-control li').removeClass('active'); 783 $('.golo-menu-filter input[type="checkbox"]').prop('checked', false); 784 ajax_call = true; 785 GLF.element.ajax_load(ajax_call); 786 }); 787 }, 788 789 790 ajax_load: function(ajax_call, pagination) { 791 var title, height, sortby, price, sort_by, cities, categories, types, place_type, amenities, neighborhood, current_term, type_term, city, location, place_layout, open_now; 792 var paged = 1; 793 var map_html = $( '.maptype' ).clone(); 794 height = $('.area-places').height(); 795 796 paged = $('.golo-pagination').find('input[name="paged"]').val(); 797 title = $('input[name="title"]').val(); 798 current_term = $('input[name="current_term"]').val(); 799 type_term = $('input[name="type_term"]').val(); 800 city = $('input[name="city"]').val(); 801 location = $('input[name="place_location"]').val(); 802 place_type = $('input[name="place_type"]').val(); 803 place_layout = $('.place-layout a.active').attr('data-layout'); 804 open_now = $('.filter-open-time a.open-filter').attr('data-open'); 805 806 price = menu_filter_wrap.find('.price.filter-control li.active a').data('price'); 807 sort_by = menu_filter_wrap.find('.sort-by.filter-control li.active a').data('sort'); 808 809 var select_sort = $('.archive-layout select[name="sort_by"]').val(); 810 if( select_sort ) { 811 sort_by = select_sort; 812 } 813 814 if( price ) { 815 menu_filter_wrap.find('.price-filter').hide(); 816 menu_filter_wrap.find('.price-filter').removeClass('active'); 817 }else{ 818 menu_filter_wrap.find('.price-filter').show(); 819 } 820 821 var cities = []; 822 menu_filter_wrap.find("input[name='cities']:checked").each(function () 823 { 824 cities.push(parseInt($(this).val())); 825 }); 826 827 var categories = []; 828 829 menu_filter_wrap.find("input[name='categories']:checked").each(function () 830 { 831 categories.push(parseInt($(this).val())); 832 }); 833 834 var types = []; 835 menu_filter_wrap.find("input[name='types']:checked").each(function () 836 { 837 types.push(parseInt($(this).val())); 838 }); 839 840 var amenities = []; 841 842 $( '.left' ).find(".golo-menu-filter input[name='amenities']:checked").each(function () 843 { 844 amenities.push($(this).val()); 845 }); 846 847 if (amenities.length === 0) { 848 $( '.col-left' ).find(".golo-menu-filter input[name='amenities']:checked").each(function () 849 { 850 amenities.push($(this).val()); 851 }); 852 } 853 854 var neighborhood = []; 855 menu_filter_wrap.find("input[name='neighborhood']:checked").each(function () 856 { 857 neighborhood.push(parseInt($(this).val())); 858 }); 859 860 var maptype = $( '.maptype' ).data( 'maptype' ); 861 862 var review_status = $( '.maptype' ).parents( '.filter-place-search' ).data( 'review' ); 863 864 if ( maptype == 'google_map' ) { 865 866 var marker_cluster = null, 867 googlemap_default_zoom = golo_template_vars.googlemap_default_zoom, 868 not_found = golo_template_vars.not_found, 869 clusterIcon = golo_template_vars.clusterIcon, 870 google_map_style = golo_template_vars.google_map_style, 871 google_map_type = golo_template_vars.google_map_type, 872 pin_cluster_enable = golo_template_vars.pin_cluster_enable; 873 874 var infowindow = new google.maps.InfoWindow({ 875 maxWidth: 370, 876 }); 877 878 var silver = [ 879 { 880 "featu
880reType": "landscape", 881 "elementType": "labels", 882 "stylers": [ 883 { 884 "visibility": "off" 885 } 886 ] 887 }, 888 { 889 "featureType": "transit", 890 "elementType": "labels", 891 "stylers": [ 892 { 893 "visibility": "off" 894 } 895 ] 896 }, 897 { 898 "featureType": "poi", 899 "elementType": "labels", 900 "stylers": [ 901 { 902 "visibility": "off" 903 } 904 ] 905 }, 906 { 907 "featureType": "water", 908 "elementType": "labels", 909 "stylers": [ 910 { 911 "visibility": "off" 912 } 913 ] 914 }, 915 { 916 "featureType": "road", 917 "elementType": "labels.icon", 918 "stylers": [ 919 { 920 "visibility": "off" 921 } 922 ] 923 }, 924 { 925 "stylers": [ 926 { 927 "hue": "#00aaff" 928 }, 929 { 930 "saturation": -100 931 }, 932 { 933 "gamma": 2.15 934 }, 935 { 936 "lightness": 12 937 } 938 ] 939 }, 940 { 941 "featureType": "road", 942 "elementType": "labels.text.fill", 943 "stylers": [ 944 { 945 "visibility": "on" 946 }, 947 { 948 "lightness": 24 949 } 950 ] 951 }, 952 { 953 "featureType": "road", 954 "elementType": "geometry", 955 "stylers": [ 956 { 957 "lightness": 57 958 } 959 ] 960 } 961 ]; 962 963 if( has_map ) { 964 var golo_search_map_option = { 965 scrollwheel: true, 966 scroll: {x: $(window).scrollLeft(), y: $(window).scrollTop()}, 967 zoom: parseInt(googlemap_default_zoom), 968 mapTypeId: google_map_type, 969 draggable: drgflag, 970 fullscreenControl: true, 971 styles: silver, 972 mapTypeControl: false, 973 zoomControlOptions: { 974 position: google.maps.ControlPosition.RIGHT_BOTTOM 975 }, 976 fullscreenControlOptions: { 977 position: google.maps.ControlPosition.RIGHT_BOTTOM 978 } 979 }; 980 } 981 982 var golo_input_search = function(map) { 983 // Create the search box and link it to the UI element. 984 var input = document.getElementById('pac-input'); 985 var searchBox = new google.maps.places.SearchBox(input); 986 golo_map.controls[google.maps.ControlPosition.TOP_LEFT].push(input); 987 988 // Bias the SearchBox results towards current map's viewport. 989 golo_map.addListener('bounds_changed', function() { 990 searchBox.setBounds(golo_map.getBounds()); 991 }); 992 993 // Listen for the event fired when the user selects a prediction and retrieve 994 // more details for that place. 995 searchBox.addListener('places_changed', function() { 996 var places = searchBox.getPlaces(); 997 998 if ( places.length == 0 ) { 999 return; 1000 } 1001 1002 // Clear out the old markers.
1003 search_markers.forEach(function(marker) { 1004 marker.setMap(null); 1005 }); 1006 search_markers = []; 1007 1008 // For each place, get the icon, name and location. 1009 var bounds = new google.maps.LatLngBounds(); 1010 places.forEach(function(place) { 1011 if ( !place.geometry ) { 1012 console.log("Returned place contains no geometry"); 1013 return; 1014 } 1015 var icon = { 1016 url: place.icon, 1017 size: new google.maps.Size(71, 71), 1018 origin: new google.maps.Point(0, 0), 1019 anchor: new google.maps.Point(17, 34), 1020 scaledSize: new google.maps.Size(25, 25) 1021 }; 1022 1023 // Create a marker for each place. 1024 search_markers.push(new google.maps.Marker({ 1025 map: golo_map, 1026 icon: icon, 1027 title: place.name, 1028 position: place.geometry.location 1029 })); 1030 1031 if (place.geometry.viewport) { 1032 bounds.union(place.geometry.viewport); 1033 } else { 1034 bounds.extend(place.geometry.location); 1035 } 1036 }); 1037 1038 golo_map.fitBounds(bounds); 1039 }); 1040 } 1041 1042 var golo_add_markers = function(props, map) { 1043 $.each(props, function(i, prop) { 1044 var latlng = new google.maps.LatLng(prop.lat, prop.lng), 1045 marker_url = prop.marker_icon, 1046 marker_size = new google.maps.Size(60, 60); 1047 var marker_icon = { 1048 url: marker_url, 1049 size: marker_size, 1050 scaledSize: new google.maps.Size(40, 40), 1051 origin: new google.maps.Point(-10, -10), 1052 anchor: new google.maps.Point(7, 27) 1053 }; 1054 1055 var marker = new google.maps.Marker({ 1056 position: latlng, 1057 url: '.place-' + prop.id, 1058 map: map, 1059 icon: marker_icon, 1060 draggable: false, 1061 title: 'marker' + prop.id, 1062 animation: google.maps.Animation.DROP 1063 }); 1064 1065 var prop_title = prop.data ? prop.data.post_title : prop.title; 1066 var rating_html = ''; 1067 if( prop.rating ) { 1068 rating_html = 1069 '<div class="place-rating">' + 1070 '<span>' + prop.rating + '</span>' + 1071 '<i class="la la-star"></i>' + 1072 '</div>'; 1073 } 1074 1075 var contentString = document.createElement("div"); 1076 contentString.className = 'golo-marker'; 1077 contentString.innerHTML = 1078 '<div class="inner-marker">' + 1079 '<div class="entry-thumbnail">' + 1080 '<a href="' + prop.url + '">' + 1081 '<img src="' + prop.image_url + '" alt="' + prop_title + '">' + 1082 '</a>' + 1083 '</div>' + 1084 '<div class="entry-detail">' + 1085 '<div class="entry-head">' + 1086 '<div class="place-cate list-item">' + 1087 prop.cate + 1088 '</div>' + 1089 '<div class="place-title">' + 1090 '<h3 class="entry-title"><a href="' + prop.url + '">' + prop_title + '</a></h3>' + 1091 '</div>' + 1092 '</div>' + 1093 '<div class="entry-bottom">' + 1094 '<div class="place-preview ' + review_status + '">' + 1095 rating_html + 1096 '<span class="place-reviews">(' + prop.review + ' reviews)</span>' + 1097 '</div>' + 1098 '<div class="place-price">' + 1099 '<span>' + prop.price + '</span>' + 1100 '</div>' + 1101 '</div>' + 1102 '</div>' + 1103 '</div>'; 1104 1105 marker.addListener('mouseover', function() { 1106 click_marker = true; 1107 }); 1108 1109 marker.addListener('mouseout', function() { 1110 click_marker = false; 1111 }); 1112 1113 google.maps.event.addListener(marker, 'click', function() { 1114 1115 infowindow.close(); 1116 infowindow.setContent(contentString); 1117 infowindow.open(map,marker); 1118 1119 var scale = Math.pow(2, map.getZoom()), 1120 offsety = ( (30 / scale) || 0 ), 1121 projection = map.getProjection(), 1122 markerPosition = marker.getPosition(), 1123 markerScreenPosition = projection.fromLatLngToPoint(markerPosition), 1124 pointHalfScreenAbove = new google.maps.Point(markerScreenPosition.x, markerScreenPosition.y - offsety), 1125 aboveMarkerLatLng = projection.fromPointToLatLng(pointHalfScreenAbove); 1126 map.panTo(aboveMarkerLatLng); 1127 1128 var elem = $(marker.url); 1129 $('.area-places .place-item').removeClass('highlight'); 1130 if( elem.length > 0 && click_marker && $('.archive-place.map-event').length > 0 ) { 1131 elem.addClass('highlight'); 1132 $('html, body').animate({ 1133 scrollTop: elem.offset().top - 50 1134 }, 500 ); 1135 } 1136 }); 1137 1138 markers.push(marker); 1139 }); 1140 }; 1141 1142 var golo_my_location = function(map) { 1143 1144 var my_location = {}; 1145 var my_lat = ''; 1146 var my_lng = ''; 1147 1148 if (navigator.geolocation) { 1149 navigator.geolocation.getCurrentPosition(function(position) { 1150 var pos = { 1151 lat: position.coords.latitude, 1152 lng: position.coords.longitude 1153 }; 1154 1155 my_lat = position.coords.latitude; 1156 my_lng = position.coords.longitude; 1157 1158 my_location = { lat: parseFloat(my_lat),lng: parseFloat(my_lng) }; 1159 1160 }, function() { 1161 handleLocationError(true, infowindow, map.getCenter()); 1162 }); 1163 } else { 1164 // Browser doesn't support Geolocation 1165 handleLocationError(false, infowindow, map.getCenter()); 1166 } 1167 1168 function CenterControl(controlDiv, map) { 1169 1170 // Set CSS for the control border. 1171 const controlUI = document.createElement("div"); 1172 controlUI.style.backgroundColor = "#fff"; 1173 controlUI.style.border = "2px solid #fff"; 1174 controlUI.style.borderRadius = "3px"; 1175 controlUI.style.boxShadow = "0 2px 6px rgba(0,0,0,.3)"; 1176 controlUI.style.cursor = "pointer"; 1177 controlUI.style.width = "40px"; 1178 controlUI.style.height = "40px"; 1179 controlUI.style.margin = "10px"; 1180 controlUI.style.textAlign = "center"; 1181 controlUI.title = "My location"; 1182 controlDiv.appendChild(controlUI); 1183 1184 // Set CSS for the control interior. 1185 const controlText = document.createElement("div"); 1186 controlText.style.fontSize = "18px"; 1187 controlText.style.lineHeight = "37px"; 1188 controlText.style.paddingLeft = "5px"; 1189 controlText.style.paddingRight = "5px"; 1190 controlText.innerHTML = "<i class='fas fa-location'></i>"; 1191 controlUI.appendChild(controlText); 1192 1193 var marker_icon = { 1194 url: default_icon, 1195 scaledSize: new google.maps.Size(40, 40), 1196 origin: new google.maps.Point(0, 0), 1197 anchor: new google.maps.Point(7, 27) 1198 }; 1199 1200 // Setup the click event listeners: simply set the map to Chicago. 1201 controlUI.addEventListener('click', () => { 1202 var current_location = new google.maps.Marker({ 1203 position: my_location, 1204 map, 1205 icon: marker_icon 1206 }); 1207 1208 infowindow.setPosition(my_location); 1209 infowindow.setContent('<div class="default-result">Your location.</div>'); 1210 //infowindow.open(map); 1211 map.panTo(my_location); 1212 }); 1213 } 1214 1215 const centerControlDiv = document.createElement("div"); 1216 CenterControl(centerControlDiv, map); 1217 1218 centerControlDiv.index = 1; 1219 map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(centerControlDiv); 1220 1221 function handleLocationError(browserHasGeolocation, infowindow, pos) { 1222 infowindow.setPosition(pos); 1223 infowindow.setContent(browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.'); 1224 infowindow.open(map); 1225 } 1226 1227 }; 1228 1229 var golo_infowindow_hover_trigger = function() { 1230 1231 $('.map-event .area-places .place-item').each(function(i) { 1232 var index = i; 1233 1234 $(this).on('mouseenter', function() { 1235 var title = $( this ).find( '.golo-add-to-wis
1235hlist' ).data( 'place-id' ); 1236 if(golo_map) { 1237 if( paged > 1 ) { 1238 index = i + (item_amount * (paged - 1 )); 1239 } 1240 $( 'div[title="marker' + title + '"]' ).trigger('click'); 1241 } 1242 }); 1243 1244 $(this).on('mouseleave', function() { 1245 infowindow.open(null,null); 1246 }); 1247 }); 1248 1249 $('.map-event-zoom .area-places .place-item').each(function(i) { 1250 var index = i; 1251 1252 $(this).on('mouseenter', function() { 1253 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1254 if(golo_map) { 1255 if( paged > 1 ) { 1256 index = i + (item_amount * (paged - 1 )); 1257 } 1258 $( 'div[title="marker' + title + '"]' ).addClass('zoom'); 1259 } 1260 }); 1261 1262 $(this).on('mouseleave', function() { 1263 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1264 $( 'div[title="marker' + title + '"]' ).removeClass('zoom'); 1265 }); 1266 }); 1267 return false; 1268 }; 1269 1270 var golo_infowindow_scroll_trigger = function() { 1271 var $elem = $('.area-places').find( '.place-item' ); 1272 1273 var waypoints_map = $elem.waypoint(function(direction) { 1274 if (direction === 'down') { 1275 if( golo_map ) { 1276 google.maps.event.trigger(markers[$(this.element).index()], 'click'); 1277 } 1278 } else if (direction === 'up') { 1279 if( golo_map ) { 1280 google.maps.event.trigger(markers[$(this.element).prev().index()], 'click'); 1281 } 1282 } 1283 }, { 1284 offset: '50%', 1285 triggerOnce: true 1286 }); 1287 }; 1288 1289 1290 } else if ( maptype == 'openstreetmap' ) { 1291 1292 // Begin Openstreetmap 1293 1294 var golo_osm_add_markers = function(props, maps) { 1295 1296 $( '.maptype' ).remove(); 1297 $( map_html ).insertAfter( "#pac-input" ); 1298 1299 var osm_api = $( '#maps' ).data( 'key' ); 1300 var osm_level = $( '#maps' ).data( 'level' ); 1301 var osm_style = $( '#maps' ).data( 'style' ); 1302 1303 var features_info = []; 1304 var lng_args = []; 1305 var lat_args = []; 1306 1307 1308 $.each(props, function(i, prop) { 1309 1310 features_info.push( 1311 { 1312 "type": "Feature", 1313 "geometry": { 1314 "type": "Point", 1315 "coordinates": [ 1316 prop.lat, 1317 prop.lng 1318 ] 1319 }, 1320 "properties": { 1321 "iconSize": [40, 40], 1322 "id": prop.id, 1323 "icon": prop.marker_icon, 1324 "url": prop.url, 1325 "image_url": prop.image_url, 1326 "title": prop.title, 1327 "cate": prop.cate, 1328 "rating": prop.rating, 1329 "review": prop.review, 1330 "price": prop.price, 1331 } 1332 } 1333 ); 1334 1335 lng_args.push(prop.lng); 1336 lat_args.push(prop.lat); 1337 1338 }); 1339 1340 var stores = { 1341 "type": "FeatureCollection", 1342 "features": features_info 1343 }; 1344 1345 var sum_lng = 0; 1346 for( var i = 0; i < lng_args.length; i++ ){ 1347 sum_lng += parseFloat( lng_args[i], 10 ); 1348 } 1349 1350 var avg_lng = 0; 1351 1352 if( sum_lng/lng_args.length ){ 1353 avg_lng = sum_lng/lng_args.length; 1354 } 1355 1356 1357 var sum_lat = 0; 1358 for( var i = 0; i < lat_args.length; i++ ){ 1359 sum_lat += parseFloat( lat_args[i], 10 ); 1360 } 1361 1362 var avg_lat = 0; 1363 1364 if( sum_lat/lat_args.length ){ 1365 avg_lat = sum_lat/lat_args.length; 1366 } 1367 1368 var container = L.DomUtil.get('maps'); if(container != null){ container._leaflet_id = null; } 1369 1370 $( '.leaflet-map-pane' ).remove(); 1371 $( '.leaflet-control-container' ).remove(); 1372 1373 var osm_map = new L.map('maps'); 1374 1375 osm_map.on('load', onMapLoad); 1376
1377 osm_map.setView([avg_lat, avg_lng], osm_level); 1378 1379 1380 function onMapLoad(){ 1381 1382 var titleLayer_id = 'mapbox/' + osm_style; 1383 1384 L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=' + osm_api, { 1385 attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', 1386 id: titleLayer_id, 1387 tileSize: 512, 1388 zoomOffset: -1, 1389 accessToken: osm_api 1390 }).addTo(osm_map); 1391 1392 /** 1393 * Add all the things to the page: 1394 * - The location listings on the side of the page 1395 * - The markers onto the map 1396 */ 1397 addMarkers(); 1398 1399 // $( '.leaflet-marker-icon' ).each( function() { 1400 // $( this ).wrap( '<div class="leaflet-marker-icon-wrap"></div>' ); 1401 // }); 1402 1403 $('.map-event .area-places .place-item').each(function(i) { 1404 var index = i; 1405 1406 $(this).on('mouseenter', function() { 1407 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1408 if(osm_map) { 1409 if( paged > 1 ) { 1410 index = i + (item_amount * (paged - 1 )); 1411 } 1412 $( ".marker-" + title ).trigger( "click" ); 1413 } 1414 }); 1415 1416 $(this).on('mouseleave', function() { 1417 $( ".leaflet-popup-close-button" )[0].click(); 1418 }); 1419 }); 1420 $('.map-event-zoom .area-places .place-item').each(function(i) { 1421 var index = i; 1422 1423 $(this).on('mouseenter', function() { 1424 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1425 if(osm_map) { 1426 if( paged > 1 ) { 1427 index = i + (item_amount * (paged - 1 )); 1428 } 1429 $( ".marker-" + title ).addClass( 'zoom' ); 1430 } 1431 }); 1432 1433 $(this).on('mouseleave', function() { 1434 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1435 $( ".marker-" + title ).removeClass( 'zoom' ); 1436 }); 1437 }); 1438 }; 1439 1440 function flyToStore(currentFeature) { 1441 osm_map.flyTo(currentFeature.geometry.coordinates, osm_level); 1442 } 1443 1444 /* This will let you use the .remove() function later on */ 1445 if (!('remove' in Element.prototype)) { 1446 Element.prototype.remove = function() { 1447 if (this.parentNode) { 1448 this.parentNode.removeChild(this); 1449 } 1450 }; 1451 } 1452 1453 function addMarkers() { 1454 1455 /* For each feature in the GeoJSON object above: */ 1456 stores.features.forEach(function(marker) { 1457 /* Create a div element for the marker. */ 1458 var el = document.createElement('div'); 1459 /* Assign a unique `id` to the marker. */ 1460 el.id = "marker-" + marker.properties.id; 1461 /* Assign the `marker` class to each marker for styling. */ 1462 el.className = 'marker'; 1463 el.style.backgroundImage = 'url(' + marker.properties.icon + ')'; 1464 el.style.width = marker.properties.iconSize[0] + 'px'; 1465 el.style.height = marker.properties.iconSize[1] + 'px'; 1466 /** 1467 * Create a marker using the div element 1468 * defined above and add it to the map. 1469 **/ 1470 var icon = L.divIcon({ 1471 className: 'marker-' + marker.properties.id, 1472 html: '<div><img src="' + marker.properties.icon + '" alt=""></div>', 1473 iconSize: [40, 40], 1474 shadowSize: [50, 64], 1475 iconAnchor: [22, 94], 1476 shadowAnchor: [4, 62], 1477 popupAnchor: [-3, -76] 1478 }); 1479 var rating_html = ''; 1480 if( marker.properties.rating ) { 1481 rating_html = 1482 '<div class="place-rating">' + 1483 '<span>' + marker.properties.rating + '</span>' + 1484 '<i class="la la-star"></i>' + 1485 '</div>'; 1486 } 1487 1488 new L.marker([marker.geometry.coordinates[0], marker.geometry.coordinates[1]], {icon: icon}).addTo(osm_map).bindPopup( '<div class="golo-marker"><div class="inner-marker">' +
1489 '<div class="entry-thumbnail">' + 1490 '<a href="' + marker.properties.url + '">' + 1491 '<img src="' + marker.properties.image_url + '" alt="' + marker.properties.title + '">' + 1492 '</a>' + 1493 '</div>' + 1494 '<div class="entry-detail">' + 1495 '<div class="entry-head">' + 1496 '<div class="place-cate list-item">' + 1497 marker.properties.cate + 1498 '</div>' + 1499 '<div class="place-title">' + 1500 '<h3 class="entry-title"><a href="' + marker.properties.url + '">' + marker.properties.title + '</a></h3>' + 1501 '</div>' + 1502 '</div>' + 1503 '<div class="entry-bottom">' + 1504 '<div class="place-preview ' + review_status + '">' + 1505 rating_html + 1506 '<span class="place-reviews">(' + marker.properties.review + ' reviews)</span>' + 1507 '</div>' + 1508 '<div class="place-price">' + 1509 '<span>' + marker.properties.price + '</span>' + 1510 '</div>' + 1511 '</div>' + 1512 '</div>' + 1513 '</div></div>', { maxWidth : 325 } ); 1514 1515 el.addEventListener('click', function(e){ 1516 /* Fly to the point */ 1517 flyToStore(marker); 1518 /* Highlight listing in sidebar */ 1519 var activeItem = document.getElementsByClassName('active'); 1520 e.stopPropagation(); 1521 if (activeItem[0]) { 1522 activeItem[0].classList.remove('active'); 1523 } 1524 }); 1525 }); 1526 } 1527 1528 }; 1529 1530 // End Openstreetmap 1531 1532 } else { 1533 1534 // Begin Mapbox 1535 1536 var golo_mapbox_add_markers = function(props, map) { 1537 var mapbox_api = $( '#map' ).data( 'key' ); 1538 var mapbox_level = $( '#map' ).data( 'level' ); 1539 var mapbox_type = $( '#map' ).data( 'type' ); 1540 mapboxgl.accessToken = mapbox_api; 1541 $( '.mapboxgl-canary' ).remove(); 1542 $( '.mapboxgl-canvas-container' ).remove(); 1543 $( '.mapboxgl-control-container' ).remove(); 1544 var features_info = []; 1545 var lng_args = []; 1546 var lat_args = []; 1547 1548 $.each(props, function(i, prop) { 1549 1550 features_info.push( 1551 { 1552 "type": "Feature", 1553 "geometry": { 1554 "type": "Point", 1555 "coordinates": [ 1556 prop.lng, 1557 prop.lat 1558 ] 1559 }, 1560 "properties": { 1561 "iconSize": [40, 40], 1562 "id": prop.id, 1563 "icon": prop.marker_icon, 1564 "url": prop.url, 1565 "image_url": prop.image_url, 1566 "title": prop.title, 1567 "cate": prop.cate, 1568 "rating": prop.rating, 1569 "review": prop.review, 1570 "price": prop.price, 1571 } 1572 } 1573 ); 1574 1575 lng_args.push(prop.lng); 1576 lat_args.push(prop.lat); 1577 1578 }); 1579 1580 var sum_lng = 0; 1581 for( var i = 0; i < lng_args.length; i++ ){ 1582 sum_lng += parseFloat( lng_args[i] ); 1583 } 1584 1585 var avg_lng = 0; 1586 1587 if( sum_lng/lng_args.length ){ 1588 avg_lng = sum_lng/lng_args.length; 1589 } 1590 1591 1592 var sum_lat = 0; 1593 for( var i = 0; i < lat_args.length; i++ ){ 1594 sum_lat += parseFloat( lat_args[i] ); 1595 } 1596 1597 var avg_lat = 0; 1598 1599 if( sum_lat/lat_args.length ){ 1600 avg_lat = sum_lat/lat_args.length; 1601 } 1602 1603 var map = new mapboxgl.Map({ 1604 container: 'map', 1605 style: 'mapbox://styles/mapbox/' + mapbox_type, 1606 zoom: mapbox_level, 1607 center: [avg_lng, avg_lat], 1608 }); 1609 1610 map.addControl(new mapboxgl.NavigationControl()); 1611 1612 var stores = { 1613 "type": "FeatureCollection", 1614 "features": features_info 1615 }; 1616 1617 /** 1618 * Wait until the map loads to make changes to the map. 1619 */ 1620 map.on('load', function (e) { 1621 /** 1622 * This is where your '.addLayer()' used to be, instead 1623 * add only the source without styling a layer 1624 */ 1625 map.addLayer({ 1626 "id": "locations", 1627 "type": "symbol", 1628 /* Add a GeoJSON source containing place coordinates and information. */ 1629 "source": { 1630 "type": "geojson", 1631 "data": stores 1632 }, 1633 "layout": { 1634 "icon-image": "", 1635 "icon-allow-overlap": true, 1636 } 1637 }); 1638 1639 /** 1640 * Add all the things to the page: 1641 * - The location listings on the side of the page 1642 * - The markers onto the map 1643 */ 1644 addMarkers(); 1645 1646 $('.map-event .area-places .place-item').each(function(i) { 1647 var index = i; 1648 1649 $(this).on('mouseenter', function() { 1650 var title = $( this ).find( '.golo-add-to-wis
1650hlist' ).data( 'place-id' ); 1651 if(map) { 1652 if( paged > 1 ) { 1653 index = i + (item_amount * (paged - 1 )); 1654 } 1655 $( "#marker-" + title ).trigger( "click" ); 1656 } 1657 }); 1658 1659 $(this).on('mouseleave', function() { 1660 $( ".mapboxgl-popup-close-button" ).trigger( "click" ); 1661 }); 1662 }); 1663 1664 $('.map-event-zoom .area-places .place-item').each(function(i) { 1665 var index = i; 1666 1667 $(this).on('mouseenter', function() { 1668 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1669 if(map) { 1670 if( paged > 1 ) { 1671 index = i + (item_amount * (paged - 1 )); 1672 } 1673 $( "#marker-" + title ).addClass( 'zoom' ); 1674 } 1675 }); 1676 1677 $(this).on('mouseleave', function() { 1678 var title = $( this ).find( '.golo-add-to-wishlist' ).data( 'place-id' ); 1679 $( "#marker-" + title ).removeClass( 'zoom' ); 1680 }); 1681 }); 1682 }); 1683 1684 function flyToStore(currentFeature) { 1685 map.flyTo({ 1686 center: currentFeature.geometry.coordinates, 1687 bearing: 0, 1688 duration: 0, 1689 speed: 0.2, 1690 curve: 1, 1691 easing: function (t) { 1692 return t; 1693 } 1694 }); 1695 } 1696 1697 function createPopUp(currentFeature) { 1698 var popUps = document.getElementsByClassName('mapboxgl-popup'); 1699 /** Check if there is already a popup on the map and if so, remove it */ 1700 if (popUps[0]) popUps[0].remove(); 1701 1702 var rating_html = ''; 1703 if( currentFeature.properties.rating ) { 1704 rating_html = 1705 '<div class="place-rating">' + 1706 '<span>' + currentFeature.properties.rating + '</span>' + 1707 '<i class="la la-star"></i>' + 1708 '</div>'; 1709 } 1710 1711 var popup = new mapboxgl.Popup({ closeOnClick: false }) 1712 .setLngLat(currentFeature.geometry.coordinates) 1713 .setHTML('<div class="golo-marker"><div class="inner-marker">' + 1714 '<div class="entry-thumbnail">' + 1715 '<a href="' + currentFeature.properties.url + '">' + 1716 '<img src="' + currentFeature.properties.image_url + '" alt="' + currentFeature.properties.title + '">' + 1717 '</a>' + 1718 '</div>' + 1719 '<div class="entry-detail">' + 1720 '<div class="entry-head">' + 1721 '<div class="place-cate list-item">' + 1722 currentFeature.properties.cate + 1723 '</div>' + 1724 '<div class="place-title">' + 1725 '<h3 class="entry-title"><a href="' + currentFeature.properties.url + '">' + currentFeature.properties.title + '</a></h3>' + 1726 '</div>' + 1727 '</div>' + 1728 '<div class="entry-bottom">' + 1729 '<div class="place-preview ' + review_status + '">' + 1730 rating_html + 1731 '<span class="place-reviews">(' + currentFeature.properties.review + ' reviews)</span>' + 1732 '</div>' + 1733 '<div class="place-price">' + 1734 '<span>' + currentFeature.properties.price + '</span>' + 1735 '</div>' + 1736 '</div>' + 1737 '</div>' + 1738 '</div></div>') 1739 .addTo(map); 1740 } 1741 1742 /* This will let you use the .remove() function later on */ 1743 if (!('remove' in Element.prototype)) { 1744 Element.prototype.remove = function() { 1745 if (this.parentNode) { 1746 this.parentNode.removeChild(this); 1747 } 1748 }; 1749 } 1750 1751 1752 map.on('click', function(e) { 1753 /* Determine if a feature in the "locations" layer exists at that point. */ 1754 var features = map.queryRenderedFeatures(e.point, { 1755 layers: ['locations'] 1756 }); 1757 1758 /* If yes, then: */ 1759 if (features.length) { 1760 var clickedPoint = features[0]; 1761 1762 /* Fly to the point */ 1763 flyToStore(clickedPoint); 1764 1765 /* Close all other popups and display popup for clicked store */ 1766 createPopUp(clickedPoint); 1767 1768 } 1769 }); 1770 1771 1772 1773 function addMarkers() { 1774 /* For each feature in the GeoJSON object above: */
1775 stores.features.forEach(function(marker) { 1776 /* Create a div element for the marker. */ 1777 var el = document.createElement('div'); 1778 /* Assign a unique `id` to the marker. */ 1779 el.id = "marker-" + marker.properties.id; 1780 /* Assign the `marker` class to each marker for styling. */ 1781 el.className = 'marker'; 1782 el.style.backgroundImage = 'url(' + marker.properties.icon + ')'; 1783 el.style.width = marker.properties.iconSize[0] + 'px'; 1784 el.style.height = marker.properties.iconSize[1] + 'px'; 1785 /** 1786 * Create a marker using the div element 1787 * defined above and add it to the map. 1788 **/ 1789 new mapboxgl.Marker(el, { offset: [0, -23] }) 1790 .setLngLat(marker.geometry.coordinates) 1791 .addTo(map); 1792 1793 el.addEventListener('click', function(e){ 1794 /* Fly to the point */ 1795 flyToStore(marker); 1796 /* Close all other popups and display popup for clicked store */ 1797 createPopUp(marker); 1798 /* Highlight listing in sidebar */ 1799 var activeItem = document.getElementsByClassName('active'); 1800 e.stopPropagation(); 1801 if (activeItem[0]) { 1802 activeItem[0].classList.remove('active'); 1803 } 1804 }); 1805 }); 1806 } 1807 }; 1808 1809 // End Mapbox 1810 1811 } 1812 1813 GLF.element.display_clear(); 1814 1815 var page_item = $('.area-places').attr('data-item-amount'); 1816 1817 if( page_item ) { 1818 item_amount = page_item; 1819 } 1820 1821 var type_pagination = $('.golo-pagination').attr('data-type'); 1822 $('.area-places .place-item').addClass('skeleton-loading'); 1823 1824 $.ajax({
1825 dataType: 'json', 1826 url: ajax_url, 1827 data: { 1828 'action': 'golo_pagination_ajax', 1829 'paged': paged, 1830 'title': title, 1831 'item_amount': item_amount, 1832 'price': price, 1833 'sort_by': sort_by, 1834 'cities': cities, 1835 'categories': categories, 1836 'types': types, 1837 'amenities': amenities, 1838 'neighborhood': neighborhood, 1839 'current_term': current_term, 1840 'type_term': type_term, 1841 'city': city, 1842 'location': location, 1843 'place_type': place_type, 1844 'place_layout': place_layout, 1845 'open_now': open_now, 1846 }, 1847 beforeSend: function () { 1848 $('.filter-place-search .golo-loading-effect').fadeIn(); 1849 }, 1850 success: function(data) { 1851 if ( maptype == 'google_map' ) { 1852 1853 if( has_map ) { 1854 1855 golo_map = new google.maps.Map(document.getElementById('place-map-filter'), golo_search_map_option); 1856 1857 //golo_input_search(golo_map); 1858 google.maps.event.trigger(golo_map, 'resize'); 1859 if( data.success === true ) { 1860 if ( data.places ) { 1861 var count_places = data.places.length; 1862 } 1863 } 1864 1865 if( count_places == 1 ) { 1866 var boundsListener = google.maps.event.addListener((golo_map), 'bounds_changed', function (event) { 1867 this.setZoom(parseInt(googlemap_default_zoom)); 1868 google.maps.event.removeListener(boundsListener); 1869 }); 1870 } 1871 1872 if( google_map_style !== '' ) { 1873 var styles = JSON.parse(google_map_style); 1874 golo_map.setOptions({styles: styles}); 1875 } 1876 1877 var mapPosition = new google.maps.LatLng('34.0207305', '-118.6919226'); 1878 golo_map.setCenter(mapPosition); 1879 golo_map.setZoom(parseInt(googlemap_default_zoom)); 1880 google.maps.event.addListener(golo_map, 'tilesloaded', function () { 1881 $('.filter-place-search .golo-loading-effect').fadeOut(); 1882 }); 1883 1884 1885 } 1886 1887 if( data.success === true ) { 1888 if( has_map ) { 1889 markers.forEach(function(marker) { 1890 marker.setMap(null); 1891 }); 1892 1893 markers = []; 1894 golo_add_markers(data.places, golo_map); 1895 //golo_my_location(golo_map); 1896 golo_map.fitBounds(markers.reduce(function (bounds, marker) { 1897 return bounds.extend(marker.getPosition()); 1898 }, new google.maps.LatLngBounds())); 1899 } 1900 1901 if( ajax_call == true ){ 1902 1903 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 1904 $('.area-places').html(data.place_html); 1905 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 1906 $('.golo-pagination .pagination').html(data.pagination); 1907 $('.archive-layout .result-count').html(data.count_post); 1908 }else{ 1909 $('.area-places').append(data.place_html); 1910 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 1911 if( data.hidden_pagination ) { 1912 $('.golo-pagination .pagination').html(''); 1913 } 1914 $('.golo-pagination .pagination').removeClass('active'); 1915 } 1916 1917 GLF.element.waypoints();
1918 } 1919 1920 if( has_map ) { 1921 google.maps.event.trigger(golo_map, 'resize'); 1922 1923 if( golo_template_vars.map_pin_cluster != 0 ) { 1924 marker_cluster = new MarkerClusterer(golo_map, markers, { 1925 gridSize: 60, 1926 styles: [ 1927 { 1928 url: clusterIcon, 1929 width: 66, 1930 height: 65, 1931 textColor: "#fff" 1932 } 1933 ] 1934 }); 1935 } 1936 1937 if( !is_mobile ) { 1938 golo_infowindow_hover_trigger(); 1939 } 1940 1941 // setTimeout(function() { 1942 // golo_infowindow_scroll_trigger(); 1943 // }, 50); 1944 1945 } 1946 }else{ 1947 if( ajax_call == true ){ 1948 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 1949 $('.area-places').html('<div class="golo-ajax-result">' + not_place + '</div>'); 1950 $('.archive-layout .result-count').html(data.count_post); 1951 $('.golo-pagination .pagination').html(''); 1952 }else{ 1953 $('.area-places').append(data.place_html); 1954 if( data.hidden_pagination ) { 1955 $('.golo-pagination .pagination').html(''); 1956 } 1957 $('.golo-pagination .pagination').removeClass('active'); 1958 } 1959 } 1960 } 1961 1962 if( has_map ) { 1963 golo_map.fitBounds(markers.reduce(function (bounds, marker) { 1964 return bounds.extend(marker.getPosition()); 1965 }, new google.maps.LatLngBounds())); 1966 google.maps.event.trigger(golo_map, 'resize'); 1967 } 1968 1969 $('.area-places .place-item').removeClass('skeleton-loading'); 1970 1971 1972 } else if ( maptype == 'openstreetmap' ) { 1973 1974 $('.filter-place-search .golo-loading-effect').fadeOut(); 1975 // if( has_map ) { 1976 // golo_osm_add_markers(data.places, maps); 1977 // } 1978 if( data.success === true ) { 1979 1980 if( ajax_call == true ){ 1981 1982 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 1983 $('.area-places').html(data.place_html); 1984 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 1985 $('.golo-pagination .pagination').html(data.pagination); 1986 $('.archive-layout .result-count').html(data.count_post); 1987 }else{ 1988 $('.area-places').append(data.place_html); 1989 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 1990 if( data.hidden_pagination ) { 1991 $('.golo-pagination .pagination').html(''); 1992 } 1993 $('.golo-pagination .pagination').removeClass('active'); 1994 } 1995 1996 GLF.element.waypoints();
1997 } 1998 1999 if( has_map ) { 2000 2001 golo_osm_add_markers(data.places, maps); 2002 2003 } 2004 2005 }else{ 2006 if( ajax_call == true ){ 2007 2008 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 2009 $('.area-places').html('<div class="golo-ajax-result">' + not_place + '</div>'); 2010 $('.archive-layout .result-count').html(data.count_post); 2011 $('.golo-pagination .pagination').html(''); 2012 }else{ 2013 $('.area-places').append(data.place_html); 2014 if( data.hidden_pagination ) { 2015 $('.golo-pagination .pagination').html(''); 2016 } 2017 $('.golo-pagination .pagination').removeClass('active'); 2018 } 2019 } 2020 } 2021 2022 $('.area-places .place-item').removeClass('skeleton-loading'); 2023 2024 } else { 2025 2026 $('.filter-place-search .golo-loading-effect').fadeOut(); 2027 if( has_map ) { 2028 golo_mapbox_add_markers(data.places, map); 2029 } 2030 if( data.success === true ) { 2031 if( has_map ) { 2032 2033 golo_mapbox_add_markers(data.places, map); 2034 2035 } 2036 2037 if( ajax_call == true ){ 2038 2039 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 2040 $('.area-places').html(data.place_html); 2041 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 2042 $('.golo-pagination .pagination').html(data.pagination); 2043 $('.archive-layout .result-count').html(data.count_post); 2044 }else{ 2045 $('.area-places').append(data.place_html); 2046 $('.filter-neighborhood ul.neighborhood').html(data.filter_html); 2047 if( data.hidden_pagination ) { 2048 $('.golo-pagination .pagination').html(''); 2049 } 2050 $('.golo-pagination .pagination').removeClass('active'); 2051 } 2052 2053 GLF.element.waypoints(); 2054 } 2055 2056 }else{ 2057 if( ajax_call == true ){ 2058 if( data.pagination_type == 'number' || pagination !== 'loadmore' ) { 2059 $('.area-places').html('<div class="golo-ajax-result">' + not_place + '</div>'); 2060 $('.archive-layout .result-count').html(data.count_post); 2061 $('.golo-pagination .pagination').html(''); 2062 }else{ 2063 $('.area-places').append(data.place_html); 2064 if( data.hidden_pagination ) { 2065 $('.golo-pagination .pagination').html(''); 2066 } 2067 $('.golo-pagination .pagination').removeClass('active'); 2068 } 2069 } 2070 } 2071 2072 $('.area-places .place-item').removeClass('skeleton-loading'); 2073 2074 } 2075 2076 2077 }, 2078 }); 2079 }, 2080 2081 add_to_wishlist: function () { 2082 2083 var burst = new mojs.Burst( { 2084 left : 0, 2085 top : 0, 2086 radius : { 4: 32 }, 2087 angle : 45, 2088 count : 14, 2089 children: { 2090 radius : 2.5, 2091 fill : wishlist_color, 2092 scale : { 2093 1 : 0, 2094 easing: 'quad.in' 2095 }, 2096 pathScale : [.8, null], 2097 degreeShift: [13, null], 2098 duration : [500, 700], 2099 easing : 'quint.out' 2100 } 2101 } ); 2102 burst.el.style.zIndex = 10; 2103
2104 $('body').on('click', '.golo-add-to-wishlist', function (e) { 2105 e.preventDefault(); 2106 if (!$(this).hasClass('on-handle')) { 2107 2108 var $this = $(this).addClass('on-handle'), 2109 place_inner = $this.closest('.place-inner').addClass('place-active-hover'), 2110 place_id = $this.attr('data-place-id'), 2111 save = ''; 2112 2113 if( !$this.hasClass('added') ){ 2114 var offset = $this.offset(), 2115 width = $this.width(), 2116 height = $this.height(), 2117 coords = { 2118 x: offset.left + width / 2, 2119 y: offset.top + height / 2 2120 }; 2121 2122 burst.tune( coords ).replay(); 2123 } 2124 2125 $.ajax({ 2126 type: 'post', 2127 url: ajax_url, 2128 dataType: 'json', 2129 data: { 2130 'action': 'golo_add_to_wishlist', 2131 'place_id': place_id 2132 }, 2133 beforeSend: function () { 2134 $this.find('.icon-heart').html('<span class="golo-dual-ring"></span>'); 2135 }, 2136 success: function (data) { 2137 if (data.added) { 2138 save = wishlist_saved; 2139 $this.removeClass('removed').addClass('added'); 2140 $this.parents('.place-item').removeClass('removed-wishlist'); 2141 } else { 2142 save = wishlist_save; 2143 $this.removeClass('added').addClass('removed'); 2144 $this.parents('.place-item').addClass('removed-wishlist'); 2145 } 2146 $this.children('i').removeClass('fa-spinner fa-spin'); 2147 if (typeof(data.added) == 'undefined') { 2148 console.log('login?'); 2149 } 2150 $this.removeClass('on-handle'); 2151 place_inner.removeClass('place-active-hover'); 2152 $this.html('<div class="icon-heart"><i class="la la-bookmark large"></i></div>'); 2153 }, 2154 error: function (xhr) { 2155 var err = eval("(" + xhr.responseText + ")"); 2156 console.log(err.Message); 2157 $this.children('i').removeClass('fa-spinner fa-spin'); 2158 $this.removeClass('on-handle'); 2159 place_inner.removeClass('place-active-hover'); 2160 } 2161 }); 2162 } 2163 }); 2164 }, 2165 2166 ajax_search_location: function($this, list = 'show') { 2167 2168 var location; 2169 2170 location = $this.closest('.golo-ajax-search').find('input[name="place_location"]').val(); 2171 2172 if (cached_location[location]) { 2173 GLF.element.cache_result($this, cached_location[location], list); 2174 } else { 2175 $.ajax({
2176 dataType: 'json', 2177 cache: true, 2178 url: ajax_url, 2179 data: { 2180 'action': 'golo_search_location_ajax', 2181 'location': location, 2182 }, 2183 success: function (data) { 2184 if( data.success === true ) { 2185 cached_location[location] = data.location_html; 2186 GLF.element.cache_result($this, data.location_html, list); 2187 }else{ 2188 cached_location[location] = '<div class="golo-ajax-result">' + no_results + '</div>'; 2189 $this.closest('.form-field').find('.area-result').empty().append('<div class="golo-ajax-result">' + no_results + '</div>'); 2190 } 2191 2192 if( list !== 'hide' ) { 2193 $this.closest('.form-field').find('.area-result').show(); 2194 $this.closest('.golo-ajax-search').removeClass('active'); 2195 } 2196 2197 GLF.element.click_outside('.location-field','.focus-result'); 2198 GLF.element.click_search_location(); 2199 }, 2200 }); 2201 } 2202 }, 2203 2204 ajax_search: function($this, list = 'show') { 2205 2206 var post_type, key, location, obj; 2207 2208 post_type = $this.closest('.golo-ajax-search').find('input[name="post_type"]').val(); 2209 key = $this.closest('.golo-ajax-search').find('input[name="s"]').val(); 2210 location = $this.closest('.golo-ajax-search').find('input[name="place_location"]').val(); 2211 2212 obj = key + '_' + location; 2213 2214 if (cached_html[obj]) { 2215 GLF.element.cache_result($this, cached_html[obj]); 2216 } else { 2217 2218 $.ajax({
2219 dataType: 'json', 2220 cache: true, 2221 url: ajax_url, 2222 data: { 2223 'action': 'golo_search_ajax', 2224 'post_type': post_type, 2225 'key': key, 2226 'location': location, 2227 }, 2228 beforeSend: function () { 2229 $this.closest('.golo-ajax-search').addClass('active'); 2230 }, 2231 success: function (data) { 2232 if( data.success === true ) { 2233 cached_html[obj] = data.place_html; 2234 GLF.element.cache_result($this, data.place_html, list); 2235 }else{ 2236 cached_html[obj] = '<div class="golo-ajax-result">' + not_place + '</div>'; 2237 $this.closest('.form-field').find('.area-result').empty().append('<div class="golo-ajax-result">' + not_place + '</div>'); 2238 } 2239 2240 if( list !== 'hide' ) { 2241 $this.closest('.form-field').find('.area-result').show(); 2242 $this.closest('.golo-ajax-search').removeClass('active'); 2243 } 2244 2245 GLF.element.click_outside('.input-field','.area-result'); 2246 }, 2247 }); 2248 } 2249 }, 2250 2251 cache_result: function($this, html, list = 'show') { 2252 $this.closest('.form-field').find('.area-result').empty().append(html); 2253 2254 if( list !== 'hide' ) { 2255 $('.form-field .area-result').hide(); 2256 $this.closest('.form-field').find('.area-result').show(); 2257 } 2258 }, 2259 2260 click_search_location: function() { 2261 $('.location-result a').on('click', function(e) { 2262 e.preventDefault(); 2263 var text = $(this).text(); 2264 var id = $(this).data('ciid'); 2265 2266 var formField = $(this).closest('.form-field'); 2267 formField.find('.location-search').val( text.trim() ).trigger('input', ['hide']); 2268 formField.find('input[name="ciid"]').val( id ); 2269 }); 2270 $('.type-result a').on('click', function(e) { 2271 e.preventDefault(); 2272 var text = $(this).text(); 2273 var id = $(this).data('tyid'); 2274 2275 var formField = $(this).closest('.form-field'); 2276 formField.find('.type-search').val( text.trim() ).trigger('input'); 2277 formField.find('input[name="tyid"]').val( id ); 2278 }); 2279 2280 $('.list-categories a').on('click', function(e) { 2281 e.preventDefault(); 2282 var text = $(this).text(); 2283 var id = $(this).data('caid'); 2284 2285 var formField = $(this).closest('.form-field'); 2286 formField.find('.input-search').val( text.trim() ).trigger('input'); 2287 formField.find('input[name="caid"]').val( id ); 2288 }); 2289 }, 2290 2291 ajax_booking_form: function($this) { 2292 2293 var place_title, place_id, place_author_id, adults, childrens, booking_date, booking_time, place_coupon; 2294 2295 place_title = $this.find('input[name="place_title"]').val(); 2296 place_id = $this.find('input[name="place_id"]').val(); 2297 place_author_id = $this.find('input[name="place_author_id"]').val(); 2298 adults = $this.find('input[name="adults"]').val(); 2299 childrens = $this.find('input[name="childrens"]').val(); 2300 booking_date = $this.find('input[name="booking_date"]').val(); 2301 booking_time = $this.find('input[name="booking_time"]').val(); 2302 place_coupon = $this.find('input[name="place_coupon"]').val(); 2303 2304 $.ajax({
2305 type: 'post', 2306 dataType: 'json', 2307 url: ajax_url, 2308 data: { 2309 'action': 'golo_booking_form_ajax', 2310 'place_title': place_title, 2311 'place_id': place_id, 2312 'place_author_id': place_author_id, 2313 'adults': adults, 2314 'childrens': childrens, 2315 'booking_date': booking_date, 2316 'booking_time': booking_time, 2317 'place_coupon': place_coupon, 2318 }, 2319 beforeSend: function () { 2320 $this.find('.golo-loading-effect').fadeIn(); 2321 }, 2322 success: function (data) { 2323 $this.find('.golo-loading-effect').fadeOut(); 2324 $this.find('.form-messages').removeClass('success warning'); 2325 if( data.success === true ) { 2326 $this.find('.form-messages').addClass('success'); 2327 $this.find('.form-messages span').text(booking_success); 2328 }else{ 2329 $this.find('.form-messages').addClass('warning'); 2330 $this.find('.form-messages span').text(booking_error); 2331 } 2332 }, 2333 }); 2334 }, 2335 2336 ajax_claim_form: function($this) { 2337 2338 var your_name, your_email, your_username, your_listing, place_id, messager; 2339 2340 your_name = $this.find('input[name="your_name"]').val(); 2341 your_email = $this.find('input[name="your_email"]').val(); 2342 your_username = $this.find('input[name="your_username"]').val(); 2343 your_listing = $this.find('input[name="your_listing"]').val(); 2344 place_id = $this.find('input[name="place_id"]').val(); 2345 messager = $this.find('textarea[name="messager"]').val(); 2346 2347 $.ajax({
2348 type: 'post', 2349 dataType: 'json', 2350 url: ajax_url, 2351 data: { 2352 'action': 'golo_claim_form_ajax', 2353 'your_name': your_name, 2354 'your_email': your_email, 2355 'your_username': your_username, 2356 'your_listing': your_listing, 2357 'place_id': place_id, 2358 'messager': messager, 2359 }, 2360 beforeSend: function () { 2361 $this.find('.golo-loading-effect').fadeIn(); 2362 }, 2363 success: function (data) { 2364 $this.find('.golo-loading-effect').fadeOut(); 2365 $this.find('.form-messages').removeClass('success warning'); 2366 if( data.success === true ) { 2367 $this.find('.form-messages').addClass('success'); 2368 $this.find('.form-messages span').text(data.success_text); 2369 $this.trigger("reset"); 2370 }else{ 2371 $this.find('.form-messages').addClass('warning'); 2372 $this.find('.form-messages span').text(data.error_text); 2373 } 2374 }, 2375 }); 2376 }, 2377 2378 contact_agent_by_email: function() { 2379 $('.agent-contact-btn', '#contact-agent-form').each(function () { 2380 $(this).on('click', function (event) { 2381 event.preventDefault(); 2382 var $this = $(this), 2383 $form = $(this).parents('form'), 2384 name = $('[name="sender_name"]', $form).val(), 2385 phone = $('[name="sender_phone"]', $form).val(), 2386 sender_email = $('[name="sender_email"]', $form).val(), 2387 message = $('[name="sender_msg"]', $form).val(), 2388 error = false; 2389 2390 $('.form-messages', $form).hide(); 2391 2392 if(name == null || name.length === 0) { 2393 $('.name-error', $form).removeClass('hidden'); 2394 error = true; 2395 } else if(!$('.name-error', $form).hasClass('hidden')) { 2396 $('.name-error', $form).addClass('hidden'); 2397 } 2398 if(phone == null || phone.length === 0) { 2399 $('.phone-error', $form).removeClass('hidden'); 2400 error = true; 2401 } else if(!$('.phone-error', $form).hasClass('hidden')) { 2402 $('.phone-error', $form).addClass('hidden'); 2403 } 2404 2405 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 2406 2407 if( sender_email == null || sender_email.length === 0 || !re.test(sender_email) ) { 2408 $('.email-error', $form).removeClass('hidden'); 2409 if(sender_email.trim().length !== 0 && !re.test(sender_email)) { 2410 $('.email-error', $form).text($('.email-error', $form).data('not-valid')); 2411 } else { 2412 $('.email-error', $form).text($('.email-error', $form).data('error')); 2413 } 2414 error = true; 2415 } else if( !$('.email-error', $form).hasClass('hidden') ) { 2416 $('.email-error', $form).addClass('hidden'); 2417 } 2418 if( message == null || message.length === 0 ) { 2419 $('.message-error', $form).removeClass('hidden'); 2420 error = true; 2421 } else if( !$('.message-error', $form).hasClass('hidden') ) { 2422 $('.message-error', $form).addClass('hidden'); 2423 } 2424 2425 if(!error) { 2426 $.ajax({
2427 type: 'post', 2428 url: ajax_url, 2429 dataType: 'json', 2430 data: $form.serialize(), 2431 beforeSend: function () { 2432 $('.form-messages', $form).show(); 2433 $('.form-messages', $form).html('<span class="success text-success"> ' + sending_text + '</span>'); 2434 }, 2435 success: function (response) { 2436 if (response.success) { 2437 $('.form-messages', $form).html('<span class="success text-success"><i class="lar la-check-circle icon-large"></i> ' + response.message + '</span>'); 2438 $("#contact-agent-form")[0].reset(); 2439 } else { 2440 $('.form-messages', $form).html('<span class="error text-danger"><i class="lar la-check-circle icon-large"></i> ' + response.message + '</span>'); 2441 } 2442 }, 2443 error: function () { 2444 } 2445 }); 2446 } 2447 }); 2448 }); 2449 }, 2450 2451 load_unseen_notification: function($this) { 2452 (function poll() { 2453 $.ajax({
2454 dataType: 'json', 2455 url: ajax_url, 2456 data: { 2457 'action': 'golo_load_unseen_notification_ajax', 2458 }, 2459 beforeSend: function () { 2460 2461 }, 2462 success: function (data) { 2463 $('.recent-notification .listing-detail').prepend(data.noti_html); 2464 var limit = $('.recent-notification .listing-detail li').length; 2465 if( limit > 20 ) { 2466 $('.recent-notification .listing-detail li').last().remove(); 2467 } 2468 }, 2469 complete: setTimeout(function() { 2470 poll(); 2471 }, 3000), 2472 }); 2473 })(); 2474 }, 2475 } 2476 2477 GLF.onReady = { 2478 init: function() { 2479 GLF.element.init(); 2480 } 2481 }; 2482 2483 GLF.onLoad = { 2484 init: function() { 2485 2486 } 2487 }; 2488 2489 GLF.onScroll = { 2490 init: function() { 2491 GLF.element.waypoints(); 2492 } 2493 }; 2494 2495 GLF.onResize = { 2496 init: function() { 2497 // Resize Window 2498 } 2499 }; 2500 2501 $(document).ready(GLF.onReady.init); 2502 $(window).scroll(GLF.onScroll.init); 2503 $(window).resize(GLF.onResize.init); 2504 $(window).load(GLF.onLoad.init); 2505 2506})(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.