File manager - Edit - /home/gzbnyc5/pty-app/realstate/public/js/pty.front.angjs-listing.js
Back
angularApp.directive('onErrorSrc', function() { return { link: function(scope, element, attrs) { element.bind('error', function() { if (attrs.src != attrs.onErrorSrc) { attrs.$set('src', attrs.onErrorSrc); element.addClass('pty-no-pic') } }); element.bind('load', function() { }); } } }); angularApp.filter('bedNumber', function() { return function(x) { if( x == null ) return 0; var z = x.toString(); if( z.indexOf('.') < 0 ) return x; var parts = z.split('.'); if(parseInt(parts[1]) == 0) { return parts[0]; } else { return x; } }; }); angularApp.controller('listingController', ['$rootScope', '$scope', '$http', '$compile', '$q', function($rootScope, $scope, $http, $compile, $q) { var ctrl = this; /***************************************************************************** * * Search, Pagination and Property Lists * *****************************************************************************/ ctrl.propertyPag = { length: 0, numPerPage: 26, currentPage: 1, maxSize: 5, filters: { keywords: window.params.keywords || '', type: window.listingType || '', location: window.params.location || '', minBed: window.params.minBeds || '', minBath: window.params.minBaths || '', minPrice: window.params.minPrice || '', maxPrice: window.params.maxPrice || '', pets: '', fee: '', bAmens: window.params.bAmens || '', iAmens: window.params.iAmens || '', } }; ctrl.listingType = window.listingType; ctrl.trans = GLOBAL_TRANSLATION; ctrl.noDataFound = true; ctrl.propertyList = []; ctrl.currency = window.currency; ctrl.canceler = null; ctrl.loadListingItems = function() { ctrl.clearMarker(); if( ctrl.canceler != null ) { ctrl.canceler.resolve(); } ctrl.canceler = $q.defer(); $http({ method: 'POST', url: BASEURL + '/listings', data: { currentPage: ctrl.propertyPag.currentPage, numPerPage: ctrl.propertyPag.numPerPage, filters: ctrl.propertyPag.filters }, timeout: ctrl.canceler.promise }) .then(function(result) { if (result.status != 200) { console.log('Unknown error. Please contact your administrator', data); } else { ctrl.propertyPag.length = result.data.length; ctrl.propertyList = result.data.records; ctrl.noDataFound = result.data.length == 0 ? true : false; ctrl.showMarkers(); } if(!$scope.$$phase) { $scope.$apply(); } },function(error) { console.log('error',error); }); } $scope.pageChanged = function() { $(window).scrollTop(0); ctrl.loadListingItems(); } ctrl.doSearch = function() { ctrl.propertyPag.filters.bAmens = $('input[type="checkbox"].build-amens:checked').map(function(){ return $(this).val(); }).get().join(','); ctrl.propertyPag.filters.iAmens = $('input[type="checkbox"].apart-amens:checked').map(function(){ return $(this).val(); }).get().join(','); ctrl.loadListingItems(); } ctrl.clearMarker = function() { console.log('Clearing markers'); // Remove previous markers if ( ctrl.googleMap.map == null ) return; if( ctrl.googleMap.cluster != null ) { ctrl.googleMap.cluster.clearMarkers(); } if( ctrl.googleMap.markers != null ) { ctrl.googleMap.markers.forEach(function(el, idx) { el.setMap(null); }); } ctrl.googleMap.markers = []; // google.maps.event.trigger(ctrl.googleMap.map,'resize'); } ctrl.googleMap = { map: null, markers: null, infoWindow: null, cluster: null, }; ctrl.showMarkers = function() { console.log('Rendering markers'); // ctrl.clearMarker(); // Create new markers // Loop through our array of markers & place each one on the map var bounds = new google.maps.LatLngBounds(); ctrl.googleMap.markers = []; ctrl.propertyList.forEach(function(property, idx) { var geoLocation = { lat: parseFloat(property.latitude), lng: parseFloat(property.longitude) } var position = new google.maps.LatLng(geoLocation); bounds.extend(position); var marker = new google.maps.Marker({ position: position, map: ctrl.googleMap.map, title: property.city, icon : BASEURL + '/assets/front/images/map_marker.png' }); // Allow each marker to have an info window google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { ctrl.scrollToProperty(property.id); var propertyContent = angular.element('<div class="property-listing-map-info-window">' + '<div class="image-with-label">' + '<img ng-src="'+BASEURL + '/images/properties/' + property.first_image +'" on-error-src="'+BASEURL + '/images/properties/nopic.png' +'" alt="" class="img-responsive" style="width: auto; height: 150px; margin-left: auto; margin-right: auto;">' + '</div>' + '<div class="featured-properties-detail" style="white-space: normal"> ' + '<a href="'+BASEURL + '/property/' + property.alias +'" target="_blank"><h4>'+property.city+'</h4></a> ' + '<p class="featured-properties-address " ng-class="{\'hidden\' : ctrl.propertyPag.filters.type != \'E\' }">'+property.street+'</p> ' + '<h6>'+ctrl.trans['bedrooms']+':{{ '+property.beds+' | bedNumber }} '+ctrl.trans['bathrooms']+':{{ '+property.baths+' | bedNumber}} '+ctrl.trans['price']+':'+ctrl.currency+'{{ '+property.price+' | number:2 }}</h6>' + '</div>'); $compile(propertyContent)($scope); ctrl.googleMap.infoWindow.setContent(propertyContent[0]); ctrl.googleMap.infoWindow.open(ctrl.googleMap.map, marker); } })(marker, idx)); ctrl.googleMap.markers.push(marker); // Automatically center the map fitting all markers on the screen }); // Add a marker clusterer to manage the markers. // ctrl.googleMap.cluster = new MarkerClusterer(ctrl.googleMap.map, ctrl.googleMap.markers, // {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m', maxZoom: 15,gridSize: 150}); // ctrl.googleMap.map.fitBounds(bounds); if(ctrl.propertyList.length > 1) ctrl.googleMap.map.fitBounds(bounds); else if(ctrl.propertyList.length == 1) ctrl.googleMap.map.setCenter({ lat: parseFloat(ctrl.propertyList[0].latitude), lng: parseFloat(ctrl.propertyList[0].longitude) }); // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) var boundsListener = google.maps.event.addListener((ctrl.googleMap.map), 'bounds_changed', function(event) { google.maps.event.removeListener(boundsListener); }); } ctrl.scrollToProperty = function(propertyId) { document.getElementById('listing-item-' + propertyId).scrollIntoView(); window.scrollBy(0, -100); } $(document).ready(function(){ var location = ctrl.propertyPag.filters.location.length > 0 ? ctrl.propertyPag.filters.location.split(',') : null; if(location != null) $('#pty-location').val(location); var select2 = $('.callus select[placeholder]').not('#pty-location').each(function() { var placeHolder = $(this).attr('placeholder'); var allowClear = $(this).data('allow-clear') || false; $(this).select2({ placeholder: { id: '', text: placeHolder, }, allowClear: allowClear, minimumResultsForSearch: -1, width: '100%', }) }); var multiSelect = $('#pty-location').each(function() { var obj = this; $(obj).multiselect({ columns: 4, selectGroup : true, texts : { placeholder : GLOBAL_TRANSLATION.neighborhood + '(s)' }, onControlClose : function(element) { var $all = $('#pty-location').parent().find('#ms-list-1 .ms-selectall'); $all.hide(); setTimeout(function() { $all.show(); }, 0); }, onOptionClick: function(element, option) { ctrl.propertyPag.filters.location = $(obj).val() == null ? '' : $(obj).val().join(','); ctrl.loadListingItems(); }, onLoad : function(element) { var $opts = $(element).next().find('.ms-options'); var html = '<div class="btn-group btn-group-justified pty-neighborhood-tab-container" data-toggle="buttons">' + window.nTabStr + '</div>'; $opts.prepend(html); $opts.find('.optgroup > span').remove(); $opts.find('.optgroup').not(':eq(0)').hide(); }, onSelectAll : function(element, selected) { ctrl.propertyPag.filters.location = $(obj).val() == null ? '' : $(obj).val().join(','); ctrl.loadListingItems(); } }); }) $(document).on('click', '.pty-neighborhood-tab', function(e) { e.preventDefault(); e.stopPropagation(); var index = $('.pty-neighborhood-tab').removeClass('active').index(this); var $optGroups = $('#pty-location').parent().find('#ms-list-1').find('.optgroup').hide(); $optGroups.eq(index).show(); $(this).addClass('active'); }); $(document).on('click', '.listing_full .image', function(e) { window.open($(this).parent().find('a:eq(0)').attr('href'),'_blank'); }); $.when(select2).done(function() { $('.callus .input-group > .select2-container:eq(0)').addClass('first'); $('.callus .input-group > .select2-container:eq(1)').addClass('last'); }); $('#pty-keywords').keyup(function() { ctrl.propertyPag.filters.keywords = this.value; }); $('#pty-location').change(function() { ctrl.propertyPag.filters.location = $(this).val() == null ? '' : $(this).val().join(','); }); $('#pty-bed').change(function() { ctrl.propertyPag.filters.minBed = this.value; }); $('#pty-bath').change(function() { ctrl.propertyPag.filters.minBath = this.value; }); $('#pty-fee').change(function() { ctrl.propertyPag.filters.fee = this.value; }); $('#pty-price-min').change(function() { ctrl.propertyPag.filters.minPrice = this.value; }); $('#pty-price-max').change(function() { ctrl.propertyPag.filters.maxPrice = this.value; }); // Property listing map page load map function property_listing_map_initialize() { var defLoc = {lat: parseFloat(window.defLocation[0]), lng: parseFloat(window.defLocation[1])}; var mapOptions = { zoom: 14, center: defLoc, mapTypeId: 'roadmap', scrollwheel: false, styles: [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]}] }; // Display a map on the page ctrl.googleMap.map = new google.maps.Map(document.getElementById("property-listing-map"), mapOptions); ctrl.googleMap.map.setTilt(45); // Display multiple markers on a map ctrl.googleMap.infoWindow = new google.maps.InfoWindow({Width: 365,Height: 400}); ctrl.loadListingItems(); } if(document.getElementById('property-listing-map') != null ){ google.maps.event.addDomListener(window, 'load', property_listing_map_initialize); } }); }]);
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings