// source --> https://www.vikyreal.cz/wp-content/plugins/realteo/assets/js/frontend.min.js /* ----------------- Start Document ----------------- */ (function($){ "use strict"; $(document).ready(function(){ /*----------------------------------------------------*/ /* Inline CSS replacement for backgrounds etc. /*----------------------------------------------------*/ function inlineCSS() { // Common Inline CSS $(".property-slider .item, .fullwidth-property-slider .item, .address-container").each(function() { var attrImageBG = $(this).attr('data-background-image'); var attrColorBG = $(this).attr('data-background-color'); $(this).css('background-image', 'url('+attrImageBG+')'); $(this).css('background', ''+attrColorBG+''); }); } // Init inlineCSS(); $('.realteo-dashboard-action-delete').click(function(e) { e.preventDefault(); if (window.confirm(realteo.areyousure)) { location.href = this.href; } }); $( '.realteo-ordering' ).on( 'change', 'select.orderby', function() { var order = $(this).val(); $('#realteo-search-form #realteo_order').val(order); if($( 'form#realteo-search-form' ).length>0) { $( 'form#realteo-search-form' ).submit(); } else { window.history.replaceState(null, null, window.location.pathname); window.location.href = window.location.href + "?realteo_order="+order; } }); $('label.selectit input[type="checkbox"]').click(function(){ $(this).parent().toggleClass('active'); }); /*----------------------------------------------------*/ /* Slick Carousel /*----------------------------------------------------*/ $('.property-slider').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: true, fade: true, asNavFor: '.property-slider-nav', centerMode: true, slide: ".item" }); $('.property-slider-nav').slick({ slidesToShow: 6, slidesToScroll: 1, asNavFor: '.property-slider', dots: false, arrows: false, centerMode: false, focusOnSelect: true, responsive: [ { breakpoint: 993, settings: { slidesToShow: 4, } }, { breakpoint: 767, settings: { slidesToShow: 3, } } ] }); $('.fullwidth-property-slider').slick({ centerMode: true, centerPadding: '20%', slidesToShow: 1, responsive: [ { breakpoint: 1367, settings: { centerPadding: '15%' } }, { breakpoint: 993, settings: { centerPadding: '0' } } ] }); $('.fullwidth-home-slider').slick({ centerMode: true, centerPadding: '0', slidesToShow: 1, responsive: [ { breakpoint: 1367, settings: { centerPadding: '0' } }, { breakpoint: 993, settings: { centerPadding: '0' } } ] }); /*----------------------------------------------------*/ /* Mortgage Calculator /*----------------------------------------------------*/ // Gets property price var propertyPricing = parseFloat($('.property-price').text().replace(/[^0-9\.]+/g,"")); if (propertyPricing > 0) { $('.pick-price').on('click', function(){ $('#amount').val(parseInt(propertyPricing)); }); } // replacing comma with dot $('.mortgageCalc').on( 'change', '#interest', function() { $("#interest").val($("#interest").val().replace(/,/g, '.')); }); // Calculator function mortgageCalc() { var amount = parseFloat($("#amount").val().replace(/[^0-9\.]+/g,"")), months =parseFloat($("#years").val().replace(/[^0-9\.]+/g,"")*12), down = parseFloat($("#downpayment").val().replace(/[^0-9\.]+/g,"")), annInterest = parseFloat($("#interest").val().replace(/[^0-9\.]+/g,"")), monInt = annInterest / 1200, calculation = ((monInt + monInt / (Math.pow(1 + monInt, months) - 1)) * (amount - (down || 0))).toFixed(2); if (calculation > 0 ){ $(".calc-output-container").css({'opacity' : '1', 'max-height' : '200px' }); $(".calc-output").hide().html(calculation + ' ' + $('.mortgageCalc').attr("data-calc-currency")).fadeIn(300); } } // Calculate $('.calc-button').on('click', function(){ mortgageCalc(); }); /*----------------------------------------------------*/ /* Compare Menu /*----------------------------------------------------*/ $('.csm-trigger').on('click', function(){ $('.compare-slide-menu').toggleClass('active'); }); $('.csm-mobile-trigger').on('click', function(){ $('.compare-slide-menu').removeClass('active'); }); // Tooltips $(".compare-button.with-tip, .like-icon.with-tip, .widget-button.with-tip").each(function() { $(this).on('click', function(e){ e.preventDefault(); }); var tipContent = $(this).attr('data-tip-content'); if($(this).hasClass('already-added')){ $(this).append('
'+ $(this).attr('data-tip-added-content') + '
'); } else { $(this).append('
'+ tipContent + '
'); } }); $('.compare-button, .compare-widget-button').on('click', function(e){ e.preventDefault(); /*if it's already added show the sidebar and stop*/ if($(this).hasClass('already-added')){ $('.compare-slide-menu').fadeIn().addClass('active'); return; } var tipAddingContent = $(this).attr('data-tip-adding-content'); var tipAddedContent = $(this).attr('data-tip-added-content'); /* if there are 1-3 properties, proceed to add on emore*/ if($(".csm-properties .listing-item").length < 4) { $(this).find(".tip-content").html(tipAddingContent); $('.compare-button, .compare-widget-button').fadeIn(); $(this).addClass('clicked'); var post_id = $(this).data("post_id"), handler = $(this), nonce = $(this).data("nonce"), addedtolist = $(this).data("saved-title") $.ajax({ type : "post", dataType : "json", url : realteo.ajax_url, data : {action: "realteo_compare_this", post_id : post_id, nonce: nonce}, success : function(response) { if(response.type == "success") { handler.removeClass('clicked').addClass('compared').addClass('already-added'); $('.csm-properties').append(response.html); $('.compare-slide-menu').fadeIn().addClass('active'); handler.find(".tip-content").html(tipAddedContent); if($(".csm-properties .listing-item").length > 4) { $('.compare-slide-menu').fadeIn().addClass('active'); $('.compare-slide-menu .notification').show(); setTimeout( function(){ $('.compare-slide-menu .notification').fadeOut() }, 2500 ); } } else { handler.removeClass('clicked') handler.find(".tip-content").html(response.message); } } }); } else { $('.compare-slide-menu').fadeIn().addClass('active'); $('.compare-slide-menu .notification').show(); setTimeout( function(){ $('.compare-slide-menu .notification').fadeOut() }, 2500 ); } }); $(".compare-list-container .remove-from-compare").on('click', function(e){ e.preventDefault(); var handler = $(this); var post_id = $(this).data("post_id"); var nonce = $(this).data("nonce"); var index = handler.parent().parent().parent().index(); $( "#compare-list li.compare-list-properties > div:eq("+index+")").addClass('opacity-05'); $.ajax({ type : "post", dataType : "json", url : realteo.ajax_url, data : {action: "realteo_uncompare_this", post_id : post_id, nonce: nonce}, success : function(response) { if(response.type == "success") { console.log($('#compare-list li.compare-list-properties > div').length); var number_left = $('#compare-list li.compare-list-properties > div').length; if(number_left == 2) { $('.compare-list-container').fadeOut(300, function() { $(this).remove(); }); $('.nothing-compares-2u').show(); } $( "#compare-list li.compare-list-properties > div:eq("+index+")").fadeOut(300, function() { $(this).remove(); }); $( "#compare-list li:not(.compare-list-properties)" ).each(function() { $( this ).find('div:eq('+index+' )').fadeOut(300, function() { $(this).remove(); }); }); } else { $( "#compare-list li.compare-list-properties > div:eq("+index+")").removeClass('opacity-05'); } } }) }); $('.compare-slide-menu').on( 'click', '.reset-compare', function(e) { e.preventDefault(); var handler = $(this); var nonce = $(this).data("nonce"); $(".csm-properties").addClass('opacity-05'); $.ajax({ type : "post", dataType : "json", url : realteo.ajax_url, data : {action: "realteo_uncompare_all", nonce: nonce}, success : function(response) { if(response.type == "success") { $(".csm-properties").empty(); $('.compare-slide-menu').removeClass('active'); setTimeout( function(){ $('.compare-slide-menu').fadeOut().removeClass('opacity-05') }, 500 ); } else { alert(response.message); $(".csm-properties").removeClass('opacity-05'); } } }) }); $('.compare-slide-menu').on( 'click', '.remove-from-compare', function(e) { e.preventDefault(); var handler = $(this); var post_id = $(this).data("post_id"); var nonce = $(this).data("nonce"); $(this).parent().parent().addClass('opacity-05'); $.ajax({ type : "post", dataType : "json", url : realteo.ajax_url, data : {action: "realteo_uncompare_this", post_id : post_id, nonce: nonce}, success : function(response) { if(response.type == "success") { handler.parent().parent().fadeOut(300, function() { $(this).remove(); $('.compare-widget-button.with-tip').removeClass('already-added').find('.tip-content').html($('.compare-widget-button.with-tip').data('tip-content')); if ($(".csm-properties .listing-item").length == 0){ $('.compare-slide-menu').removeClass('active') setTimeout( function(){ $('.compare-slide-menu').fadeOut() }, 500 ); } }); } else { alert(response.message); handler.parent().parent().removeClass('opacity-05'); } } }) }); /*----------------------------------------------------*/ /* Owl Carousel /*----------------------------------------------------*/ $('.carousel').owlCarousel({ autoPlay: false, navigation: true, slideSpeed: 600, items : 3, itemsDesktop : [1239,3], itemsTablet : [991,2], itemsMobile : [767,1] }); $('.testimonial-carousel').owlCarousel({ autoPlay: false, navigation: false, dots: true, slideSpeed: 600, items : 3, itemsDesktop : [1239,3], itemsTablet : [991,2], itemsMobile : [767,1] }); $('.agents-carousel').owlCarousel({ autoPlay: false, navigation: true, slideSpeed: 600, items : 4, itemsDesktop : [1239,3], itemsTablet : [991,2], itemsMobile : [767,1] }); $('.logo-carousel').owlCarousel({ autoPlay: false, navigation: true, slideSpeed: 600, items : 5, itemsDesktop : [1239,4], itemsTablet : [991,3], itemsMobile : [767,1] }); $('.listing-carousel').owlCarousel({ autoPlay: false, navigation: true, slideSpeed: 800, items : 1, itemsDesktop : [1239,1], itemsTablet : [991,1], itemsMobile : [767,1] }); $('.owl-next, .owl-prev').on("click", function (e) { e.preventDefault(); }); $('#realteo_reset_filters').on("click", function (e) { e.preventDefault(); $('#realteo-search-form').get(0).reset(); $('#realteo-search-form input').val(''); $("#realteo-search-form .chosen-select").val('').trigger("chosen:updated"); $('#realteo-search-form').find('input[type=checkbox]:checked').removeAttr('checked'); $(".first-slider-value").each(function() { var name = $(this).attr('name'); var val = realteo[name]; var $slider = $(this).parent(); $slider.slider("values", 0, val); $(this).val(val); }); $(".second-slider-value").each(function() { var name = $(this).attr('name'); var val = realteo[name]; var $slider = $(this).parent(); $slider.slider("values", 1, val); $(this).val(val); }); }); /*----------------------------------------------------*/ /* Chosen Plugin /*----------------------------------------------------*/ var config = { '.chosen-select' : {disable_search_threshold: 10, width:"100%"}, '.chosen-select-deselect' : {allow_single_deselect:true, width:"100%"}, '.chosen-select-no-single' : {disable_search_threshold:100, width:"100%"}, '.chosen-select-no-single.no-search' : {disable_search_threshold:10, width:"100%"}, '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'}, '.chosen-select-width' : {width:"95%"} }; for (var selector in config) { if (config.hasOwnProperty(selector)) { $(selector).chosen(config[selector]); } } /* Custom Input With Select /*----------------------------------------------------*/ $('.select-input').each(function(){ var thisContainer = $(this); var $this = $(this).children('select'), numberOfOptions = $this.children('option').length; $this.addClass('select-hidden'); $this.wrap('
'); $this.after('
'); var $styledSelect = $this.next('div.select-styled'); $styledSelect.text($this.children('option').eq(0).text()); var $list = $('