PageSourceSearch

https://collegelearners.org/wp-content/themes/homeo/js/property.js?ver=20150330

js collegelearners.org collected 2026-10-02 21:22:31 UTC 62,711 bytes, 1,363 lines download raw bytes

1(function($) {
2    "use strict";
3    
4    $.extend($.apusThemeCore, {
5        /**
6         *  Initialize scripts
7         */
8        property_init: function() {
9            var self = this;
10
11            self.select2Init();
12
13            self.searchAjaxInit();
14            
15            self.mortgageCalculator();
16
17            self.submitProperty();
18
19            self.listingDetail();
20
21            self.filterListingFnc();
22
23            self.userLoginRegister();
24
25            self.listingBtnFilter();
26
27            self.changePaddingTopContent();
28
29            self.dashboardChartInit();
30
31            $(window).resize(function(){
32                setTimeout(function(){
33                    self.changePaddingTopContent();
34                }, 50);
35            });
36
37            self.agentAgencyLoadMore();
38
39            self.propertyCompare();
40
41            if ( $('.properties-listing-wrapper.main-items-wrapper, .agents-listing-wrapper.main-items-wrapper, .agencies-listing-wrapper.main-items-wrapper').length ) {
42                $(document).on('change', 'form.filter-listing-form input, form.filter-listing-form select', function (e) {
43                    var form = $(this).closest('form.filter-listing-form');
44                    setTimeout(function(){
45                        form.trigger('submit');
46                    }, 200);
47                });
48
49                $(document).on('submit', 'form.filter-listing-form', function (e) {
50                    e.preventDefault();
51                    var url = $(this).attr('action');
52
53                    var formData = $(this).find(":input").filter(function(index, element) {
54                            return $(element).val() != '';
55                        }).serialize();
56
57                    if( url.indexOf('?') != -1 ) {
58                        url = url + '&' + formData;
59                    } else{
60                        url = url + '?' + formData;
61                    }
62                    
63                    self.propertiesGetPage( url );
64                    return false;
65                });
66
67                // Sort Action
68                $(document).on('change', 'form.properties-ordering select.orderby', function(e) {
69                    e.preventDefault();
70                    $('form.properties-ordering').trigger('submit');
71                });
72                
73                $(document).on('submit', 'form.properties-ordering', function (e) {
74                    var url = $(this).attr('action');
75
76                    var formData = $(this).find(":input").filter(function(index, element) {
77                            return $(element).val() != '';
78                        }).serialize();
79                    
80                    if( url.indexOf('?') != -1 ) {
81                        url = url + '&' + formData;
82                    } else{
83                        url = url + '?' + formData;
84                    }
85                    self.propertiesGetPage( url );
86                    return false;
87                });
88
89                // display mode
90                $(document).on('change', 'form.properties-display-mode input', function(e) {
91                    e.preventDefault();
92                    $('form.properties-display-mode').trigger('submit');
93                });
94
95                $(document).on('submit', 'form.properties-display-mode', function (e) {
96                    var url = $(this).attr('action');
97
98                    if( url.indexOf('?') != -1 ) {
99                        url = url + '&' + $(this).serialize();
100                    } else{
101                        url = url + '?' + $(this).serialize();
102                    }
103                    self.propertiesGetPage( url );
104                    return false;
105                });
106            }
107
108            $(document).on('click', '.advance-search-btn', function(e) {
109                e.preventDefault();
110                $(this).closest('.search-form-inner').find('.advance-search-wrapper-fields').removeClass('overflow-visible').slideToggle('fast', 'swing', function(){
111                    if ( !$(this).hasClass('overflow-visible') ) {
112                        $(this).addClass('overflow-visible');
113                    }
114                });
115            });
116            // ajax pagination
117            if ( $('.ajax-pagination').length ) {
118                self.ajaxPaginationLoad();
119            }
120
121            if ( $('.page-template-page-dashboard .sidebar-wrapper:not(.offcanvas-filter-sidebar) > .sidebar-right, .page-template-page-dashboard .sidebar-wrapper:not(.offcanvas-filter-sidebar) > .sidebar-left').length ) {
122                var ps = new PerfectScrollbar('.page-template-page-dashboard .sidebar-wrapper:not(.offcanvas-filter-sidebar) > .sidebar-right, .page-template-page-dashboard .sidebar-wrapper:not(.offcanvas-filter-sidebar) > .sidebar-left', {
123                    wheelPropagation: true
124                });
125            }
126            // filter fixed
127            if ( $('.properties-filter-sidebar-wrapper .inner').length ) {
128                var ps = new PerfectScrollbar('.properties-filter-sidebar-wrapper .inner', {
129                    wheelPropagation: true
130                });
131            }
132            self.galleryPropery();
133
134            $('.btn-send-mail').on('click', function(){
135                var target = $('form.contact-form-wrapper');
136                if (target.length) {
137                    $('html,body').animate({
138                        scrollTop: target.offset().top - 100
139                    }, 1000);
140                    return false;
141                }
142                return false;
143            });
144
145            $(document).on('after_nearby_yelp_content', function(e, $this, data){
146                if ( !data.status && $('.property-single-layout').hasClass('property-single-v5') ) {
147                    $('a[href="#property-single-nearby_yelp"]').parent().remove();
148                    $('#property-single-nearby_yelp').remove();
149                }
150            });
151
152            $(document).on('after_nearby_google_place_content', function(e, $this, data){
153                if ( !data.status && $('.property-single-layout').hasClass('property-single-v5') ) {
154                    $('a[href="#property-single-nearby_google_places"]').parent().remove();
155                    $('#property-single-nearby_google_places').remove();
156                }
157            });
158
159            $(document).on('after_walk_score_content', function(e, $this, data){
160                if ( !data.status && $('.property-single-layout').hasClass('property-single-v5') ) {
161                    $('a[href="#property-single-walk_score"]').parent().remove();
162                    $('#property-single-walk_score').remove();
163                }
164            });
165        },
166        select2Init: function() {
167            // select2
168            if ( $.isFunction( $.fn.select2 ) && typeof wp_realestate_select2_opts !== 'undefined' ) {
169                var select2_args = wp_realestate_select2_opts;
170                select2_args['allowClear']              = true;
171                select2_args['minimumResultsForSearch'] = 10;
172                
173                if ( typeof wp_realestate_select2_opts.language_result !== 'undefined' ) {
174                    select2_args['language'] = {
175                        noResults: function(){
176                            return wp_realestate_select2_opts.language_result;
177                        }
178                    };
179                }
180                var filter_select2_args = select2_args;
181                
182                
183
184                select2_args['allowClear'] = false;
185                select2_args['theme'] = 'default';
186
187                var register_select2_args = select2_args;
188                register_select2_args['minimumResultsForSearch'] = -1;
189                // filter
190                
191                $('select[name=email_frequency]').select2( select2_args );
192                $('.register-form select').select2( register_select2_args );
193
194                // fix for widget search
195                if( $('.widget-property-search-form.horizontal select').length ){
196                    filter_select2_args.theme = 'default customizer-search';
197                }
198                 
199                if ( $('.layout-type-half-map .widget-property-search-form.horizontal select').length ){
200                    filter_select2_args.theme = 'default customizer-search customizer-search-halpmap';
201                }
202                
203                filter_select2_args['allowClear'] = true;
204                $('.filter-listing-form select').select2( filter_select2_args );
205            }
206        },
207        searchAjaxInit: function() {
208            if ( $.isFunction( $.fn.typeahead ) ) {
209                $('.apus-autocompleate-input').each(function(){
210                    var $this = $(this);
211                    $this.typeahead({
212                            'hint': true,
213                            'highlight': true,
214                            'minLength': 2,
215                            'limit': 10
216                        }, {
217                            name: 'search',
218                            source: function (query, processSync, processAsync) {
219                                processSync([homeo_property_opts.empty_msg]);
220                                $this.closest('.twitter-typeahead').addClass('loading');
221
222                                var values = {};
223                                $.each($this.closest('form').serializeArray(), function (i, field) {
224                                    values[field.name] = field.value;
225                                });
226
227                                var ajaxurl = homeo_property_opts.ajaxurl;
228                                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
229                                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_autocomplete_search_properties' );
230                                }
231
232                                return $.ajax({
233                                    url: ajaxurl,
234                                    type: 'GET',
235                                    data: {
236                                        'search': query,
237                                        'action': 'homeo_autocomplete_search_properties',
238                                        'data': values
239                                    },
240                                    dataType: 'json',
241                                    success: function (json) {
242                                        $this.closest('.twitter-typeahead').removeClass('loading');
243                                        $this.closest('.has-suggestion').removeClass('active');
244                                        return processAsync(json);
245                                    }
246                                });
247                            },
248                            templates: {
249                                empty : [
250                                    '<div class="empty-message">',
251                                    homeo_property_opts.empty_msg,
252                                    '</div>'
253                                ].join('\n'),
254                                suggestion: Handlebars.compile( homeo_property_opts.template )
255                            },
256                        }
257                    );
258                    $this.on('typeahead:selected', function (e, data) {
259                        e.preventDefault();
260                        setTimeout(function(){
261                            $('.apus-autocompleate-input').val(data.title);    
262                        }, 5);
263                        
264                        return false;
265                    });
266                });
267            }
268        },
269        mortgageCalculator: function() {
270            $('#btn_mortgage_get_results').on('click', function (e) {
271                e.preventDefault();
272
273                var property_price = $('#apus_mortgage_property_price').val();
274                var deposit = $('#apus_mortgage_deposit').val();
275                var interest_rate = parseFloat($('#apus_mortgage_interest_rate').val(), 10) / 100;
276                var years = parseInt($('#apus_mortgage_term_years').val(), 10);
277                
278
279                var interest_rate_month = interest_rate / 12;
280                var nbp_month = years * 12;
281
282                var loan_amount = property_price - deposit;
283                var monthly_payment = parseFloat((loan_amount * interest_rate_month) / (1 - Math.pow(1 + interest_rate_month, -nbp_month))).toFixed(2);
284
285                if (monthly_payment === 'NaN') {
286                    monthly_payment = 0;
287                }
288                
289                $('.apus_mortgage_results').html( homeo_property_opts.monthly_text + homeo_property_opts.currency + monthly_payment);
290
291            });
292        },
293        dashboardChartInit: function() {
294            var self = this;
295            var $this = $('#dashboard_property_chart_wrapper');
296            if( $this.length <= 0 ) {
297                return;
298            }
299
300            // select2
301            if ( $.isFunction( $.fn.select2 ) && typeof wp_realestate_select2_opts !== 'undefined' ) {
302                var select2_args = wp_realestate_select2_opts;
303                select2_args['allowClear']              = false;
304                select2_args['minimumResultsForSearch'] = 10;
305                
306                if ( typeof wp_realestate_select2_opts.language_result !== 'undefined' ) {
307                    select2_args['language'] = {
308                        noResults: function(){
309                            return wp_realestate_select2_opts.language_result;
310                        }
311                    };
312                }
313                
314                select2_args['width'] = '100%';
315
316                $('.stats-graph-search-form select').select2( select2_args );
317            }
318
319
320            var property_id = $this.data('property_id');
321            var nb_days = $this.data('nb_days');
322            self.dashboardChartAjaxInit($this, property_id, nb_days);
323
324            $('form.stats-graph-search-form select[name="property_id"]').on('change', function(){
325                $('form.stats-graph-search-form').trigger('submit');
326            });
327
328            $('form.stats-graph-search-form select[name="nb_days"]').on('change', function(){
329                $('form.stats-graph-search-form').trigger('submit');
330            });
331
332            $('form.stats-graph-search-form').on('submit', function(e){
333                e.preventDefault();
334                var property_id = $('form.stats-graph-search-form select[name="property_id"]').val();
335                var nb_days = $('form.stats-graph-search-form select[name="nb_days"]').val();
336                self.dashboardChartAjaxInit($this, property_id, nb_days);
337                return false;
338            });
339        },
340        dashboardChartAjaxInit: function($this, property_id, nb_days) {
341            var self = this;
342            if( $this.length <= 0 ) {
343                return;
344            }
345            if ( $this.hasClass('loading') ) {
346                return;
347            }
348            $this.addClass('loading');
349
350            var ajaxurl = homeo_property_opts.ajaxurl;
351            if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
352                ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_get_property_chart' );
353            }
354
355            $.ajax({
356                url: ajaxurl,
357                type:'POST',
358                dataType: 'json',
359                data: {
360                    action: 'wp_realestate_get_property_chart',
361                    property_id: property_id,
362                    nb_days: nb_days,
363                    nonce: $this.data('nonce'),
364                }
365            }).done(function(response) {
366                if (response.status == 'error') {
367                    $this.remove();
368                } else {
369                    var ctx = $this.get(0).getContext("2d");
370
371                    var data = {
372                        labels: response.stats_labels,
373                        datasets: [
374                            {
375                                label: response.stats_view,
376                                backgroundColor: response.bg_color,
377                                borderColor: response.border_color,
378                                borderWidth: 1,
379                                data: response.stats_values
380                            },
381                        ]
382                    };
383
384                    var options = {
385                        //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
386                        scaleBeginAtZero : true,
387                        //Boolean - Whether grid lines are shown across the chart
388                        scaleShowGridLines : false,
389                        //String - Colour of the grid lines
390                        scaleGridLineColor : "rgba(0,0,0,.05)",
391                        //Number - Width of the grid lines
392                        scaleGridLineWidth : 1,
393                        //Boolean - Whether to show horizontal lines (except X axis)
394                        scaleShowHorizontalLines: true,
395                        //Boolean - Whether to show vertical lines (except Y axis)
396                        scaleShowVerticalLines: true,
397                        //Boolean - If there is a stroke on each bar
398                        barShowStroke : false,
399                        //Number - Pixel width of the bar stroke
400                        barStrokeWidth : 2,
401                        //Number - Spacing between each of the X value sets
402                        barValueSpacing : 5,
403                        //Number - Spacing between data sets within X values
404                        barDatasetSpacing : 1,
405                        legend: { display: false },
406
407                        tooltips: {
408                            enabled: true,
409                            mode: 'x-axis',
410                            cornerRadius: 4
411                        },
412                    }
413
414                    if (typeof self.myBarChart !== 'undefined') {
415                        self.myBarChart.destroy();
416                    }
417
418                    self.myBarChart = new Chart(ctx, {
419                        type: response.chart_type,
420                        data: data,
421                        options: options
422                    });
423                }
424                $this.removeClass('loading');
425            });
426        },
427        submitProperty: function() {
428            $(document).on('click', 'ul.submit-property-heading li a', function(e) {
429                e.preventDefault();
430                var href = $(this).attr('href');
431                if ( $(href).length ) {
432                    $('ul.submit-property-heading li').removeClass('active');
433                    $(this).closest('li').addClass('active');
434                    $('.before-group-row').removeClass('active');
435                    $(href).addClass('active');
436
437                    $( "input" ).trigger( "pxg:simplerefreshmap" );
438                }
439            });
440
441            $(document).on('click', '.job-submission-previous-btn, .job-submission-next-btn', function(e) {
442                e.preventDefault();
443                var index = $(this).data('index');
444                if ( $('.before-group-row-'+index).length ) {
445                    $('.before-group-row').removeClass('active');
446                    $('.before-group-row-'+index).addClass('active');
447
448                    $('.submit-property-heading li').removeClass('active');
449                    $('.submit-property-heading-'+index).addClass('active');
450
451                    $( "input" ).trigger( "pxg:simplerefreshmap" );
452                }
453            });
454        },
455        changePaddingTopContent: function() {
456            var header_h = 0;
457            if ($(window).width() >= 1200) {
458                if ( $('#apus-header').length ) {
459                    var header_h = $('#apus-header').outerHeight();
460                    $('#apus-main-content').css({ 'padding-top': 0 });
461                    $('body.page-template-page-dashboard #apus-main-content').css({ 'padding-top': header_h });
462                } else if( $('div[data-elementor-type="header"]').length ) {
463                    var header_h = $('div[data-elementor-type="header"]').outerHeight();
464                    $('#apus-main-content').css({ 'padding-top': 0 });
465                    $('body.page-template-page-dashboard #apus-main-content').css({ 'padding-top': header_h });
466                    var wpadminbar_h = 0;
467                    if ( $('#wpadminbar').length ) {
468                        var wpadminbar_h = $('#wpadminbar').outerHeight();
469                    }
470                    header_h = header_h + wpadminbar_h;
471                }
472            } else {
473                var header_h = $('#apus-header-mobile').outerHeight();
474                $('#apus-main-content').css({ 'padding-top': header_h });
475            }
476            
477            if ($('#properties-google-maps').is('.fix-map')) {
478                $('#properties-google-maps').css({ 'top': header_h, 'height': 'calc(100vh - ' + header_h+ 'px)' });
479                // filter for half 3
480                if ($(window).width() >= 1200) {
481                    $('.layout-type-half-map-v3 .properties-filter-sidebar-wrapper ').css({ 'top': header_h, 'height': 'calc(100vh - ' + header_h+ 'px)' });
482                    $('#apus-main-content').css({ 'padding-top': header_h });
483                }
484            }
485            // fix for half map
486            $('.layout-type-half-map .filter-sidebar').css({ 'padding-top': header_h + 30 });
487            // $('.layout-type-half-map .filter-scroll').perfectScrollbar();
488            if ( $('.layout-type-half-map .filter-scroll').length ) {
489                var ps = new PerfectScrollbar('.layout-type-half-map .filter-scroll', {
490                    wheelPropagation: true
491                });
492            }
493            // offcanvas-filter-sidebar 
494            $('.offcanvas-filter-sidebar').css({ 'padding-top': header_h + 10 });
495        },
496        agentAgencyLoadMore: function() {
497            $(document).on('click', '.ajax-properties-pagination .apus-loadmore-btn', function(e){
498                e.preventDefault();
499                var $this = $(this);
500                
501                $this.addClass('loading');
502
503                var ajaxurl = homeo_property_opts.ajaxurl;
504                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
505                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_get_ajax_properties_load_more' );
506                }
507
508                $.ajax({
509                    url: ajaxurl,
510                    type:'POST',
511                    dataType: 'json',
512                    data: {
513                        action: 'homeo_get_ajax_properties_load_more',
514                        paged: $this.data('paged'),
515                        post_id: $this.data('post_id'),
516                        type: $this.data('type'),
517                    }
518                }).done(function(data) {
519                    $this.removeClass('loading');
520                    $this.closest('.agent-agency-detail-properties').find('.row').append(data.output);
521                    $this.data('paged', data.paged);
522                    if ( !data.load_more ) {
523                        $this.closest('.ajax-properties-pagination').addClass('all-properties-loaded');
524                    }
525                });
526            });
527
528            $(document).on('click', '.ajax-agents-pagination .apus-loadmore-btn', function(e){
529                e.preventDefault();
530                var $this = $(this);
531                    
532                $this.addClass('loading');
533
534                var ajaxurl = homeo_property_opts.ajaxurl;
535                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
536                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_get_ajax_agents_load_more' );
537                }
538
539                $.ajax({
540                    url: ajaxurl,
541                    type:'POST',
542                    dataType: 'json',
543                    data: {
544                        action: 'homeo_get_ajax_agents_load_more',
545                        paged: $this.data('paged'),
546                        post_id: $this.data('post_id'),
547                    }
548                }).done(function(data) {
549                    $this.removeClass('loading');
550                    $this.closest('.agent-detail-agents').find('.row').append(data.output);
551                    $this.data('paged', data.paged);
552                    if ( !data.load_more ) {
553                        $this.closest('.ajax-agents-pagination').addClass('all-properties-loaded');
554                    }
555                });
556            });
557        },
558        propertyChangeMarginTopAffix: function() {
559            var affix_height = 0;
560            //if ($(window).width() > 991) {
561                if ( $('.panel-affix').length > 0 ) {
562                    affix_height = $('.panel-affix').outerHeight();
563                    $('.panel-affix-wrapper').css({'height': affix_height});
564                }
565            //}
566            return affix_height;
567        },
568        listingDetail: function() {
569            var self = this;
570            
571            // sticky tabs
572            var affix_height = 0;
573            var affix_height_top = 0;
574            setTimeout(function(){
575                affix_height = affix_height_top = self.propertyChangeMarginTopAffix();
576            }, 50);
577            $(window).resize(function(){
578                affix_height = affix_height_top = self.propertyChangeMarginTopAffix();
579            });
580            if ($(window).width() >= 1200) {
581                //Function from Bluthemes, lets you add li elemants to affix object without having to alter and data attributes set out by bootstrap
582                setTimeout(function(){
583                    // name your elements here
584                    var stickyElement   = '.panel-affix',   // the element you want to make sticky
585                        bottomElement   = '#apus-footer'; // the bottom element where you want the sticky element to stop (usually the footer) 
586
587                    // make sure the element exists on the page before trying to initalize
588                    if($( stickyElement ).length){
589                        $( stickyElement ).each(function(){
590                            var header_height = 0;
591                            if ($(window).width() >= 1200) {
592                                if ($('.main-sticky-header').length > 0) {
593                                    header_height = $('.main-sticky-header').outerHeight();
594                                    affix_height_top = affix_height + header_height;
595                                }
596                            } else {
597                                header_height = $('#apus-header-mobile').outerHeight();
598                                affix_height_top = affix_height + header_height;
599                                header_height = 0;
600                            }
601                            affix_height_top = affix_height_top + 10;
602                            // let's save some messy code in clean variables
603                            // when should we start affixing? (the amount of pixels to the top from the element)
604                            var fromTop = $( this ).offset().top, 
605                                // where is the bottom of the element?
606                                fromBottom = $( document ).height()-($( this ).offset().top + $( this ).outerHeight()),
607                                // where should we stop? (the amount of pixels from the top where the bottom element is)
608                                // also add the outer height mismatch to the height of the element to account for padding and borders
609                               
609 stopOn = ($( this ).outerHeight() - $( this ).height()); 
610                
611                            // if the element doesn't need to get sticky, then skip it so it won't mess up your layout
612                            if( (fromBottom-stopOn) > 200 ){
613                                // let's put a sticky width on the element and assign it to the top
614                                $( this ).css('width', $( this ).width()).css('top', 0).css('position', '');
615                                // assign the affix to the element
616                                $( this ).affix({
617                                    offset: { 
618                                        // make it stick where the top pixel of the element is
619                                        top: fromTop - header_height,  
620                                        // make it stop where the top pixel of the bottom element is
621                                        bottom: stopOn
622                                    }
623                                // when the affix get's called then make sure the position is the default (fixed) and it's at the top
624                                }).on('affix.bs.affix', function(){
625                                    var header_height = 0;
626                                    if ($(window).width() >= 1200) {
627                                        if ($('.main-sticky-header').length > 0) {
628                                            header_height = $('.main-sticky-header').outerHeight();
629                                            affix_height_top = affix_height + header_height;
630                                        }
631                                    } else {
632                                        header_height = $('#apus-header-mobile').outerHeight();
633                                        affix_height_top = affix_height + header_height;
634                                        header_height = 0;
635                                    }
636                                    affix_height_top = affix_height_top + 10;
637                                    $( this ).css('top', header_height).css('position', header_height);
638                                });
639                            }
640                            // trigger the scroll event so it always activates 
641                            $( window ).trigger('scroll'); 
642                        }); 
643                    }
644
645                    //Offset scrollspy height to highlight li elements at good window height
646                    $('body').scrollspy({
647                        target: ".header-tabs-wrapper",
648                        offset: affix_height_top + 20
649                    });
650                }, 50);
651            }
652            
653
654            //Smooth Scrolling For Internal Page Links
655            $('.panel-affix a[href*="#"]:not([href="#"])').on('click', function() {
656                if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
657                    var target = $(this.hash);
658                    target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
659                    if (target.length) {
660                        $('html,body').animate({
661                            scrollTop: target.offset().top - affix_height_top
662                        }, 1000);
663                        return false;
664                    }
665                }
666            });
667
668
669
670            $(document).on('click', '.add-a-review', function(e) {
671                e.preventDefault();
672                var $id = $(this).attr('href');
673                if ( $($id).length > 0 ) {
674                    $('html,body').animate({
675                        scrollTop: $($id).offset().top - 100
676                    }, 1000);
677                }
678            });
679
680            $(document).on('click', '.btn-view-all-photos', function(e){
681                $(this).closest('.property-detail-gallery').find('a:first').trigger('click');
682            });
683
684            $('.btn-print-property').on('click', function(e){
685                e.preventDefault();
686                
687                var $this = $(this);
688                $this.addClass('loading');
689                var property_id = $(this).data('property_id');
690                var nonce = $(this).data('nonce');
691
692                var ajaxurl = homeo_property_opts.ajaxurl;
693                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
694                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_ajax_print_property' );
695                }
696
697                var printWindow = window.open('', 'Print Me', 'width=700 ,height=842');
698                $.ajax({
699                    url: ajaxurl,
700                    type:'POST',
701                    dataType: 'html',
702                    data: {
703                        'property_id': property_id,
704                        'nonce': nonce,
705                        'action': 'homeo_ajax_print_property',
706                    }
707                }).done(function(data) {
708                    $this.removeClass('loading');
709                    
710                    
711                    printWindow.document.write(data);
712                    printWindow.document.close();
713                    printWindow.focus();
714
715                    // setTimeout(function(){
716                    //     printWindow.print();
717                    // }, 2000);
718                    // printWindow.close();
719
720                });
721
722            });
723        },
724        listingBtnFilter: function(){
725            $('.btn-view-map').on('click', function(e){
726                e.preventDefault();
727                $('#properties-google-maps').removeClass('hidden-sm').removeClass('hidden-xs');
728                $('.content-listing .properties-listing-wrapper, .content-listing .agencies-listing-wrapper').addClass('hidden-sm').addClass('hidden-xs');
729                $('.btn-view-listing').removeClass('hidden-sm').removeClass('hidden-xs');
730                $(this).addClass('hidden-sm').addClass('hidden-xs');
731                $('.properties-pagination-wrapper, .agencies-pagination-wrapper').addClass('p-fix-pagination');
732                setTimeout(function() {
733                    $(window).trigger('pxg:refreshmap');
734                }, 100);
735            });
736            $('.btn-view-listing').on('click', function(e){
737                e.preventDefault();
738                $('#properties-google-maps').addClass('hidden-sm').addClass('hidden-xs');
739                $('.content-listing .properties-listing-wrapper, .content-listing .agencies-listing-wrapper').removeClass('hidden-sm').removeClass('hidden-xs');
740                $('.btn-view-map').removeClass('hidden-sm').removeClass('hidden-xs');
741                $(this).addClass('hidden-sm').addClass('hidden-xs');
742                $('.properties-pagination-wrapper, .agencies-pagination-wrapper').removeClass('p-fix-pagination');
743            });
744
745            $('.show-filter-properties, .filter-in-sidebar').on('click', function(e){
746                e.stopPropagation();
747                $('.layout-type-half-map .filter-sidebar').toggleClass('active');
748                $('.filter-sidebar + .over-dark').toggleClass('active');
749            });
750            
751            $(document).on('click', '.filter-sidebar + .over-dark', function(){
752                $('.layout-type-half-map .filter-sidebar').removeClass('active');
753                $('.filter-sidebar + .over-dark').removeClass('active');
754            });
755
756            // filter sidebar fixed
757            $(document).on('click', '.properties-filter-sidebar-wrapper .close-filter, .btn-show-filter, .properties-filter-sidebar-wrapper + .over-dark-filter', function(){
758                $('.properties-filter-sidebar-wrapper').toggleClass('active');
759            });
760        },
761        userLoginRegister: function(){
762            var self = this;
763            // login/register
764            $('.user-login-form, .must-log-in').on('click', function(e){
765                e.preventDefault();
766                if ( $('.apus-user-login').length ) {
767                    $('.apus-user-login').trigger('click');
768                }
769            });
770            $('.apus-user-login, .apus-user-register').on('click', function(){
771                self.layzyLoadImage();
772            });
773            $('.apus-user-login, .apus-user-register').magnificPopup({
774                mainClass: 'apus-mfp-zoom-in login-popup',
775                type:'inline',
776                midClick: true,
777                callbacks: {
778                    open: function() {
779                        self.layzyLoadImage();
780                        $(window).trigger('resize');
781                    }
782                }
783            });
784              
785        },
786
787        filterListingFnc: function(){
788            var self = this;
789            $('body').on('click', '.btn-show-filter, .offcanvas-filter-sidebar + .over-dark', function(){
790                $('.offcanvas-filter-sidebar, .offcanvas-filter-sidebar + .over-dark').toggleClass('active');
791                // $('.offcanvas-filter-sidebar').perfectScrollbar();
792                if ( $('.offcanvas-filter-sidebar').length ) {
793                    var ps = new PerfectScrollbar('.offcanvas-filter-sidebar', {
794                        wheelPropagation: true
795                    });
796                }
797                
798            });
799
800            $(document).on('after_add_property_favorite', function(e, $this, data) {
801                $this.attr('data-original-title', homeo_property_opts.favorite_added_tooltip_title);
802            });
803            $(document).on('after_remove_property_favorite', function( event, $this, data ) {
804                $this.attr('data-original-title', homeo_property_opts.favorite_add_tooltip_title);
805            });
806
807            $('body').on('click', function() {
808                if ( $(this).find('.price-input-wrapper').length ) {
809                    $(this).find('.price-input-wrapper').slideUp();
810                }
811            });
812
813            $('body').on('click', '.form-group-price.text, .form-group-price.list, .form-group-home_area.text, .form-group-lot_area.text, .form-group-year_built.text', function(e){
814                e.stopPropagation();
815            });
816            $('body').on('click', '.heading-filter-price', function(){
817                $(this).closest('.from-to-wrapper').find('.price-input-wrapper').slideToggle();
818            });
819            $('body').on('keyup', '.price-input-wrapper input', function(){
820                var $from_val = $(this).closest('.price-input-wrapper').find('.filter-from').val();
821                var $to_val = $(this).closest('.price-input-wrapper').find('.filter-to').val();
822                var $wrapper = $(this).closest('.from-to-text-wrapper');
823
824                if ( $wrapper.hasClass('price') ) {
825                    if ( wp_realestate_opts.enable_multi_currencies === 'yes' ) {
826                        $from_val = self.shortenNumber($from_val);
827                        $to_val = self.shortenNumber($to_val);
828                    } else {
829                        $from_val = self.addCommas($from_val);
830                        $to_val = self.addCommas($to_val);
831                    }
832                    $wrapper.find('.from-text .price-text').text( $from_val );
833                    $wrapper.find('.to-text .price-text').text( $to_val );
834                } else {
835                    $wrapper.find('.from-text').text( $from_val );
836                    $wrapper.find('.to-text').text( $to_val );
837                }
838            });
839            $('body').on('change', '.price-input-wrapper input', function(){
840                var $from_val = $(this).closest('.price-input-wrapper').find('.filter-from').val();
841                var $to_val = $(this).closest('.price-input-wrapper').find('.filter-to').val();
842                var $wrapper = $(this).closest('.from-to-text-wrapper');
843                if ( $wrapper.hasClass('price') ) {
844                    if ( wp_realestate_opts.enable_multi_currencies === 'yes' ) {
845                        $from_val = self.shortenNumber($from_val);
846                        $to_val = self.shortenNumber($to_val);
847                    } else {
848                        $from_val = self.addCommas($from_val);
849                        $to_val = self.addCommas($to_val);
850                    }
851
852                    $wrapper.find('.from-text .price-text').text( $from_val );
853                    $wrapper.find('.to-text .price-text').text( $to_val );
854                } else {
855                    $wrapper.find('.from-text').text( $from_val );
856                    $wrapper.find('.to-text').text( $to_val );
857                }
858            });
859            $('body').on('click', '.from-to-wrapper.price-list .price-filter li', function(){
860                var $parent = $(this).closest('.from-to-wrapper');
861                var $min = $(this).data('min');
862                var $max = $(this).data('max');
863                $parent.find('input.filter-from').val($min);
864                $parent.find('input.filter-to').val($max);
865                $(this).closest('.from-to-wrapper').find('.heading-filter-price .price-text').html($(this).find('.price-text').html());
866                $(this).closest('.price-input-wrapper').slideUp();
867                $(this).closest('form').trigger('submit');
868            });
869        },
870        propertyCompare: function(){
871            var self = this;
872            if ( $('.compare-sidebar-inner .compare-list').length ) {
873                var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
874                    wheelPropagation: true
875                });
876            }
877
878            $(document).on('after_add_property_compare', function(e, $this, data) {
879                var html_output = '';
880                if ( data.html_output ) {
881                    html_output = data.html_output;
882                }
883                $('#compare-sidebar .compare-sidebar-inner').html(html_output);
884                $('.compare-sidebar-btn .count').html(data.count);
885
886                if ( $('.compare-sidebar-inner .compare-list').length ) {
887                    var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
888                        wheelPropagation: true
889                    });
890                }
891
892                self.layzyLoadImage();
893
894                if ( !$('#compare-sidebar').hasClass('active') ) {
895                    $('#compare-sidebar').addClass('active');
896                }
897                if ( !$('#compare-sidebar').hasClass('open') ) {
898                    $('#compare-sidebar').addClass('open');
899                }
900                $this.attr('data-original-title', homeo_property_opts.c
900ompare_added_tooltip_title);
901            });
902            
903            $(document).on('after_remove_property_compare', function( event, $this, data ) {
904                var html_output = '';
905                if ( data.html_output ) {
906                    html_output = data.html_output;
907                }
908                $('#compare-sidebar .compare-sidebar-inner').html(html_output);
909                $('.compare-sidebar-btn .count').html(data.count);
910                
911                if ( $('.compare-sidebar-inner .compare-list').length ) {
912                    var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
913                        wheelPropagation: true
914                    });
915                }
916
917                if ( data.count == '0' ) {
918                    $('#compare-sidebar').removeClass('active');
919                }
920
921                $this.attr('data-original-title', homeo_property_opts.compare_add_tooltip_title);
922
923                self.layzyLoadImage();
924            });
925
926            $('.compare-sidebar-inner').on('click', '.btn-remove-property-compare-list', function(e) {
927                e.stopPropagation();
928                var $this = $(this);
929                $this.addClass('loading');
930                var property_id = $(this).data('property_id');
931                var nonce = $(this).data('nonce');
932
933                var ajaxurl = homeo_property_opts.ajaxurl;
934                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
935                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_compare' );
936                }
937                $.ajax({
938                    url: ajaxurl,
939                    type:'POST',
940                    dataType: 'json',
941                    data: {
942                        'property_id': property_id,
943                        'nonce': nonce,
944                        'action': 'wp_realestate_ajax_remove_property_compare',
945                    }
946                }).done(function(data) {
947                    $this.removeClass('loading');
948                    if ( data.status ) {
949                        
950                        $(document).trigger( "after_remove_property_compare", [$this, data] );
951
952                        if ( $('.btn-remove-property-compare-list').length <= 0 ) {
953                            $('#compare-sidebar').removeClass('active');
954                            $('#compare-sidebar').removeClass('open');
955                        }
956
957                        $('a.btn-added-property-compare').each(function(){
958                            if ( property_id == $(this).data('property_id') ) {
959                                $(this).removeClass('btn-added-property-compare').addClass('btn-add-property-compare');
960                                $(this).data('nonce', data.nonce);
961                            }
962                        });
963                    }
964                });
965            });
966
967            $('.compare-sidebar-inner').on('click', '.btn-remove-compare-all', function(e) {
968                e.stopPropagation();
969                var $this = $(this);
970                $this.addClass('loading');
971                var nonce = $(this).data('nonce');
972
973                var ajaxurl = homeo_property_opts.ajaxurl;
974                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
975                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_all_property_compare' );
976                }
977
978                $.ajax({
979                    url: ajaxurl,
980                    type:'POST',
981                    dataType: 'json',
982                    data: {
983                        'nonce': nonce,
984                        'action': 'wp_realestate_ajax_remove_all_property_compare',
985                    }
986                }).done(function(data) {
987                    $this.removeClass('loading');
988                    if ( data.status ) {
989                        
990                        $(document).trigger( "after_remove_property_compare", [$this, data] );
991
992                        $('a.btn-added-property-compare').each(function(){
993                            $(this).removeClass('btn-added-property-compare').addClass('btn-add-property-compare');
994                            $(this).data('nonce', data.nonce);
995                        });
996                    }
997                });
998            });
999
1000            $('body').on('click', '#compare-sidebar .compare-sidebar-btn', function(e){
1001                e.stopPropagation();
1002                $('#compare-sidebar').toggleClass('open');
1003                if ($('#compare-sidebar').hasClass('open')) {
1004                    $('body').css({ 'overflow': 'hidden' });
1005                } else {
1006                    $('body').css({ 'overflow': 'initial' });
1007                }
1008            });
1009            $('body').on('click', function() {
1010                if ($('#compare-sidebar').hasClass('open')) {
1011                    $('#compare-sidebar').removeClass('open');
1012                    $('body').css({ 'overflow': 'initial' });
1013                }
1014            });
1015            $('.compare-sidebar-inner').on('click', function(e) {
1016                e.stopPropagation();
1017            });
1018        },
1019        propertiesGetPage: function(pageUrl, isBackButton){
1020            var self = this;
1021            if (self.filterAjax) { return false; }
1022
1023            self.propertiesSetCurrentUrl();
1024
1025            if (pageUrl) {
1026                // Show 'loader' overlay
1027                self.propertiesShowLoader();
1028                
1029                // Make sure the URL has a trailing-slash before query args (301 redirect fix)
1030                pageUrl = pageUrl.replace(/\/?(\?|#|$)/, '/$1');
1031                
1032                if (!isBackButton) {
1033                    self.setPushState(pageUrl);
1034                }
1035
1036                self.filterAjax = $.ajax({
1037                    url: pageUrl,
1038                    data: {
1039                        load_type: 'full'
1040                    },
1041                    dataType: 'html',
1042                    cache: false,
1043                    headers: {'cache-control': 'no-cache'},
1044                    
1045                    method: 'POST', // Note: Using "POST" method for the Ajax request to avoid "load_type" query-string in pagination links
1046                    
1047                    error: function(XMLHttpRequest, textStatus, errorThrown) {
1048                        console.log('Apus: AJAX error - propertiesGetPage() - ' + errorThrown);
1049                        
1050                        // Hide 'loader' overlay (after scroll animation)
1051                        self.propertiesHideLoader();
1052                        
1053                        self.filterAjax = false;
1054                    },
1055                    success: function(response) {
1056                        // Update properties content
1057                        self.propertiesUpdateContent(response);
1058                        
1059                        self.filterAjax = false;
1060                    }
1061                });
1062                
1063            }
1064        },
1065        propertiesHideLoader: function(){
1066            $('body').find('.main-items-wrapper').removeClass('loading');
1067        },
1068        propertiesShowLoader: function(){
1069            $('body').find('.main-items-wrapper').addClass('loading');
1070        },
1071        setPushState: function(pageUrl) {
1072            window.history.pushState({apusShop: true}, '', pageUrl);
1073        },
1074        propertiesSetCurrentUrl: function() {
1075            var self = this;
1076            
1077            // Set current page URL
1078            self.searchAndTagsResetURL = window.location.href;
1079        },
1080        /**
1081         *  Properties: Update properties content with AJAX HTML
1082         */
1083        propertiesUpdateContent: function(ajaxHTML) {
1084            var self = this,
1085                $ajaxHTML = $('<div>' + ajaxHTML + '</div>');
1086
1087            var $properties = $ajaxHTML.find('.main-items-wrapper'),
1088                $display_mode = $ajaxHTML.find('.properties-display-mode-wrapper-ajax .properties-display-mode-wrapper'),
1089                $pagination = $ajaxHTML.find('.main-pagination-wrapper');
1090
1091            // Replace properties
1092            if ($properties.length) {
1093                $('.main-items-wrapper').replaceWith($properties);
1094            }
1095            if ($display_mode.length) {
1096                $('.properties-display-mode-wrapper').replaceWith($display_mode);
1097            }
1098            // Replace pagination
1099            if ($pagination.length) {
1100                $('.main-pagination-wrapper').replaceWith($pagination);
1101            }
1102            
1103            // Load images (init Unveil)
1104            self.layzyLoadImage();
1105
1106            // pagination
1107            if ( $('.ajax-pagination').length ) {
1108                self.infloadScroll = false;
1109                self.ajaxPaginationLoad();
1110            }
1111
1112            if ( $.isFunction( $.fn.select2 ) && typeof wp_realestate_select2_opts !== 'undefined' ) {
1113                var select2_args = wp_realestate_select2_opts;
1114                select2_args['allowClear']              = false;
1115                select2_args['minimumResultsForSearch'] = 10;
1116                select2_args['width'] = 'auto';
1117                
1118                if ( typeof wp_realestate_select2_opts.language_result !== 'undefined' ) {
1119                    select2_args['language'] = {
1120                        noResults: function(){
1121                            return wp_realestate_select2_opts.language_result;
1122                        }
1123                    };
1124                }
1125                
1126                $('select.orderby').select2( select2_args );
1127            }
1128
1129            $('.btn-saved-search').magnificPopup({
1130                mainClass: 'wp-realestate-mfp-container',
1131                type:'inline',
1132                midClick: true
1133            });
1134            
1135            self.updateMakerCards('properties-google-maps');
1136            setTimeout(function() {
1137                // Hide 'loader'
1138                self.propertiesHideLoader();
1139            }, 100);
1140        },
1141
1142        /**
1143         *  Shop: Initialize infinite load
1144         */
1145        ajaxPaginationLoad: function() {
1146            var self = this,
1147                $infloadControls = $('body').find('.ajax-pagination'),                   
1148                nextPageUrl;
1149
1150            self.infloadScroll = ($infloadControls.hasClass('infinite-action')) ? true : false;
1151            
1152            if (self.infloadScroll) {
1153                self.infscrollLock = false;
1154                
1155                var pxFromWindowBottomToBottom,
1156                    pxFromMenuToBottom = Math.round($(document).height() - $infloadControls.offset().top);
1157                
1158                /* Bind: Window resize event to re-calculate the 'pxFromMenuToBottom' value (so the items load at the correct scroll-position) */
1159                var to = null;
1160                $(window).resize(function() {
1161                    if (to) { clearTimeout(to); }
1162                    to = setTimeout(function() {
1163                        var $infloadControls = $('.ajax-pagination'); // Note: Don't cache, element is dynamic
1164                        pxFromMenuToBottom = Math.round($(document).height() - $infloadControls.offset().top);
1165                    }, 100);
1166                });
1167                
1168                $(window).scroll(function(){
1169                    if (self.infscrollLock) {
1170                        return;
1171                    }
1172                    
1173                    pxFromWindowBottomToBottom = 0 + $(document).height() - ($(window).scrollTop()) - $(window).height();
1174                    
1175                    // If distance remaining in the scroll (including buffer) is less than the pagination element to bottom:
1176                    if (pxFromWindowBottomToBottom < pxFromMenuToBottom) {
1177                        self.ajaxPaginationGet();
1178                    }
1179                });
1180            } else {
1181                var $productsWrap = $('body');
1182                /* Bind: "Load" button */
1183                $productsWrap.on('click', '.main-pagination-wrapper .apus-loadmore-btn', function(e) {
1184                    e.preventDefault();
1185                    self.ajaxPaginationGet();
1186                });
1187                
1188            }
1189            
1190            if (self.infloadScroll) {
1191                $(window).trigger('scroll'); // Trigger scroll in case the pagination element (+buffer) is above the window bottom
1192            }
1193        },
1194        /**
1195         *  Shop: AJAX load next page
1196         */
1197        ajaxPaginationGet: function() {
1198            var self = this;
1199            
1200            if (self.filterAjax) return false;
1201            
1202            // Get elements (these can be replaced with AJAX, don't pre-cache)
1203            var $nextPageLink = $('.apus-pagination-next-link').find('a'),
1204                $infloadControls = $('.ajax-pagination'),
1205                nextPageUrl = $nextPageLink.attr('href');
1206            
1207            if (nextPageUrl) {
1208                // Show 'loader'
1209                $infloadControls.addClass('apus-loader');
1210                
1211                // self.setPushState(nextPageUrl);
1212
1213                self.filterAjax = $.ajax({
1214                    url: nextPageUrl,
1215                    data: {
1216                        load_type: 'items'
1217                    },
1218                    dataType: 'html',
1219                    cache: false,
1220                    headers: {'cache-control': 'no-cache'},
1221                    method: 'GET',
1222                    error: function(XMLHttpRequest, textStatus, errorThrown) {
1223                        console.log('APUS: AJAX error - ajaxPaginationGet() - ' + errorThrown);
1224                    },
1225                    complete: function() {
1226                        // Hide 'loader'
1227                        $infloadControls.removeClass('apus-loader');
1228                    },
1229                    success: function(response) {
1230                        var $response = $('<div>' + response + '</div>'), // Wrap the returned HTML string in a dummy 'div' element we can get the elements
1231                            $gridItemElement = $('.items-wrapper', $response).html(),
1232                            $resultCount = $('.results-count .last', $response).html(),
1233                            $display_mode = $('.main-items-wrapper').data('display_mode');
1234                        
1235
1236                        // Append the new elements
1237                        if ( $display_mode == 'grid') {
1238                            $('.main-items-wrapper .items-wrapper .row').append($gridItemElement);
1239                        } else {
1240                            $('.main-items-wrapper .items-wrapper').append($gridItemElement);
1241                        }
1242                        
1243                        // Append results
1244                        $('.main-items-wrapper .results-count .last').html($resultCount);
1245
1246                        // Update Maps
1247                        self.updateMakerCards('properties-google-maps');
1248                        
1249                        // Load images (init Unveil)
1250                        self.layzyLoadImage();
1251                        
1252                        // Get the 'next page' URL
1253                        nextPageUrl = $response.find('.apus-pagination-next-link').children('a').attr('href');
1254                        
1255                        if (nextPageUrl) {
1256                            $nextPageLink.attr('href', nextPageUrl);
1257                        } else {
1258                            $('.main-items-wrapper').addClass('all-properties-loaded');
1259                            
1260                            if (self.infloadScroll) {
1261                                self.infscrollLock = true;
1262                            }
1263                            $infloadControls.find('.apus-loadmore-btn').addClass('hidden');
1264                            $nextPageLink.removeAttr('href');
1265                        }
1266                        
1267                        self.filterAjax = false;
1268                        
1269                        if (self.infloadScroll) {
1270                            $(window).trigger('scroll'); // Trigger 'scroll' in case the pagination element (+buffer) is still above the window bottom
1271                        }
1272                    }
1273                });
1274            } else {
1275                if (self.infloadScroll) {
1276                    self.infscrollLock = true; // "Lock" scroll (no more products/pages)
1277                }
1278            }
1279        },
1280        shortenNumber: function($number) {
1281            var self = this;
1282
1283            var divisors = wp_realestate_opts.divisors;
1284            var $key_sign = '';
1285            $.each(divisors, function( $index, $value ) {
1286                if ($number < ($value['divisor'] * 1000)) {
1287                    $key_sign = $value['key'];
1288                    $number = $number / $value['divisor'];
1289                    return false;
1290                }
1291            });
1292
1293            return self.addCommas($number) + $key_sign;
1294        },
1295        addCommas: function(str) {
1296            var parts = (str + "").split("."),
1297                main = parts[0],
1298                len = main.length,
1299                output = "",
1300                first = main.charAt(0),
1301                i;
1302            
1303            if (first === '-') {
1304                main = main.slice(1);
1305                len = main.length;    
1306            } else {
1307                first = "";
1308            }
1309            i = len - 1;
1310            while(i >= 0) {
1311                output = main.charAt(i) + output;
1312                if ((len - i) % 3 === 0 && i > 0) {
1313                    output = wp_realestate_opts.money_thousands_separator + output;
1314                }
1315                --i;
1316            }
1317            // put sign back
1318            output = first + output;
1319            // put decimal part back
1320            if (parts.length > 1) {
1321                output += wp_realestate_opts.money_dec_point + parts[1];
1322            }
1323            
1324            return output;
1325        },
1326        galleryPropery: function() {
1327            var self = this;
1328            $(document).on( 'mouseenter', 'article.property-item', function(){
1329                if ( !$(this).hasClass('loaded-gallery') && $(this).data('images') ) {
1330                    var $this = $(this);
1331                    var href = $(this).find('a.property-image').attr('href')
1332                    var images = $(this).data('images');
1333                    var html = '<div class="slick-carousel-gallery-properties hidden" style="width: ' + $(this).find('.property-thumbnail-wrapper').width() + 'px;"><div class="slick-carousel" data-items="1" data-smallmedium="1" data-extrasmall="1" data-pagination="false" data-nav="true" data-disable_draggable="true">';
1334                    images.forEach(function(img_url, index){
1335                        html += '<div class="item"><a class="property-image" href="'+ href +'"><img src="'+img_url+'"></a></div>';
1336                    });
1337                    html += '</div></div>';
1338                    $(this).find('.property-thumbnail-wrapper .image-thumbnail').append(html);
1339
1340                    $(this).find('.slick-carousel-gallery-properties').imagesLoaded( function(){
1341
1342                        $this.find('.slick-carousel-gallery-properties').removeClass("hidden").delay(200).queue(function(){
1343                            $(this).addClass("active").dequeue();
1344                        });
1345
1346                        self.initSlick($this.find('.slick-carousel'));
1347                        
1348                    }).progress( function( instance, image ) {
1349                        $this.addClass('images-loading');
1350                    }).done( function( instance ) {
1351                        $this.addClass('images-loaded').removeClass('images-loading');
1352                    });
1353
1354                    $(this).addClass('loaded-gallery');
1355                }
1356            });
1357        }
1358    });
1359
1360    $.apusThemeExtensions.property = $.apusThemeCore.property_init;
1361
1362    
1363})(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.