PageSourceSearch

https://skyrealestate.co/wp-content/themes/homeo/js/property.js?ver=20150330

js skyrealestate.co collected 2026-10-04 13:25:33 UTC 62,004 bytes, 1,351 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            if ($(window).width() >= 1200) {
457                var header_h = $('#apus-header').outerHeight();
458                $('#apus-main-content').css({ 'padding-top': 0 });
459                $('body.page-template-page-dashboard #apus-main-content').css({ 'padding-top': header_h });
460            } else {
461                var header_h = $('#apus-header-mobile').outerHeight();
462                $('#apus-main-content').css({ 'padding-top': header_h });
463            }
464            
465            if ($('#properties-google-maps').is('.fix-map')) {
466                $('#properties-google-maps').css({ 'top': header_h, 'height': 'calc(100vh - ' + header_h+ 'px)' });
467                // filter for half 3
468                if ($(window).width() >= 1200) {
469                    $('.layout-type-half-map-v3 .properties-filter-sidebar-wrapper ').css({ 'top': header_h, 'height': 'calc(100vh - ' + header_h+ 'px)' });
470                    $('#apus-main-content').css({ 'padding-top': header_h });
471                }
472            }
473            // fix for half map
474            $('.layout-type-half-map .filter-sidebar').css({ 'padding-top': header_h + 30 });
475            // $('.layout-type-half-map .filter-scroll').perfectScrollbar();
476            if ( $('.layout-type-half-map .filter-scroll').length ) {
477                var ps = new PerfectScrollbar('.layout-type-half-map .filter-scroll', {
478                    wheelPropagation: true
479                });
480            }
481            // offcanvas-filter-sidebar 
482            $('.offcanvas-filter-sidebar').css({ 'padding-top': header_h + 10 });
483        },
484        agentAgencyLoadMore: function() {
485            $(document).on('click', '.ajax-properties-pagination .apus-loadmore-btn', function(e){
486                e.preventDefault();
487                var $this = $(this);
488                
489                $this.addClass('loading');
490
491                var ajaxurl = homeo_property_opts.ajaxurl;
492                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
493                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_get_ajax_properties_load_more' );
494                }
495
496                $.ajax({
497                    url: ajaxurl,
498                    type:'POST',
499                    dataType: 'json',
500                    data: {
501                        action: 'homeo_get_ajax_properties_load_more',
502                        paged: $this.data('paged'),
503                        post_id: $this.data('post_id'),
504                        type: $this.data('type'),
505                    }
506                }).done(function(data) {
507                    $this.removeClass('loading');
508                    $this.closest('.agent-agency-detail-properties').find('.row').append(data.output);
509                    $this.data('paged', data.paged);
510                    if ( !data.load_more ) {
511                        $this.closest('.ajax-properties-pagination').addClass('all-properties-loaded');
512                    }
513                });
514            });
515
516            $(document).on('click', '.ajax-agents-pagination .apus-loadmore-btn', function(e){
517                e.preventDefault();
518                var $this = $(this);
519                    
520                $this.addClass('loading');
521
522                var ajaxurl = homeo_property_opts.ajaxurl;
523                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
524                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_get_ajax_agents_load_more' );
525                }
526
527                $.ajax({
528                    url: ajaxurl,
529                    type:'POST',
530                    dataType: 'json',
531                    data: {
532                        action: 'homeo_get_ajax_agents_load_more',
533                        paged: $this.data('paged'),
534                        post_id: $this.data('post_id'),
535                    }
536                }).done(function(data) {
537                    $this.removeClass('loading');
538                    $this.closest('.agent-detail-agents').find('.row').append(data.output);
539                    $this.data('paged', data.paged);
540                    if ( !data.load_more ) {
541                        $this.closest('.ajax-agents-pagination').addClass('all-properties-loaded');
542                    }
543                });
544            });
545        },
546        propertyChangeMarginTopAffix: function() {
547            var affix_height = 0;
548            //if ($(window).width() > 991) {
549                if ( $('.panel-affix').length > 0 ) {
550                    affix_height = $('.panel-affix').outerHeight();
551                    $('.panel-affix-wrapper').css({'height': affix_height});
552                }
553            //}
554            return affix_height;
555        },
556        listingDetail: function() {
557            var self = this;
558            
559            // sticky tabs
560            var affix_height = 0;
561            var affix_height_top = 0;
562            setTimeout(function(){
563                affix_height = affix_height_top = self.propertyChangeMarginTopAffix();
564            }, 50);
565            $(window).resize(function(){
566                affix_height = affix_height_top = self.propertyChangeMarginTopAffix();
567            });
568            if ($(window).width() >= 1200) {
569                //Function from Bluthemes, lets you add li elemants to affix object without having to alter and data attributes set out by bootstrap
570                setTimeout(function(){
571                    // name your elements here
572                    var stickyElement   = '.panel-affix',   // the element you want to make sticky
573                        bottomElement   = '#apus-footer'; // the bottom element where you want the sticky element to stop (usually the footer) 
574
575                    // make sure the element exists on the page before trying to initalize
576                    if($( stickyElement ).length){
577                        $( stickyElement ).each(function(){
578                            var header_height = 0;
579                            if ($(window).width() >= 1200) {
580                                if ($('.main-sticky-header').length > 0) {
581                                    header_height = $('.main-sticky-header').outerHeight();
582                                    affix_height_top = affix_height + header_height;
583                                }
584                            } else {
585                                header_height = $('#apus-header-mobile').outerHeight();
586                                affix_height_top = affix_height + header_height;
587                                header_height = 0;
588                            }
589                            affix_height_top = affix_height_top + 10;
590                            // let's save some messy code in clean variables
591                            // when should we start affixing? (the amount of pixels to the top from the element)
592                            var fromTop = $( this ).offset().top, 
593                                // where is the bottom of the element?
594                                fromBottom = $( document ).height()-($( this ).offset().top + $( this ).outerHeight()),
595                                // where should we stop? (the amount of pixels from the top where the bottom element is)
596                                // also add the outer height mismatch to the height of the element to account for padding and borders
597                                stopOn = ($( this ).outerHeight() - $( this ).height()); 
598                
599                            // if the element doesn't need to get sticky, then skip it so it won't mess up your layout
600                            if( (fromBottom-stopOn) > 200 ){
601                                // let's put a sticky width on the element and assign it to the top
602                                $( this ).css('width', $( this ).width()).css('top', 0).css('position', '');
603                                // assign the affix to the element
604                                $( this ).affix({
605                                    offset: { 
606                                        // make it stick where the top pixel o
606f the element is
607                                        top: fromTop - header_height,  
608                                        // make it stop where the top pixel of the bottom element is
609                                        bottom: stopOn
610                                    }
611                                // when the affix get's called then make sure the position is the default (fixed) and it's at the top
612                                }).on('affix.bs.affix', function(){
613                                    var header_height = 0;
614                                    if ($(window).width() >= 1200) {
615                                        if ($('.main-sticky-header').length > 0) {
616                                            header_height = $('.main-sticky-header').outerHeight();
617                                            affix_height_top = affix_height + header_height;
618                                        }
619                                    } else {
620                                        header_height = $('#apus-header-mobile').outerHeight();
621                                        affix_height_top = affix_height + header_height;
622                                        header_height = 0;
623                                    }
624                                    affix_height_top = affix_height_top + 10;
625                                    $( this ).css('top', header_height).css('position', header_height);
626                                });
627                            }
628                            // trigger the scroll event so it always activates 
629                            $( window ).trigger('scroll'); 
630                        }); 
631                    }
632
633                    //Offset scrollspy height to highlight li elements at good window height
634                    $('body').scrollspy({
635                        target: ".header-tabs-wrapper",
636                        offset: affix_height_top + 20
637                    });
638                }, 50);
639            }
640            
641
642            //Smooth Scrolling For Internal Page Links
643            $('.panel-affix a[href*="#"]:not([href="#"])').on('click', function() {
644                if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
645                    var target = $(this.hash);
646                    target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
647                    if (target.length) {
648                        $('html,body').animate({
649                            scrollTop: target.offset().top - affix_height_top
650                        }, 1000);
651                        return false;
652                    }
653                }
654            });
655
656
657
658            $(document).on('click', '.add-a-review', function(e) {
659                e.preventDefault();
660                var $id = $(this).attr('href');
661                if ( $($id).length > 0 ) {
662                    $('html,body').animate({
663                        scrollTop: $($id).offset().top - 100
664                    }, 1000);
665                }
666            });
667
668            $(document).on('click', '.btn-view-all-photos', function(e){
669                $(this).closest('.property-detail-gallery').find('a:first').trigger('click');
670            });
671
672            $('.btn-print-property').on('click', function(e){
673                e.preventDefault();
674                
675                var $this = $(this);
676                $this.addClass('loading');
677                var property_id = $(this).data('property_id');
678                var nonce = $(this).data('nonce');
679
680                var ajaxurl = homeo_property_opts.ajaxurl;
681                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
682                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_ajax_print_property' );
683                }
684
685                var printWindow = window.open('', 'Print Me', 'width=700 ,height=842');
686                $.ajax({
687                    url: ajaxurl,
688                    type:'POST',
689                    dataType: 'html',
690                    data: {
691                        'property_id': property_id,
692                        'nonce': nonce,
693                        'action': 'homeo_ajax_print_property',
694                    }
695                }).done(function(data) {
696                    $this.removeClass('loading');
697                    
698                    
699                    printWindow.document.write(data);
700                    printWindow.document.close();
701                    printWindow.focus();
702
703                    // setTimeout(function(){
704                    //     printWindow.print();
705                    // }, 2000);
706                    // printWindow.close();
707
708                });
709
710            });
711        },
712        listingBtnFilter: function(){
713            $('.btn-view-map').on('click', function(e){
714                e.preventDefault();
715                $('#properties-google-maps').removeClass('hidden-sm').removeClass('hidden-xs');
716                $('.content-listing .properties-listing-wrapper, .content-listing .agencies-listing-wrapper').addClass('hidden-sm').addClass('hidden-xs');
717                $('.btn-view-listing').removeClass('hidden-sm').removeClass('hidden-xs');
718                $(this).addClass('hidden-sm').addClass('hidden-xs');
719                $('.properties-pagination-wrapper, .agencies-pagination-wrapper').addClass('p-fix-pagination');
720                setTimeout(function() {
721                    $(window).trigger('pxg:refreshmap');
722                }, 100);
723            });
724            $('.btn-view-listing').on('click', function(e){
725                e.preventDefault();
726                $('#properties-google-maps').addClass('hidden-sm').addClass('hidden-xs');
727                $('.content-listing .properties-listing-wrapper, .content-listing .agencies-listing-wrapper').removeClass('hidden-sm').removeClass('hidden-xs');
728                $('.btn-view-map').removeClass('hidden-sm').removeClass('hidden-xs');
729                $(this).addClass('hidden-sm').addClass('hidden-xs');
730                $('.properties-pagination-wrapper, .agencies-pagination-wrapper').removeClass('p-fix-pagination');
731            });
732
733            $('.show-filter-properties, .filter-in-sidebar').on('click', function(e){
734                e.stopPropagation();
735                $('.layout-type-half-map .filter-sidebar').toggleClass('active');
736                $('.filter-sidebar + .over-dark').toggleClass('active');
737            });
738            
739            $(document).on('click', '.filter-sidebar + .over-dark', function(){
740                $('.layout-type-half-map .filter-sidebar').removeClass('active');
741                $('.filter-sidebar + .over-dark').removeClass('active');
742            });
743
744            // filter sidebar fixed
745            $(document).on('click', '.properties-filter-sidebar-wrapper .close-filter, .btn-show-filter, .properties-filter-sidebar-wrapper + .over-dark-filter', function(){
746                $('.properties-filter-sidebar-wrapper').toggleClass('active');
747            });
748        },
749        userLoginRegister: function(){
750            var self = this;
751            // login/register
752            $('.user-login-form, .must-log-in').on('click', function(e){
753                e.preventDefault();
754                if ( $('.apus-user-login').length ) {
755                    $('.apus-user-login').trigger('click');
756                }
757            });
758            $('.apus-user-login, .apus-user-register').on('click', function(){
759                self.layzyLoadImage();
760            });
761            $('.apus-user-login, .apus-user-register').magnificPopup({
762                mainClass: 'apus-mfp-zoom-in login-popup',
763                type:'inline',
764                midClick: true,
765                callbacks: {
766                    open: function() {
767                        self.layzyLoadImage();
768                        $(window).trigger('resize');
769                    }
770                }
771            });
772              
773        },
774
775        filterListingFnc: function(){
776            var self = this;
777            $('body').on('click', '.btn-show-filter, .offcanvas-filter-sidebar + .over-dark', function(){
778                $('.offcanvas-filter-sidebar, .offcanvas-filter-sidebar + .over-dark').toggleClass('active');
779                // $('.offcanvas-filter-sidebar').perfectScrollbar();
780                if ( $('.offcanvas-filter-sidebar').length ) {
781                    var ps = new PerfectScrollbar('.offcanvas-filter-sidebar', {
782                        wheelPropagation: true
783                    });
784                }
785                
786            });
787
788            $(document).on('after_add_property_favorite', function(e, $this, data) {
789                $this.attr('data-original-title', homeo_property_opts.favorite_added_tooltip_title);
790            });
791            $(document).on('after_remove_property_favorite', function( event, $this, data ) {
792                $this.attr('data-original-title', homeo_property_opts.favorite_add_tooltip_title);
793            });
794
795            $('body').on('click', function() {
796                if ( $(this).find('.price-input-wrapper').length ) {
797                    $(this).find('.price-input-wrapper').slideUp();
798                }
799            });
800
801            $('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){
802                e.stopPropagation();
803            });
804            $('body').on('click', '.heading-filter-price', function(){
805                $(this).closest('.from-to-wrapper').find('.price-input-wrapper').slideToggle();
806            });
807            $('body').on('keyup', '.price-input-wrapper input', function(){
808                var $from_val = $(this).closest('.price-input-wrapper').find('.filter-from').val();
809                var $to_val = $(this).closest('.price-input-wrapper').find('.filter-to').val();
810                var $wrapper = $(this).closest('.from-to-text-wrapper');
811
812                if ( $wrapper.hasClass('price') ) {
813                    if ( wp_realestate_opts.enable_multi_currencies === 'yes' ) {
814                        $from_val = self.shortenNumber($from_val);
815                        $to_val = self.shortenNumber($to_val);
816                    } else {
817                        $from_val = self.addCommas($from_val);
818                        $to_val = self.addCommas($to_val);
819                    }
820                    $wrapper.find('.from-text .price-text').text( $from_val );
821                    $wrapper.find('.to-text .price-text').text( $to_val );
822                } else {
823                    $wrapper.find('.from-text').text( $from_val );
824                    $wrapper.find('.to-text').text( $to_val );
825                }
826            });
827            $('body').on('change', '.price-input-wrapper input', function(){
828                var $from_val = $(this).closest('.price-input-wrapper').find('.filter-from').val();
829                var $to_val = $(this).closest('.price-input-wrapper').find('.filter-to').val();
830                var $wrapper = $(this).closest('.from-to-text-wrapper');
831                if ( $wrapper.hasClass('price') ) {
832                    if ( wp_realestate_opts.enable_multi_currencies === 'yes' ) {
833                        $from_val = self.shortenNumber($from_val);
834                        $to_val = self.shortenNumber($to_val);
835                    } else {
836                        $from_val = self.addCommas($from_val);
837                        $to_val = self.addCommas($to_val);
838                    }
839
840                    $wrapper.find('.from-text .price-text').text( $from_val );
841                    $wrapper.find('.to-text .price-text').text( $to_val );
842                } else {
843                    $wrapper.find('.from-text').text( $from_val );
844                    $wrapper.find('.to-text').text( $to_val );
845                }
846            });
847            $('body').on('click', '.from-to-wrapper.price-list .price-filter li', function(){
848                var $parent = $(this).closest('.from-to-wrapper');
849                var $min = $(this).data('min');
850                var $max = $(this).data('max');
851                $parent.find('input.filter-from').val($min);
852                $parent.find('input.filter-to').val($max);
853                $(this).closest('.from-to-wrapper').find('.heading-filter-price .price-text').html($(this).find('.price-text').html());
854                $(this).closest('.price-input-wrapper').slideUp();
855                $(this).closest('form').trigger('submit');
856            });
857        },
858        propertyCompare: function(){
859            var self = this;
860            if ( $('.compare-sidebar-inner .compare-list').length ) {
861                var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
862                    wheelPropagation: true
863                });
864            }
865
866            $(document).on('after_add_property_compare', function(e, $this, data) {
867                var html_output = '';
868                if ( data.html_output ) {
869                    html_output = data.html_output;
870                }
871                $('#compare-sidebar .compare-sidebar-inner').html(html_output);
872                $('.compare-sidebar-btn .count').html(data.count);
873
874                if ( $('.compare-sidebar-inner .compare-list').length ) {
875                    var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
876                        wheelPropagation: true
877                    });
878                }
879
880                self.layzyLoadImage();
881
882                if ( !$('#compare-sidebar').hasClass('active') ) {
883                    $('#compare-sidebar').addClass('active');
884                }
885                if ( !$('#compare-sidebar').hasClass('open') ) {
886                    $('#compare-sidebar').addClass('open');
887                }
888                $this.attr('data-original-title', homeo_property_opts.c
888ompare_added_tooltip_title);
889            });
890            
891            $(document).on('after_remove_property_compare', function( event, $this, data ) {
892                var html_output = '';
893                if ( data.html_output ) {
894                    html_output = data.html_output;
895                }
896                $('#compare-sidebar .compare-sidebar-inner').html(html_output);
897                $('.compare-sidebar-btn .count').html(data.count);
898                
899                if ( $('.compare-sidebar-inner .compare-list').length ) {
900                    var ps = new PerfectScrollbar('.compare-sidebar-inner .compare-list', {
901                        wheelPropagation: true
902                    });
903                }
904
905                if ( data.count == '0' ) {
906                    $('#compare-sidebar').removeClass('active');
907                }
908
909                $this.attr('data-original-title', homeo_property_opts.compare_add_tooltip_title);
910
911                self.layzyLoadImage();
912            });
913
914            $('.compare-sidebar-inner').on('click', '.btn-remove-property-compare-list', function(e) {
915                e.stopPropagation();
916                var $this = $(this);
917                $this.addClass('loading');
918                var property_id = $(this).data('property_id');
919                var nonce = $(this).data('nonce');
920
921                var ajaxurl = homeo_property_opts.ajaxurl;
922                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
923                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_compare' );
924                }
925                $.ajax({
926                    url: ajaxurl,
927                    type:'POST',
928                    dataType: 'json',
929                    data: {
930                        'property_id': property_id,
931                        'nonce': nonce,
932                        'action': 'wp_realestate_ajax_remove_property_compare',
933                    }
934                }).done(function(data) {
935                    $this.removeClass('loading');
936                    if ( data.status ) {
937                        
938                        $(document).trigger( "after_remove_property_compare", [$this, data] );
939
940                        if ( $('.btn-remove-property-compare-list').length <= 0 ) {
941                            $('#compare-sidebar').removeClass('active');
942                            $('#compare-sidebar').removeClass('open');
943                        }
944
945                        $('a.btn-added-property-compare').each(function(){
946                            if ( property_id == $(this).data('property_id') ) {
947                                $(this).removeClass('btn-added-property-compare').addClass('btn-add-property-compare');
948                                $(this).data('nonce', data.nonce);
949                            }
950                        });
951                    }
952                });
953            });
954
955            $('.compare-sidebar-inner').on('click', '.btn-remove-compare-all', function(e) {
956                e.stopPropagation();
957                var $this = $(this);
958                $this.addClass('loading');
959                var nonce = $(this).data('nonce');
960
961                var ajaxurl = homeo_property_opts.ajaxurl;
962                if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
963                    var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_all_property_compare' );
964                }
965
966                $.ajax({
967                    url: ajaxurl,
968                    type:'POST',
969                    dataType: 'json',
970                    data: {
971                        'nonce': nonce,
972                        'action': 'wp_realestate_ajax_remove_all_property_compare',
973                    }
974                }).done(function(data) {
975                    $this.removeClass('loading');
976                    if ( data.status ) {
977                        
978                        $(document).trigger( "after_remove_property_compare", [$this, data] );
979
980                        $('a.btn-added-property-compare').each(function(){
981                            $(this).removeClass('btn-added-property-compare').addClass('btn-add-property-compare');
982                            $(this).data('nonce', data.nonce);
983                        });
984                    }
985                });
986            });
987
988            $('body').on('click', '#compare-sidebar .compare-sidebar-btn', function(e){
989                e.stopPropagation();
990                $('#compare-sidebar').toggleClass('open');
991                if ($('#compare-sidebar').hasClass('open')) {
992                    $('body').css({ 'overflow': 'hidden' });
993                } else {
994                    $('body').css({ 'overflow': 'initial' });
995                }
996            });
997            $('body').on('click', function() {
998                if ($('#compare-sidebar').hasClass('open')) {
999                    $('#compare-sidebar').removeClass('open');
1000                    $('body').css({ 'overflow': 'initial' });
1001                }
1002            });
1003            $('.compare-sidebar-inner').on('click', function(e) {
1004                e.stopPropagation();
1005            });
1006        },
1007        propertiesGetPage: function(pageUrl, isBackButton){
1008            var self = this;
1009            if (self.filterAjax) { return false; }
1010
1011            self.propertiesSetCurrentUrl();
1012
1013            if (pageUrl) {
1014                // Show 'loader' overlay
1015                self.propertiesShowLoader();
1016                
1017                // Make sure the URL has a trailing-slash before query args (301 redirect fix)
1018                pageUrl = pageUrl.replace(/\/?(\?|#|$)/, '/$1');
1019                
1020                if (!isBackButton) {
1021                    self.setPushState(pageUrl);
1022                }
1023
1024                self.filterAjax = $.ajax({
1025                    url: pageUrl,
1026                    data: {
1027                        load_type: 'full'
1028                    },
1029                    dataType: 'html',
1030                    cache: false,
1031                    headers: {'cache-control': 'no-cache'},
1032                    
1033                    method: 'POST', // Note: Using "POST" method for the Ajax request to avoid "load_type" query-string in pagination links
1034                    
1035                    error: function(XMLHttpRequest, textStatus, errorThrown) {
1036                        console.log('Apus: AJAX error - propertiesGetPage() - ' + errorThrown);
1037                        
1038                        // Hide 'loader' overlay (after scroll animation)
1039                        self.propertiesHideLoader();
1040                        
1041                        self.filterAjax = false;
1042                    },
1043                    success: function(response) {
1044                        // Update properties content
1045                        self.propertiesUpdateContent(response);
1046                        
1047                        self.filterAjax = false;
1048                    }
1049                });
1050                
1051            }
1052        },
1053        propertiesHideLoader: function(){
1054            $('body').find('.main-items-wrapper').removeClass('loading');
1055        },
1056        propertiesShowLoader: function(){
1057            $('body').find('.main-items-wrapper').addClass('loading');
1058        },
1059        setPushState: function(pageUrl) {
1060            window.history.pushState({apusShop: true}, '', pageUrl);
1061        },
1062        propertiesSetCurrentUrl: function() {
1063            var self = this;
1064            
1065            // Set current page URL
1066            self.searchAndTagsResetURL = window.location.href;
1067        },
1068        /**
1069         *  Properties: Update properties content with AJAX HTML
1070         */
1071        propertiesUpdateContent: function(ajaxHTML) {
1072            var self = this,
1073                $ajaxHTML = $('<div>' + ajaxHTML + '</div>');
1074
1075            var $properties = $ajaxHTML.find('.main-items-wrapper'),
1076                $display_mode = $ajaxHTML.find('.properties-display-mode-wrapper-ajax .properties-display-mode-wrapper'),
1077                $pagination = $ajaxHTML.find('.main-pagination-wrapper');
1078
1079            // Replace properties
1080            if ($properties.length) {
1081                $('.main-items-wrapper').replaceWith($properties);
1082            }
1083            if ($display_mode.length) {
1084                $('.properties-display-mode-wrapper').replaceWith($display_mode);
1085            }
1086            // Replace pagination
1087            if ($pagination.length) {
1088                $('.main-pagination-wrapper').replaceWith($pagination);
1089            }
1090            
1091            // Load images (init Unveil)
1092            self.layzyLoadImage();
1093
1094            // pagination
1095            if ( $('.ajax-pagination').length ) {
1096                self.infloadScroll = false;
1097                self.ajaxPaginationLoad();
1098            }
1099
1100            if ( $.isFunction( $.fn.select2 ) && typeof wp_realestate_select2_opts !== 'undefined' ) {
1101                var select2_args = wp_realestate_select2_opts;
1102                select2_args['allowClear']              = false;
1103                select2_args['minimumResultsForSearch'] = 10;
1104                select2_args['width'] = 'auto';
1105                
1106                if ( typeof wp_realestate_select2_opts.language_result !== 'undefined' ) {
1107                    select2_args['language'] = {
1108                        noResults: function(){
1109                            return wp_realestate_select2_opts.language_result;
1110                        }
1111                    };
1112                }
1113                
1114                $('select.orderby').select2( select2_args );
1115            }
1116
1117            $('.btn-saved-search').magnificPopup({
1118                mainClass: 'wp-realestate-mfp-container',
1119                type:'inline',
1120                midClick: true
1121            });
1122            
1123            self.updateMakerCards('properties-google-maps');
1124            setTimeout(function() {
1125                // Hide 'loader'
1126                self.propertiesHideLoader();
1127            }, 100);
1128        },
1129
1130        /**
1131         *  Shop: Initialize infinite load
1132         */
1133        ajaxPaginationLoad: function() {
1134            var self = this,
1135                $infloadControls = $('body').find('.ajax-pagination'),                   
1136                nextPageUrl;
1137
1138            self.infloadScroll = ($infloadControls.hasClass('infinite-action')) ? true : false;
1139            
1140            if (self.infloadScroll) {
1141                self.infscrollLock = false;
1142                
1143                var pxFromWindowBottomToBottom,
1144                    pxFromMenuToBottom = Math.round($(document).height() - $infloadControls.offset().top);
1145                
1146                /* Bind: Window resize event to re-calculate the 'pxFromMenuToBottom' value (so the items load at the correct scroll-position) */
1147                var to = null;
1148                $(window).resize(function() {
1149                    if (to) { clearTimeout(to); }
1150                    to = setTimeout(function() {
1151                        var $infloadControls = $('.ajax-pagination'); // Note: Don't cache, element is dynamic
1152                        pxFromMenuToBottom = Math.round($(document).height() - $infloadControls.offset().top);
1153                    }, 100);
1154                });
1155                
1156                $(window).scroll(function(){
1157                    if (self.infscrollLock) {
1158                        return;
1159                    }
1160                    
1161                    pxFromWindowBottomToBottom = 0 + $(document).height() - ($(window).scrollTop()) - $(window).height();
1162                    
1163                    // If distance remaining in the scroll (including buffer) is less than the pagination element to bottom:
1164                    if (pxFromWindowBottomToBottom < pxFromMenuToBottom) {
1165                        self.ajaxPaginationGet();
1166                    }
1167                });
1168            } else {
1169                var $productsWrap = $('body');
1170                /* Bind: "Load" button */
1171                $productsWrap.on('click', '.main-pagination-wrapper .apus-loadmore-btn', function(e) {
1172                    e.preventDefault();
1173                    self.ajaxPaginationGet();
1174                });
1175                
1176            }
1177            
1178            if (self.infloadScroll) {
1179                $(window).trigger('scroll'); // Trigger scroll in case the pagination element (+buffer) is above the window bottom
1180            }
1181        },
1182        /**
1183         *  Shop: AJAX load next page
1184         */
1185        ajaxPaginationGet: function() {
1186            var self = this;
1187            
1188            if (self.filterAjax) return false;
1189            
1190            // Get elements (these can be replaced with AJAX, don't pre-cache)
1191            var $nextPageLink = $('.apus-pagination-next-link').find('a'),
1192                $infloadControls = $('.ajax-pagination'),
1193                nextPageUrl = $nextPageLink.attr('href');
1194            
1195            if (nextPageUrl) {
1196                // Show 'loader'
1197                $infloadControls.addClass('apus-loader');
1198                
1199                // self.setPushState(nextPageUrl);
1200
1201                self.filterAjax = $.ajax({
1202                    url: nextPageUrl,
1203                    data: {
1204                        load_type: 'items'
1205                    },
1206                    dataType: 'html',
1207                    cache: false,
1208                    headers: {'cache-control': 'no-cache'},
1209                    method: 'GET',
1210                    error: function(XMLHttpRequest, textStatus, errorThrown) {
1211                        console.log('APUS: AJAX error - ajaxPaginationGet() - ' + errorThrown);
1212                    },
1213                    complete: function() {
1214                        // Hide 'loader'
1215                        $infloadControls.removeClass('apus-loader');
1216                    },
1217                    success: function(response) {
1218                        var $response = $('<div>' + response + '</div>'), // Wrap the returned HTML string in a dummy 'div' element we can get the elements
1219                            $gridItemElement = $('.items-wrapper', $response).html(),
1220                            $resultCount = $('.results-count .last', $response).html(),
1221                            $display_mode = $('.main-items-wrapper').data('display_mode');
1222                        
1223
1224                        // Append the new elements
1225                        if ( $display_mode == 'grid') {
1226                            $('.main-items-wrapper .items-wrapper .row').append($gridItemElement);
1227                        } else {
1228                            $('.main-items-wrapper .items-wrapper').append($gridItemElement);
1229                        }
1230                        
1231                        // Append results
1232                        $('.main-items-wrapper .results-count .last').html($resultCount);
1233
1234                        // Update Maps
1235                        self.updateMakerCards('properties-google-maps');
1236                        
1237                        // Load images (init Unveil)
1238                        self.layzyLoadImage();
1239                        
1240                        // Get the 'next page' URL
1241                        nextPageUrl = $response.find('.apus-pagination-next-link').children('a').attr('href');
1242                        
1243                        if (nextPageUrl) {
1244                            $nextPageLink.attr('href', nextPageUrl);
1245                        } else {
1246                            $('.main-items-wrapper').addClass('all-properties-loaded');
1247                            
1248                            if (self.infloadScroll) {
1249                                self.infscrollLock = true;
1250                            }
1251                            $infloadControls.find('.apus-loadmore-btn').addClass('hidden');
1252                            $nextPageLink.removeAttr('href');
1253                        }
1254                        
1255                        self.filterAjax = false;
1256                        
1257                        if (self.infloadScroll) {
1258                            $(window).trigger('scroll'); // Trigger 'scroll' in case the pagination element (+buffer) is still above the window bottom
1259                        }
1260                    }
1261                });
1262            } else {
1263                if (self.infloadScroll) {
1264                    self.infscrollLock = true; // "Lock" scroll (no more products/pages)
1265                }
1266            }
1267        },
1268        shortenNumber: function($number) {
1269            var self = this;
1270
1271            var divisors = wp_realestate_opts.divisors;
1272            var $key_sign = '';
1273            $.each(divisors, function( $index, $value ) {
1274                if ($number < ($value['divisor'] * 1000)) {
1275                    $key_sign = $value['key'];
1276                    $number = $number / $value['divisor'];
1277                    return false;
1278                }
1279            });
1280
1281            return self.addCommas($number) + $key_sign;
1282        },
1283        addCommas: function(str) {
1284            var parts = (str + "").split("."),
1285                main = parts[0],
1286                len = main.length,
1287                output = "",
1288                first = main.charAt(0),
1289                i;
1290            
1291            if (first === '-') {
1292                main = main.slice(1);
1293                len = main.length;    
1294            } else {
1295                first = "";
1296            }
1297            i = len - 1;
1298            while(i >= 0) {
1299                output = main.charAt(i) + output;
1300                if ((len - i) % 3 === 0 && i > 0) {
1301                    output = wp_realestate_opts.money_thousands_separator + output;
1302                }
1303                --i;
1304            }
1305            // put sign back
1306            output = first + output;
1307            // put decimal part back
1308            if (parts.length > 1) {
1309                output += wp_realestate_opts.money_dec_point + parts[1];
1310            }
1311            
1312            return output;
1313        },
1314        galleryPropery: function() {
1315            var self = this;
1316            $(document).on( 'mouseenter', 'article.property-item', function(){
1317                if ( !$(this).hasClass('loaded-gallery') && $(this).data('images') ) {
1318                    var $this = $(this);
1319                    var href = $(this).find('a.property-image').attr('href')
1320                    var images = $(this).data('images');
1321                    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">';
1322                    images.forEach(function(img_url, index){
1323                        html += '<div class="item"><a class="property-image" href="'+ href +'"><img src="'+img_url+'"></a></div>';
1324                    });
1325                    html += '</div></div>';
1326                    $(this).find('.property-thumbnail-wrapper .image-thumbnail').append(html);
1327
1328                    $(this).find('.slick-carousel-gallery-properties').imagesLoaded( function(){
1329
1330                        $this.find('.slick-carousel-gallery-properties').removeClass("hidden").delay(200).queue(function(){
1331                            $(this).addClass("active").dequeue();
1332                        });
1333
1334                        self.initSlick($this.find('.slick-carousel'));
1335                        
1336                    }).progress( function( instance, image ) {
1337                        $this.addClass('images-loading');
1338                    }).done( function( instance ) {
1339                        $this.addClass('images-loaded').removeClass('images-loading');
1340                    });
1341
1342                    $(this).addClass('loaded-gallery');
1343                }
1344            });
1345        }
1346    });
1347
1348    $.apusThemeExtensions.property = $.apusThemeCore.property_init;
1349
1350    
1351})(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.