diff --git a/assets/js/frontend/googlemaps.js b/assets/js/frontend/googlemaps.js index b370e511..119f4e3e 100755 --- a/assets/js/frontend/googlemaps.js +++ b/assets/js/frontend/googlemaps.js @@ -1,188 +1,188 @@ -;(function ($, settings) { - "use strict"; +;( function ( $, settings ) { + 'use strict'; - if (window.Opalestate === undefined) { + if ( window.Opalestate === undefined ) { window.Opalestate = {}; } /** * GooglemapSearch */ - var GooglemapSingle = Opalestate.GooglemapSingle = function ( data , id ) { + var GooglemapSingle = Opalestate.GooglemapSingle = function ( data, id ) { - /** - * Create Google Map In Single Property Only - */ - var initializePropertyMap = function ( data , id ){ + /** + * Create Google Map In Single Property Only + */ + var initializePropertyMap = function ( data, id ) { - var propertyMarkerInfo = data; - var enable = true ; - var url = propertyMarkerInfo.icon; - var size = new google.maps.Size( 42, 57 ); + var propertyMarkerInfo = data; + var enable = true; + var url = propertyMarkerInfo.icon; + var size = new google.maps.Size( 42, 57 ); + var allMarkers = []; - var allMarkers = []; - - var setMapOnAll = function (markers, map) { - for (var i = 0; i < markers.length; i++) { - markers[i].setMap( map ); - } + var setMapOnAll = function ( markers, map ) { + for ( var i = 0; i < markers.length; i++ ) { + markers[ i ].setMap( map ); } - // retina - if( window.devicePixelRatio > 1.5 ) { - if ( propertyMarkerInfo.retinaIcon ) { - url = propertyMarkerInfo.retinaIcon; - size = new google.maps.Size( 83, 113 ); - } - } - - var propertyLocation = new google.maps.LatLng( propertyMarkerInfo.latitude, propertyMarkerInfo.longitude ); - var propertyMapOptions = { - center: propertyLocation, - zoom: 15, - mapTypeId: google.maps.MapTypeId.ROADMAP, - scrollwheel: false - }; - var propertyMap = new google.maps.Map( document.getElementById( id ), propertyMapOptions ); - - /** - * - */ - - var createMarker = function ( position, icon ) { - - var image = { - url: icon, - size: size, - scaledSize: new google.maps.Size( 32, 57 ), - origin: new google.maps.Point( 0, 0 ), - anchor: new google.maps.Point( 21, 56 ) - }; - - var _marker = new google.maps.Marker({ - map: propertyMap, - position: position, - icon: image - }); - return _marker; - } - - - var infowindow = new google.maps.InfoWindow(); - - createMarker( propertyLocation, url ); - - /** - * Places near with actived types - */ - if( enable ){ - var $navs = $("#"+id).parent().find( '.property-search-places' ); - $(' .btn-map-search', $navs ).unbind('click').bind( 'click', function(){ - var service = new google.maps.places.PlacesService( propertyMap ) ; - var type = $(this).data('type'); - var $this = $(this).parent(); - - var icon = { - url: opalesateJS.mapiconurl+$(this).data('icon'), - scaledSize: new google.maps.Size( 28, 28 ), - anchor: new google.maps.Point( 21, 16 ), - origin: new google.maps.Point( 0, 0 ) - }; - - if( !allMarkers[type] || allMarkers[type].length <= 0 ){ - var markers = [] ; - var bounds = propertyMap.getBounds(); - - var $this = $(this); - - service.nearbySearch({ - location: propertyLocation, - radius: 2000, - bounds: bounds, - type: type - }, callbackNearBy); - - function callbackNearBy(results, status) { - if (status === google.maps.places.PlacesServiceStatus.OK) { - for (var i = 0; i < results.length; i++) { - createMarkerNearBy(results[i]); - } - - $('.nearby-counter',$this).remove(); - $('span',$this).append( $(''+markers.length+'') ); - allMarkers[type] = markers; - } - } - - function abc(){ - if (status === google.maps.places.PlacesServiceStatus.OK) { - for (var i = 0; i < results.length; i++) { - var place = results[i]; - var marker = new google.maps.Marker({ - map: propertyMap, - position: place.geometry.location, - icon: icon, - visible: true - }); - - marker.setMap( propertyMap ); - - google.maps.event.addListener(marker, 'click', function() { - - infowindow.setContent( place.name ); - - infowindow.open(propertyMap, this); - }); - - markers.push( marker ); - } - $('.nearby-counter',$this).remove(); - $('span',$this).append( $(''+markers.length+'') ); - allMarkers[type] = markers; - //console.log( place ); - } - } - - function createMarkerNearBy(place) { - var placeLoc = place.geometry.location; - var marker = new google.maps.Marker({ - map: propertyMap, - position: place.geometry.location, - icon: icon, - visible: true - }); - - marker.setMap( propertyMap ); - - google.maps.event.addListener(marker, 'click', function() { - infowindow.setContent(place.name); - infowindow.open(propertyMap, this); - }); - - markers.push( marker ); - } - }else { - for( var i=0 ; i < allMarkers[type].length; i++ ){ - allMarkers[type][i].setMap( null ); - } - allMarkers[type] = []; - } - - $(this).toggleClass('active'); - } ); + }; + // retina + if ( window.devicePixelRatio > 1.5 ) { + if ( propertyMarkerInfo.retinaIcon ) { + url = propertyMarkerInfo.retinaIcon; + size = new google.maps.Size( 83, 113 ); } } - initializePropertyMap( data , id ); - } - var GoogleMapSearch = Opalestate.GooglemapSingle = function ( data ) { + var propertyLocation = new google.maps.LatLng( propertyMarkerInfo.latitude, propertyMarkerInfo.longitude ); + var propertyMapOptions = { + center: propertyLocation, + zoom: 15, + mapTypeId: google.maps.MapTypeId.ROADMAP, + scrollwheel: false + }; + var propertyMap = new google.maps.Map( document.getElementById( id ), propertyMapOptions ); + + /** + * + */ + + var createMarker = function ( position, icon ) { + + var image = { + url: icon, + size: size, + scaledSize: new google.maps.Size( 32, 57 ), + origin: new google.maps.Point( 0, 0 ), + anchor: new google.maps.Point( 21, 56 ) + }; + + var _marker = new google.maps.Marker( { + map: propertyMap, + position: position, + icon: image + } ); + return _marker; + }; + + var infowindow = new google.maps.InfoWindow(); + + createMarker( propertyLocation, url ); + + /** + * Places near with actived types + */ + if ( enable ) { + var $navs = $( '#' + id ).parent().find( '.property-search-places' ); + $( ' .btn-map-search', $navs ).unbind( 'click' ).bind( 'click', function () { + var service = new google.maps.places.PlacesService( propertyMap ); + var type = $( this ).data( 'type' ); + var $this = $( this ).parent(); + + var icon = { + url: opalesateJS.mapiconurl + $( this ).data( 'icon' ), + scaledSize: new google.maps.Size( 28, 28 ), + anchor: new google.maps.Point( 21, 16 ), + origin: new google.maps.Point( 0, 0 ) + }; + + if ( !allMarkers[ type ] || allMarkers[ type ].length <= 0 ) { + var markers = []; + var bounds = propertyMap.getBounds(); + + var $this = $( this ); + + service.nearbySearch( { + location: propertyLocation, + radius: 2000, + bounds: bounds, + type: type + }, callbackNearBy ); + + function callbackNearBy( results, status ) { + if ( status === google.maps.places.PlacesServiceStatus.OK ) { + for ( var i = 0; i < results.length; i++ ) { + createMarkerNearBy( results[ i ] ); + } + + $( '.nearby-counter', $this ).remove(); + $( 'span', $this ) + .append( $( '' + markers.length + '' ) ); + allMarkers[ type ] = markers; + } + } + + function abc() { + if ( status === google.maps.places.PlacesServiceStatus.OK ) { + for ( var i = 0; i < results.length; i++ ) { + var place = results[ i ]; + var marker = new google.maps.Marker( { + map: propertyMap, + position: place.geometry.location, + icon: icon, + visible: true + } ); + + marker.setMap( propertyMap ); + + google.maps.event.addListener( marker, 'click', function () { + + infowindow.setContent( place.name ); + + infowindow.open( propertyMap, this ); + } ); + + markers.push( marker ); + } + $( '.nearby-counter', $this ).remove(); + $( 'span', $this ) + .append( $( '' + markers.length + '' ) ); + allMarkers[ type ] = markers; + //console.log( place ); + } + } + + function createMarkerNearBy( place ) { + var placeLoc = place.geometry.location; + var marker = new google.maps.Marker( { + map: propertyMap, + position: place.geometry.location, + icon: icon, + visible: true + } ); + + marker.setMap( propertyMap ); + + google.maps.event.addListener( marker, 'click', function () { + infowindow.setContent( place.name ); + infowindow.open( propertyMap, this ); + } ); + + markers.push( marker ); + } + } else { + for ( var i = 0; i < allMarkers[ type ].length; i++ ) { + allMarkers[ type ][ i ].setMap( null ); + } + allMarkers[ type ] = []; + } + + $( this ).toggleClass( 'active' ); + } ); + } + }; + initializePropertyMap( data, id ); + }; + + var GoogleMapSearch = Opalestate.GooglemapSingle = function ( data ) { var initializePropertiesMap = function ( properties ) { // Properties Array var mapOptions = { zoom: 12, maxZoom: 16, scrollwheel: false, - mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeId: google.maps.MapTypeId.ROADMAP, panControl: false, zoomControl: true, mapTypeControl: false, @@ -198,21 +198,49 @@ } }; - var map = new google.maps.Map( document.getElementById( "opalestate-map-preview" ), mapOptions ); + if ( ( typeof opalestateGmap !== 'undefined' ) ) { + switch ( opalestateGmap.style ) { + case 'standard': + mapOptions.styles = GoogleMapStyles.standard; + break; + case 'silver': + mapOptions.styles = GoogleMapStyles.silver; + break; + case 'retro': + mapOptions.styles = GoogleMapStyles.retro; + break; + case 'dark': + mapOptions.styles = GoogleMapStyles.dark; + break; + case 'night': + mapOptions.styles = GoogleMapStyles.night; + break; + case 'aubergine': + mapOptions.styles = GoogleMapStyles.aubergine; + break; + case 'custom': + if ( opalestateGmap.custom_style != '' ) { + mapOptions.styles = $.parseJSON( opalestateGmap.custom_style ); + } + break; + } + } + + var map = new google.maps.Map( document.getElementById( 'opalestate-map-preview' ), mapOptions ); var bounds = new google.maps.LatLngBounds(); // Loop to generate marker and infowindow based on properties array var markers = new Array(); - for ( var i=0; i < properties.length; i++ ) { + for ( var i = 0; i < properties.length; i++ ) { // console.log( properties[i] ); - var url = properties[i].icon; + var url = properties[ i ].icon; var size = new google.maps.Size( 42, 57 ); - if( window.devicePixelRatio > 1.5 ) { - if ( properties[i].retinaIcon ) { - url = properties[i].retinaIcon; + if ( window.devicePixelRatio > 1.5 ) { + if ( properties[ i ].retinaIcon ) { + url = properties[ i ].retinaIcon; size = new google.maps.Size( 83, 113 ); } } @@ -225,25 +253,26 @@ anchor: new google.maps.Point( 21, 56 ) }; - markers[i] = new google.maps.Marker({ - position: new google.maps.LatLng( properties[i].lat, properties[i].lng ), + markers[ i ] = new google.maps.Marker( { + position: new google.maps.LatLng( properties[ i ].lat, properties[ i ].lng ), map: map, icon: image, - title: properties[i].title, + title: properties[ i ].title, animation: google.maps.Animation.DROP, visible: true - }); + } ); - bounds.extend( markers[i].getPosition() ); + bounds.extend( markers[ i ].getPosition() ); - var boxText = document.createElement( "div" ); + var boxText = document.createElement( 'div' ); var pricelabel = ''; - if( properties[i].pricelabel ){ - pricelabel = ' / ' + properties[i].pricelabel; + if ( properties[ i ].pricelabel ) { + pricelabel = ' / ' + properties[ i ].pricelabel; } boxText.className = 'map-info-preview media'; + function opalestate_get_property_icon( $key ) { var $icon = $key; switch ( $key ) { @@ -286,22 +315,26 @@ } var meta = ''; + meta += ''; - boxText.innerHTML = '
' + - '' + properties[i].title + '' + - ''+ properties[i].status +'
' + - '
' + - '
' + properties[i].title + - '

' + properties[i].address + '

' + properties[i].pricehtml + pricelabel + - '

'+meta+'
'+'
'; + boxText.innerHTML = '
' + + '' + properties[ i ].title +
+                    '' + + '' + properties[ i ].status + '
' + + '
' + + '
' + + properties[ i ].title + + '

' + properties[ i ].address + + '

' + properties[ i ].pricehtml + pricelabel + + '

' + meta + '
' + '
'; var myOptions = { content: boxText, @@ -310,101 +343,1061 @@ alignBottom: true, pixelOffset: new google.maps.Size( -122, -48 ), zIndex: null, - closeBoxMargin: "0 0 -16px -16px", - closeBoxURL: opalesateJS.mapiconurl+"close.png", + closeBoxMargin: '0 0 -16px -16px', + closeBoxURL: opalesateJS.mapiconurl + 'close.png', infoBoxClearance: new google.maps.Size( 1, 1 ), isHidden: false, - pane: "floatPane", + pane: 'floatPane', enableEventPropagation: false }; var ib = new InfoBox( myOptions ); - attachInfoBoxToMarker( map, markers[i], ib, i ); + attachInfoBoxToMarker( map, markers[ i ], ib, i ); } - var last = null ; + var last = null; - $('body').delegate( '[data-related="map"]', 'mouseenter', function(){ - if( $(this).hasClass('map-active') ){ + $( 'body' ).delegate( '[data-related="map"]', 'mouseenter', function () { + if ( $( this ).hasClass( 'map-active' ) ) { return true; } - var i = $(this).data( 'id' ); + var i = $( this ).data( 'id' ); $( '[data-related="map"]' ).removeClass( 'map-active' ); - $(this).addClass( 'active' ); + $( this ).addClass( 'active' ); map.setZoom( 65536 );// alert( scale ); - if( markers[i] ){ - var marker = markers[i]; - google.maps.event.trigger( markers[i], 'click' ); + if ( markers[ i ] ) { + var marker = markers[ i ]; + google.maps.event.trigger( markers[ i ], 'click' ); var scale = Math.pow( 2, map.getZoom() ); - var offsety = ( (100/scale) || 0 ); + var offsety = ( ( 100 / scale ) || 0 ); var projection = map.getProjection(); var markerPosition = marker.getPosition(); var markerScreenPosition = projection.fromLatLngToPoint( markerPosition ); - var pointHalfScreenAbove = new google.maps.Point( markerScreenPosition.x, markerScreenPosition.y - offsety ); + var pointHalfScreenAbove = new google.maps.Point( markerScreenPosition.x, + markerScreenPosition.y - offsety ); var aboveMarkerLatLng = projection.fromPointToLatLng( pointHalfScreenAbove ); map.setZoom( scale ); map.setCenter( aboveMarkerLatLng ); } return false; - }); + } ); - map.fitBounds(bounds); + map.fitBounds( bounds ); /* Marker Clusters */ var markerClustererOptions = { ignoreHidden: true, maxZoom: 14, - styles: [{ - textColor: '#000000', - url: opalesateJS.mapiconurl+"cluster-icon.png", - height: 51, - width: 30 - }] + styles: [ + { + textColor: '#000000', + url: opalesateJS.mapiconurl + 'cluster-icon.png', + height: 51, + width: 30 + } ] }; var markerClusterer = new MarkerClusterer( map, markers, markerClustererOptions ); + function attachInfoBoxToMarker( map, marker, infoBox, i ) { + google.maps.event.addListener( marker, 'click', function () { - function attachInfoBoxToMarker( map, marker, infoBox , i ){ - - google.maps.event.addListener( marker, 'click', function(){ - - if( $( '[data-related="map"]' ).filter('[data-id="'+i+'"]').length > 0 ){ - var $m = $( '[data-related="map"]' ).filter('[data-id="'+i+'"]'); + if ( $( '[data-related="map"]' ).filter( '[data-id="' + i + '"]' ).length > 0 ) { + var $m = $( '[data-related="map"]' ).filter( '[data-id="' + i + '"]' ); $( '[data-related="map"]' ).removeClass( 'map-active' ); - $m.addClass('map-active'); + $m.addClass( 'map-active' ); } - if( last != null ){ + if ( last != null ) { last.close(); } var scale = Math.pow( 2, map.getZoom() ); - var offsety = ( (100/scale) || 0 ); + var offsety = ( ( 100 / scale ) || 0 ); var projection = map.getProjection(); var markerPosition = marker.getPosition(); var markerScreenPosition = projection.fromLatLngToPoint( markerPosition ); - var pointHalfScreenAbove = new google.maps.Point( markerScreenPosition.x, markerScreenPosition.y - offsety ); + var pointHalfScreenAbove = new google.maps.Point( markerScreenPosition.x, + markerScreenPosition.y - offsety ); var aboveMarkerLatLng = projection.fromPointToLatLng( pointHalfScreenAbove ); map.setCenter( aboveMarkerLatLng ); infoBox.open( map, marker ); last = infoBox; - }); + } ); } - } + }; initializePropertiesMap( data ); - } + }; + + var GoogleMapStyles = { + standard: [], + silver: [ + { + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#f5f5f5' + } + ] + }, + { + 'elementType': 'labels.icon', + 'stylers': [ + { + 'visibility': 'off' + } + ] + }, + { + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#616161' + } + ] + }, + { + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#f5f5f5' + } + ] + }, + { + 'featureType': 'administrative.land_parcel', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#bdbdbd' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#eeeeee' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#e5e5e5' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#9e9e9e' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#ffffff' + } + ] + }, + { + 'featureType': 'road.arterial', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#dadada' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#616161' + } + ] + }, + { + 'featureType': 'road.local', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#9e9e9e' + } + ] + }, + { + 'featureType': 'transit.line', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#e5e5e5' + } + ] + }, + { + 'featureType': 'transit.station', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#eeeeee' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#c9c9c9' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#9e9e9e' + } + ] + } + ], + retro: [ + { + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#ebe3cd' + } + ] + }, + { + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#523735' + } + ] + }, + { + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#f5f1e6' + } + ] + }, + { + 'featureType': 'administrative', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#c9b2a6' + } + ] + }, + { + 'featureType': 'administrative.land_parcel', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#dcd2be' + } + ] + }, + { + 'featureType': 'administrative.land_parcel', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#ae9e90' + } + ] + }, + { + 'featureType': 'landscape.natural', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#dfd2ae' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#dfd2ae' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#93817c' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'geometry.fill', + 'stylers': [ + { + 'color': '#a5b076' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#447530' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#f5f1e6' + } + ] + }, + { + 'featureType': 'road.arterial', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#fdfcf8' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#f8c967' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#e9bc62' + } + ] + }, + { + 'featureType': 'road.highway.controlled_access', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#e98d58' + } + ] + }, + { + 'featureType': 'road.highway.controlled_access', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#db8555' + } + ] + }, + { + 'featureType': 'road.local', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#806b63' + } + ] + }, + { + 'featureType': 'transit.line', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#dfd2ae' + } + ] + }, + { + 'featureType': 'transit.line', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#8f7d77' + } + ] + }, + { + 'featureType': 'transit.line', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#ebe3cd' + } + ] + }, + { + 'featureType': 'transit.station', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#dfd2ae' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'geometry.fill', + 'stylers': [ + { + 'color': '#b9d3c2' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#92998d' + } + ] + } + ], + dark: [ + { + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#212121' + } + ] + }, + { + 'elementType': 'labels.icon', + 'stylers': [ + { + 'visibility': 'off' + } + ] + }, + { + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#212121' + } + ] + }, + { + 'featureType': 'administrative', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'featureType': 'administrative.country', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#9e9e9e' + } + ] + }, + { + 'featureType': 'administrative.land_parcel', + 'stylers': [ + { + 'visibility': 'off' + } + ] + }, + { + 'featureType': 'administrative.locality', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#bdbdbd' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#181818' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#616161' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#1b1b1b' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry.fill', + 'stylers': [ + { + 'color': '#2c2c2c' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#8a8a8a' + } + ] + }, + { + 'featureType': 'road.arterial', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#373737' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#3c3c3c' + } + ] + }, + { + 'featureType': 'road.highway.controlled_access', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#4e4e4e' + } + ] + }, + { + 'featureType': 'road.local', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#616161' + } + ] + }, + { + 'featureType': 'transit', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#757575' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#000000' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#3d3d3d' + } + ] + } + ], + night: [ + { + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#242f3e' + } + ] + }, + { + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#746855' + } + ] + }, + { + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#242f3e' + } + ] + }, + { + 'featureType': 'administrative.locality', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#d59563' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#d59563' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#263c3f' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#6b9a76' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#38414e' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#212a37' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#9ca5b3' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#746855' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#1f2835' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#f3d19c' + } + ] + }, + { + 'featureType': 'transit', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#2f3948' + } + ] + }, + { + 'featureType': 'transit.station', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#d59563' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#17263c' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#515c6d' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#17263c' + } + ] + } + ], + aubergine: [ + { + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#1d2c4d' + } + ] + }, + { + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#8ec3b9' + } + ] + }, + { + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#1a3646' + } + ] + }, + { + 'featureType': 'administrative.country', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#4b6878' + } + ] + }, + { + 'featureType': 'administrative.land_parcel', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#64779e' + } + ] + }, + { + 'featureType': 'administrative.province', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#4b6878' + } + ] + }, + { + 'featureType': 'landscape.man_made', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#334e87' + } + ] + }, + { + 'featureType': 'landscape.natural', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#023e58' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#283d6a' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#6f9ba5' + } + ] + }, + { + 'featureType': 'poi', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#1d2c4d' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'geometry.fill', + 'stylers': [ + { + 'color': '#023e58' + } + ] + }, + { + 'featureType': 'poi.park', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#3C7680' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#304a7d' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#98a5be' + } + ] + }, + { + 'featureType': 'road', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#1d2c4d' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#2c6675' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'geometry.stroke', + 'stylers': [ + { + 'color': '#255763' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#b0d5ce' + } + ] + }, + { + 'featureType': 'road.highway', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#023e58' + } + ] + }, + { + 'featureType': 'transit', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#98a5be' + } + ] + }, + { + 'featureType': 'transit', + 'elementType': 'labels.text.stroke', + 'stylers': [ + { + 'color': '#1d2c4d' + } + ] + }, + { + 'featureType': 'transit.line', + 'elementType': 'geometry.fill', + 'stylers': [ + { + 'color': '#283d6a' + } + ] + }, + { + 'featureType': 'transit.station', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#3a4762' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'geometry', + 'stylers': [ + { + 'color': '#0e1626' + } + ] + }, + { + 'featureType': 'water', + 'elementType': 'labels.text.fill', + 'stylers': [ + { + 'color': '#4e6d70' + } + ] + } + ] + }; ///// - $(document).ready(function () { + $( document ).ready( function () { - function initialize_property_street_view( data , id ){ + function initialize_property_street_view( data, id ) { var propertyMarkerInfo = data; @@ -420,110 +1413,114 @@ pitch: 10 } }; - var panorama = new google.maps.StreetViewPanorama( document.getElementById( id ), panoramaOptions); - google.maps.event.trigger(panorama, 'resize'); + var panorama = new google.maps.StreetViewPanorama( document.getElementById( id ), panoramaOptions ); + google.maps.event.trigger( panorama, 'resize' ); } - $( ".property-preview-map").each( function(){ - new GooglemapSingle( $(this).data() , $(this).attr('id') ); + $( '.property-preview-map' ).each( function () { + new GooglemapSingle( $( this ).data(), $( this ).attr( 'id' ) ); } ); - $( ".tab-google-street-view-btn") .click( function(){ - $( ".property-preview-street-map").hide(); - $( ".property-preview-street-map").each( function(){ + $( '.tab-google-street-view-btn' ).click( function () { + $( '.property-preview-street-map' ).hide(); + $( '.property-preview-street-map' ).each( function () { - var d = $(this).data() ; - var i = $(this).attr('id') ; + var d = $( this ).data(); + var i = $( this ).attr( 'id' ); - initialize_property_street_view( d , i ); + initialize_property_street_view( d, i ); } ); - $( ".property-preview-street-map").show( 100 ); + $( '.property-preview-street-map' ).show( 100 ); } ); /// // auto set height for split google map - $( '.split-maps-container' ).each( function() { - $( "#opalestate-map-preview ").height( $(window).height() ); + $( '.split-maps-container' ).each( function () { + $( '#opalestate-map-preview ' ).height( $( window ).height() ); } ); - }) + } ); - - $(document).ready(function () { + $( document ).ready( function () { // search - // show google maps + // show google maps // update google maps - var updatePreviewGoogleMap = function( url ) { - if( $('#opalestate-map-preview').length > 0 ) { - $.ajax({ + var updatePreviewGoogleMap = function ( url ) { + if ( $( '#opalestate-map-preview' ).length > 0 ) { + $.ajax( { type: 'GET', dataType: 'json', url: opalesateJS.ajaxurl, - data: url, - success: function(data) { - new GoogleMapSearch( data ); + data: url, + success: function ( data ) { + new GoogleMapSearch( data ); } - }); - } + } ); + } }; - if( $('#opalestate-map-preview').length > 0 || $( '.opalesate-properties-results').length > 0 ) { - var currentLocation = location.search.substr(1)+"&action=opalestate_ajx_get_properties&paged="+$('#opalestate-map-preview').data('page'); + if ( $( '#opalestate-map-preview' ).length > 0 || $( '.opalesate-properties-results' ).length > 0 ) { + var currentLocation = location.search.substr( 1 ) + '&action=opalestate_ajx_get_properties&paged=' + + $( '#opalestate-map-preview' ).data( 'page' ); updatePreviewGoogleMap( currentLocation ); } + // update results - function updatePropertiesResults( data ){ - $( '.opalesate-properties-results').append( $('
') ); - $.ajax({ - type: "GET", + function updatePropertiesResults( data ) { + $( '.opalesate-properties-results' ).append( $( '
' ) ); + $.ajax( { + type: 'GET', url: opalesateJS.ajaxurl, - data: data+"&action=opalestate_render_get_properties" , - success: function( response ) { - if( response ){ + data: data + '&action=opalestate_render_get_properties', + success: function ( response ) { + if ( response ) { $( '.opalesate-properties-results' ).html( response ); } - $( '.opalesate-properties-results .opalestate-loading').remove(); - $('.opalestate-sortable select').select2( { + $( '.opalesate-properties-results .opalestate-loading' ).remove(); + $( '.opalestate-sortable select' ).select2( { width: '100%', minimumResultsForSearch: -1 } ); } - }); + } ); } - function updatePropertiesByParseringHtml( newurl ){ - $( '.opalesate-properties-results .opalesate-archive-bottom').append( $('
') ); - $.ajax({ - type: "GET", - url: newurl, - dataType : 'html', - cache: false, - success: function( data ) { - if( data ){ - $( '.opalesate-properties-results' ).html( $(data).find('.opalesate-properties-results').html() ); - $('.opalestate-sortable select').select2( { - width: '100%', - minimumResultsForSearch: -1 - } ); - } - // $( '.opalesate-properties-results .opalestate-loading').remove(); + function updatePropertiesByParseringHtml( newurl ) { + $( '.opalesate-properties-results .opalesate-archive-bottom' ) + .append( $( '
' ) ); + $.ajax( { + type: 'GET', + url: newurl, + dataType: 'html', + cache: false, + success: function ( data ) { + if ( data ) { + $( '.opalesate-properties-results' ) + .html( $( data ).find( '.opalesate-properties-results' ).html() ); + $( '.opalestate-sortable select' ).select2( { + width: '100%', + minimumResultsForSearch: -1 + } ); } - }); + // $( '.opalesate-properties-results .opalestate-loading').remove(); + } + } ); } - - $('form.opalestate-search-form').submit( function ( ){ - if( $('#opalestate-map-preview').length > 0 ) { - if( $(".opalesate-properties-results") && $(".opalesate-properties-results").data('mode') == 'html' ) { - var $form = $(this); - if (history.pushState) { + $( 'form.opalestate-search-form' ).submit( function () { + if ( $( '#opalestate-map-preview' ).length > 0 ) { + if ( $( '.opalesate-properties-results' ) && $( '.opalesate-properties-results' ).data( 'mode' ) == + 'html' ) { + var $form = $( this ); + if ( history.pushState ) { var ps = $form.serialize(); - var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?'+ ps; - window.history.pushState({path:newurl},'',newurl); + var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + + '?' + ps; + window.history.pushState( { path: newurl }, '', newurl ); updatePropertiesByParseringHtml( newurl ); } } else { - updatePropertiesResults( $(this).serialize() ); + updatePropertiesResults( $( this ).serialize() ); } return false; @@ -531,14 +1528,14 @@ return true; } ); - - $( '.ajax-search-form form.opalestate-search-form' ).each( function(){ - var $form = $(this); - $( '.ajax-change select', this ).change( function(){ - if (history.pushState) { + $( '.ajax-search-form form.opalestate-search-form' ).each( function () { + var $form = $( this ); + $( '.ajax-change select', this ).change( function () { + if ( history.pushState ) { var ps = $form.serialize(); - var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?'+ ps; - window.history.pushState({path:newurl},'',newurl); + var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + + '?' + ps; + window.history.pushState( { path: newurl }, '', newurl ); } $form.submit(); return false; @@ -546,116 +1543,113 @@ } ); // // Sortable Change // // - $("body").delegate( '#opalestate-sortable-form select', 'change', function(){ + $( 'body' ).delegate( '#opalestate-sortable-form select', 'change', function () { var ps = ''; - if( $('form.opalestate-search-form').length > 0 ) { - var $form =$('form.opalestate-search-form'); - var ps = $form.serialize()+"&opalsortable="+$(this).val()+"&display="+$(".display-mode a.active").data('mode'); + if ( $( 'form.opalestate-search-form' ).length > 0 ) { + var $form = $( 'form.opalestate-search-form' ); + var ps = $form.serialize() + '&opalsortable=' + $( this ).val() + '&display=' + + $( '.display-mode a.active' ).data( 'mode' ); } - if( $(".opalesate-properties-results") && ps ) { - if (history.pushState) { - var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?'+ ps; - window.history.pushState({path:newurl},'',newurl); + if ( $( '.opalesate-properties-results' ) && ps ) { + if ( history.pushState ) { + var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + + '?' + ps; + window.history.pushState( { path: newurl }, '', newurl ); updatePropertiesByParseringHtml( newurl ); } - } else { - $("#opalestate-sortable-form").submit(); + } else { + $( '#opalestate-sortable-form' ).submit(); } } ); // display mode - $( "body" ).delegate( ".display-mode a", 'click', function() { - if( $(".opalesate-properties-results").length > 0 ){ - var newurl = $(this).attr('href'); - window.history.pushState({path:newurl},'',newurl); + $( 'body' ).delegate( '.display-mode a', 'click', function () { + if ( $( '.opalesate-properties-results' ).length > 0 ) { + var newurl = $( this ).attr( 'href' ); + window.history.pushState( { path: newurl }, '', newurl ); updatePropertiesByParseringHtml( newurl ); return false; } } ); // check any estate search form is enabled ///////////////// - if( $('#opalestate-map-preview').length > 0 ) { - $( "body" ).delegate( "form.opalestate-search-form select", "change", function () { - var params = $( "form.opalestate-search-form" ).serialize(); - var url = "action=opalestate_ajx_get_properties&"+params; + if ( $( '#opalestate-map-preview' ).length > 0 ) { + $( 'body' ).delegate( 'form.opalestate-search-form select', 'change', function () { + var params = $( 'form.opalestate-search-form' ).serialize(); + var url = 'action=opalestate_ajx_get_properties&' + params; updatePreviewGoogleMap( url ); - $('form.opalestate-search-form').submit(); + $( 'form.opalestate-search-form' ).submit(); return true; } ); - $( "body" ).delegate( "form.opalestate-search-form input", "change", function () { + $( 'body' ).delegate( 'form.opalestate-search-form input', 'change', function () { - if( $(this).hasClass("ranger-geo_radius") ){ + if ( $( this ).hasClass( 'ranger-geo_radius' ) ) { return false; } - var params = $( "form.opalestate-search-form" ).serialize(); - var url = "action=opalestate_ajx_get_properties&"+params; + var params = $( 'form.opalestate-search-form' ).serialize(); + var url = 'action=opalestate_ajx_get_properties&' + params; updatePreviewGoogleMap( url ); - $('form.opalestate-search-form').submit(); + $( 'form.opalestate-search-form' ).submit(); } ); } - /////////// /////// - + /////////// /////// } ); -})(jQuery); +} )( jQuery ); //// ////// -(function( $ ) { +( function ( $ ) { 'use strict'; - - $(document).ready(function () { - $( '.opalestate-search-opal-map' ).each( function() { - initializeMapAdressSearch( $(this) ); - }); + $( document ).ready( function () { + $( '.opalestate-search-opal-map' ).each( function () { + initializeMapAdressSearch( $( this ) ); + } ); } ); - function initializeMapAdressSearch( mapInstance ) { var searchInput = mapInstance.find( '.opal-map-search' ); // Search - var autocomplete = new google.maps.places.Autocomplete( searchInput[0] ); + var autocomplete = new google.maps.places.Autocomplete( searchInput[ 0 ] ); // autocomplete.bindTo( 'bounds', map ); var latitude = mapInstance.find( '.opal-map-latitude' ); var longitude = mapInstance.find( '.opal-map-longitude' ); - google.maps.event.addListener( autocomplete, 'place_changed', function() { + google.maps.event.addListener( autocomplete, 'place_changed', function () { var place = autocomplete.getPlace(); - - if ( ! place.geometry ) { + if ( !place.geometry ) { return; } - if( place.geometry.location.lat() ){ - $(mapInstance).addClass("active"); + if ( place.geometry.location.lat() ) { + $( mapInstance ).addClass( 'active' ); } else { - $(mapInstance).removeClass("active"); + $( mapInstance ).removeClass( 'active' ); } latitude.val( place.geometry.location.lat() ); longitude.val( place.geometry.location.lng() ); - }); + } ); - $( ".map-remove", mapInstance ).click( function() { - latitude.val( "" ); - longitude.val( "" ); - searchInput.val(""); + $( '.map-remove', mapInstance ).click( function () { + latitude.val( '' ); + longitude.val( '' ); + searchInput.val( '' ); latitude.change(); } ); - $( searchInput ).keypress( function( event ) { + $( searchInput ).keypress( function ( event ) { if ( 13 === event.keyCode ) { event.preventDefault(); } - }); - + } ); } -})( jQuery ); +} )( jQuery ); diff --git a/inc/admin/settings/3rd_party.php b/inc/admin/settings/3rd_party.php index 22e77a64..cca451ad 100755 --- a/inc/admin/settings/3rd_party.php +++ b/inc/admin/settings/3rd_party.php @@ -1,4 +1,4 @@ - "Yelp", - 'walkcore' => "Walkcore" - ) ); + public function get_subtabs() { + + $tabs = [ + 'google_map' => esc_html__( 'Google Map', 'opalestate-pro' ), + 'yelp' => esc_html__( 'Yelp', 'opalestate-pro' ), + 'walkcore' => esc_html__( 'Walkcore', 'opalestate-pro' ), + ]; + + $tabs = (array) apply_filters( 'opalestate_settings_3rd_party_subtabs_nav', $tabs ); return $tabs; - } + } - public function get_subtabs_content( $key ="" ) { - // echo $key;die; - $fields = apply_filters ( 'opalestate_settings_3rd_party_subtabs_'.$key.'_fields', array() ); - - if( $key == 'yelp' ){ - $fields = $this->get_yelp_fields(); - }else if( $key == 'walkcore' ){ - $fields = $this->get_walkscore_fields(); - } + public function get_subtabs_content( $key = '' ) { + $fields = apply_filters( 'opalestate_settings_3rd_party_subtabs_' . $key . '_fields', [] ); + if ( 'google_map' == $key ) { + $fields = $this->get_google_map_fields(); + } elseif ( 'yelp' == $key ) { + $fields = $this->get_yelp_fields(); + } elseif ( 'walkcore' == $key ) { + $fields = $this->get_walkscore_fields(); + } - return [ + return [ 'id' => 'options_page', 'opalestate_title' => esc_html__( '3rd Party Settings', 'opalestate-pro' ), 'show_on' => [ 'key' => 'options-page', 'value' => [ $key ], ], - 'fields' => (array)$fields + 'fields' => (array) $fields, ]; } - public function get_walkscore_fields(){ - return array( + public function get_google_map_fields() { + return [ + [ + 'name' => esc_html__( 'API key', 'opalestate-pro' ), + 'desc' => __( 'You need to register Google API Key, then put the key in this setting.', + 'opalestate-pro' ), + 'id' => 'google_map_api_keys', + 'type' => 'text', + 'default' => 'AIzaSyCfMVNIa7khIqYHCw6VBn8ShUWWm4tjbG8', + ], + [ + 'name' => esc_html__( 'Style', 'opalestate-pro' ), + 'desc' => __( 'Select a style', 'opalestate-pro' ), + 'id' => 'google_map_style', + 'type' => 'select', + 'options' => [ + 'standard' => esc_html__( 'Standard', 'opalestate-pro' ), + 'silver' => esc_html__( 'Silver', 'opalestate-pro' ), + 'retro' => esc_html__( 'Retro', 'opalestate-pro' ), + 'dark' => esc_html__( 'Dark', 'opalestate-pro' ), + 'night' => esc_html__( 'Night', 'opalestate-pro' ), + 'aubergine' => esc_html__( 'Aubergine', 'opalestate-pro' ), + 'custom' => esc_html__( 'Custom', 'opalestate-pro' ), + ], + 'default' => 'standard', + ], + [ + 'name' => esc_html__( 'Custom Style', 'opalestate-pro' ), + 'desc' => __( 'You can visit Google Maps Platform Styling Wizard, then paste JSON into this setting.', + 'opalestate-pro' ), + 'id' => 'google_map_custom_style', + 'type' => 'textarea_code', + ], + ]; + } + + public function get_walkscore_fields() { + return [ [ 'name' => esc_html__( 'Walk Score', 'opalestate-pro' ), 'desc' => '', @@ -67,12 +102,12 @@ class Opalestate_Settings_3rd_party_Tab extends Opalestate_Settings_Base_Tab { 'desc' => esc_html__( 'Add Walk Score API key. To get your Walk Score API key, go to your Walk Score Account.', 'opalestate-pro' ), 'id' => 'walkscore_api_key', 'type' => 'text', - ] - ); + ], + ]; } - public function get_yelp_fields(){ - return array( + public function get_yelp_fields() { + return [ [ 'name' => esc_html__( 'Yelp', 'opalestate-pro' ), 'desc' => '', @@ -130,8 +165,7 @@ class Opalestate_Settings_3rd_party_Tab extends Opalestate_Settings_Base_Tab { 'kilometers' => esc_html__( 'kilometers', 'opalestate-pro' ), ], 'default' => 'miles', - ] - ); + ], + ]; } - -} \ No newline at end of file +} diff --git a/inc/admin/settings/general.php b/inc/admin/settings/general.php index 9a7b8003..155050f6 100755 --- a/inc/admin/settings/general.php +++ b/inc/admin/settings/general.php @@ -262,14 +262,6 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab { 'options' => opalestate_get_measurement_units(), 'default' => 'sqft', ], - [ - 'name' => esc_html__( 'Google Map API', 'opalestate-pro' ), - 'desc' => __( 'You need to register Google API Key, then put the key in this setting.', - 'opalestate-pro' ), - 'id' => 'google_map_api_keys', - 'type' => 'text', - 'default' => 'AIzaSyCfMVNIa7khIqYHCw6VBn8ShUWWm4tjbG8', - ], ] ); } diff --git a/inc/class-opalestate-enqueue.php b/inc/class-opalestate-enqueue.php index 81c79e54..b88cc32c 100755 --- a/inc/class-opalestate-enqueue.php +++ b/inc/class-opalestate-enqueue.php @@ -27,7 +27,6 @@ class OpalEstate_Enqueue { * Constructor */ public function __construct() { - add_action( 'wp_enqueue_scripts', [ $this, 'load_scripts' ] ); add_action( 'wp_head', [ $this, 'add_custom_styles' ] ); } @@ -52,6 +51,15 @@ class OpalEstate_Enqueue { * Google map. */ wp_enqueue_script( 'opalestate-gmap', OPALESTATE_PLUGIN_URL . 'assets/js/frontend/googlemaps.js', [ 'jquery' ], OPALESTATE_VERSION, false ); + $custom_map_styles = json_decode( ( opalestate_options( 'google_map_custom_style', '' ) ) ); + wp_localize_script( 'opalestate-gmap', 'opalestateGmap', [ + 'style' => opalestate_options( 'google_map_style', 'standard' ), + 'custom_style' => json_encode( $custom_map_styles ), + ] ); + + /** + * Frontend property. + */ wp_enqueue_script( 'opalestate-messages', OPALESTATE_PLUGIN_URL . 'assets/js/frontend/property.js', [ 'jquery' ], OPALESTATE_VERSION, false ); /** @@ -80,22 +88,20 @@ class OpalEstate_Enqueue { wp_enqueue_script( 'tooltipster' ); } - // load global variables - wp_localize_script( 'opalestate-scripts', 'opalesateJS', - [ - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - 'siteurl' => get_template_directory_uri(), - 'mapiconurl' => OPALESTATE_PLUGIN_URL . 'assets/map/', - 'rtl' => is_rtl() ? 'true' : 'false', - 'confirmed' => esc_html__( 'Are you sure to remove?', 'opalestate-pro' ), - 'error_upload_size' => esc_html__( 'This file is has large volume size, please try to upload other.', 'opalestate-pro' ), - 'size_image' => opalestate_options( 'upload_image_max_size', 0.5 ) * 1000000, - 'mfile_image' => opalestate_options( 'upload_image_max_files', 10 ), - 'size_other' => opalestate_options( 'upload_other_max_size', 0.8 ) * 1000000, - 'mfile_other' => opalestate_options( 'upload_other_max_files', 10 ), - ] ); + // Load global variables + wp_localize_script( 'opalestate-scripts', 'opalesateJS', [ + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'siteurl' => get_template_directory_uri(), + 'mapiconurl' => OPALESTATE_PLUGIN_URL . 'assets/map/', + 'rtl' => is_rtl() ? 'true' : 'false', + 'confirmed' => esc_html__( 'Are you sure to remove?', 'opalestate-pro' ), + 'error_upload_size' => esc_html__( 'This file is has large volume size, please try to upload other.', 'opalestate-pro' ), + 'size_image' => opalestate_options( 'upload_image_max_size', 0.5 ) * 1000000, + 'mfile_image' => opalestate_options( 'upload_image_max_files', 10 ), + 'size_other' => opalestate_options( 'upload_other_max_size', 0.8 ) * 1000000, + 'mfile_other' => opalestate_options( 'upload_other_max_files', 10 ), + ] ); - /// $this->register_enqueue(); } @@ -113,7 +119,7 @@ class OpalEstate_Enqueue { '4.4.3', true ); - + wp_enqueue_script( 'jquery-magnific-popup' ); wp_register_script( 'jquery-sticky-kit', trailingslashit( OPALESTATE_PLUGIN_URL ) . 'assets/3rd/sticky/jquery.sticky-kit.min.js', [], null, true ); wp_enqueue_script( 'jquery-sticky-kit' ); @@ -135,12 +141,12 @@ class OpalEstate_Enqueue { ], '4.4.3', true - ); - - if( !defined("ELEMENTOR_VERSION") ) { + ); + + if ( ! defined( "ELEMENTOR_VERSION" ) ) { wp_enqueue_style( 'jquery-swiper', OPALESTATE_PLUGIN_URL . '/assets/3rd/swiper/css/swiper.min.css' ); - } - + } + wp_enqueue_script( 'jquery-swiper' ); }