Origin commit
This commit is contained in:
157
assets/js/admin.js
Executable file
157
assets/js/admin.js
Executable file
@@ -0,0 +1,157 @@
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
/// apply select2 style
|
||||
$('select.cmb2_select').select2( {
|
||||
|
||||
} );
|
||||
|
||||
function load_select2_member ( id, action ) {
|
||||
$( id ).select2({
|
||||
width: '100%',
|
||||
ajax: {
|
||||
url: ajaxurl+"?action="+action,
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term, // search term
|
||||
page: params.page
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.items,
|
||||
pagination: {
|
||||
more: (params.page * 30) < data.total_count
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
placeholder: 'Search for a repository',
|
||||
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
|
||||
minimumInputLength: 1,
|
||||
templateResult: formatRepo,
|
||||
templateSelection: formatRepoSelection
|
||||
});
|
||||
}
|
||||
load_select2_member( '#opalestate_ppt_agent', 'opalestate_search_agents' );
|
||||
load_select2_member( '#opalestate_ppt_agency', 'opalestate_search_agencies' );
|
||||
load_select2_member( '#p-assignment #post_author_override', 'opalestate_search_property_users' );
|
||||
|
||||
function formatRepo (repo) {
|
||||
if ( repo.loading ) {
|
||||
return repo.text;
|
||||
}
|
||||
var markup = "<div class='select2-result-repository clearfix'>" +
|
||||
"<div class='select2-result-repository__avatar'><img width=\"50\" src='" + repo.avatar_url + "' /></div>" +
|
||||
"<div class='select2-result-repository__meta'>" +
|
||||
"<div class='select2-result-repository__title'>" + repo.full_name + "</div>";
|
||||
markup += "</div></div>";
|
||||
return markup;
|
||||
}
|
||||
|
||||
function formatRepoSelection (repo) {
|
||||
return repo.full_name || repo.text;
|
||||
}
|
||||
|
||||
// Ajax user search
|
||||
$('.opalestate-ajax-user-search').on('keyup', function () {
|
||||
var user_search = $(this).val();
|
||||
var exclude = '';
|
||||
|
||||
if ($(this).data('exclude')) {
|
||||
exclude = $(this).data('exclude');
|
||||
}
|
||||
|
||||
$('.opalestate-ajax').show();
|
||||
data = {
|
||||
action: 'opalestate_search_users',
|
||||
user_name: user_search,
|
||||
exclude: exclude
|
||||
};
|
||||
|
||||
document.body.style.cursor = 'wait';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
url: ajaxurl,
|
||||
success: function (search_response) {
|
||||
$('.opalestate-ajax').hide();
|
||||
$('.opalestate_user_search_results').removeClass('hidden');
|
||||
$('.opalestate_user_search_results span').html('');
|
||||
$(search_response.results).appendTo('.opalestate_user_search_results span');
|
||||
document.body.style.cursor = 'default';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click.opalestateSelectUser', '.opalestate_user_search_results span a', function (e) {
|
||||
e.preventDefault();
|
||||
var login = $(this).data('login');
|
||||
$('.opalestate-ajax-user-search').val(login);
|
||||
$('.opalestate_user_search_results').addClass('hidden');
|
||||
$('.opalestate_user_search_results span').html('');
|
||||
});
|
||||
|
||||
$('body').on('click.opalestateCancelUserSearch', '.opalestate_user_search_results a.opalestate-ajax-user-cancel', function (e) {
|
||||
e.preventDefault();
|
||||
$('.opalestate-ajax-user-search').val('');
|
||||
$('.opalestate_user_search_results').addClass('hidden');
|
||||
$('.opalestate_user_search_results span').html('');
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function open_media( field ){
|
||||
|
||||
var media = wp.media({
|
||||
title: 'Choose an image',
|
||||
button: {
|
||||
text: 'Select'
|
||||
},
|
||||
multiple: false
|
||||
});
|
||||
|
||||
media.open();
|
||||
|
||||
media.on( 'select', function(){
|
||||
var selection = media.state().get('selection');
|
||||
|
||||
var attachment = selection.first().toJSON();
|
||||
|
||||
//var attach = wp.media.attachment( cmb.attach_id );
|
||||
// attach.fetch();
|
||||
// selection.set( attach ? [ attach ] : [] );
|
||||
$( 'input', field).val( attachment.id );
|
||||
|
||||
if( $(field.data('related')).length > 0 ){
|
||||
$(field.data('related')).attr('src', attachment.url );
|
||||
}else if( $( 'img' , field ).length > 0 ){
|
||||
$( 'img', field).attr('src', attachment.url );
|
||||
}
|
||||
} )
|
||||
.on( 'open', function(){
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
$( '.media-view-upload-button' ).click( function () {
|
||||
var field = $( this ).parent();
|
||||
open_media( field );
|
||||
} );
|
||||
|
||||
$( '.media-view-remove-button' ).click( function () {
|
||||
var field = $( this ).parent();
|
||||
$( 'input', field).val( '' );
|
||||
$( 'img', field).attr('src', $( 'img', field).data('placeholder') );
|
||||
} );
|
||||
/**
|
||||
*
|
||||
*/
|
||||
});
|
||||
7
assets/js/chart.min.js
vendored
Executable file
7
assets/js/chart.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
113
assets/js/country-select.js
Executable file
113
assets/js/country-select.js
Executable file
@@ -0,0 +1,113 @@
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
|
||||
/**
|
||||
* Country select.
|
||||
*/
|
||||
var $country_el = $( '.opalestate-submission-form #opalestate_ppt_location, [name="location"],' +
|
||||
' [name="opalestate_ofe_location"], [name="opalestate_agt_location"]' ),
|
||||
$state_el = $( '.opalestate-submission-form #opalestate_ppt_state, [name="state"],' +
|
||||
' [name="opalestate_ofe_state"], [name="opalestate_agt_state"]' ),
|
||||
$city_el = $( '.opalestate-submission-form #opalestate_ppt_city, [name="city"],' +
|
||||
' [name="opalestate_ofe_city"], [name="opalestate_agt_city"]' );
|
||||
|
||||
$country_el.each( function () {
|
||||
if ( $( this ).val() != '' && $( this ).val() != '-1' ) {
|
||||
opalestate_ajax_get_state_by_country( $( this ) );
|
||||
}
|
||||
} );
|
||||
|
||||
$country_el.on( 'change', function () {
|
||||
opalestate_ajax_get_state_by_country( $( this ) );
|
||||
} );
|
||||
|
||||
$state_el.on( 'change', function () {
|
||||
opalestate_ajax_get_city_by_state( $( this ) );
|
||||
} );
|
||||
|
||||
function opalestate_ajax_get_state_by_country( $el ) {
|
||||
var country = $el.val();
|
||||
var is_search = 0;
|
||||
|
||||
if ( $el.closest( '.opalestate-search-form' ).length !== 0 ) {
|
||||
is_search = 1;
|
||||
}
|
||||
|
||||
var opalAjaxUrl = opalestate_get_ajax_url();
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalAjaxUrl,
|
||||
data: {
|
||||
'action': 'opalestate_ajax_get_state_by_country',
|
||||
'country': country,
|
||||
'is_search': is_search
|
||||
},
|
||||
success: function ( data ) {
|
||||
var old_selected = $state_el.val();
|
||||
var selected = is_search ? '-1' : '';
|
||||
if ( old_selected != '' && old_selected != '-1' ) {
|
||||
$.each( $.parseJSON( data ), function( key, value ) {
|
||||
if ( old_selected == value.id ) {
|
||||
selected = value.id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$state_el.empty();
|
||||
$state_el.select2( {
|
||||
data: $.parseJSON( data )
|
||||
} );
|
||||
$state_el.val( selected ).trigger( 'change' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function opalestate_ajax_get_city_by_state( $el ) {
|
||||
var state = $el.val();
|
||||
var is_search = 0;
|
||||
|
||||
if ( $el.closest( '.opalestate-search-form' ).length !== 0 ) {
|
||||
is_search = 1;
|
||||
}
|
||||
|
||||
var opalAjaxUrl = opalestate_get_ajax_url();
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalAjaxUrl,
|
||||
data: {
|
||||
'action': 'opalestate_ajax_get_city_by_state',
|
||||
'state': state,
|
||||
'is_search': is_search
|
||||
},
|
||||
success: function ( data ) {
|
||||
var old_selected = $city_el.val();
|
||||
var selected = is_search ? '-1' : '';
|
||||
if ( old_selected != '' && old_selected != '-1' ) {
|
||||
$.each( $.parseJSON( data ), function( key, value ) {
|
||||
if ( old_selected == value.id ) {
|
||||
selected = value.id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$city_el.empty();
|
||||
$city_el.select2( {
|
||||
data: $.parseJSON( data )
|
||||
} );
|
||||
$city_el.val( selected ).trigger( 'change' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function opalestate_get_ajax_url() {
|
||||
var opalAjaxUrl = '';
|
||||
if ( typeof ajaxurl != 'undefined' ) {
|
||||
opalAjaxUrl = ajaxurl;
|
||||
} else {
|
||||
opalAjaxUrl = opalesateJS.ajaxurl;
|
||||
}
|
||||
|
||||
return opalAjaxUrl;
|
||||
}
|
||||
} );
|
||||
186
assets/js/frontend/dashboard.js
Executable file
186
assets/js/frontend/dashboard.js
Executable file
@@ -0,0 +1,186 @@
|
||||
;(function ($, settings) {
|
||||
"use strict";
|
||||
|
||||
if (window.Opalestate === undefined) {
|
||||
window.Opalestate = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* GooglemapSearch
|
||||
*/
|
||||
var AgencyUpdateProfile = Opalestate.AgencyUpdateProfile = function ( form ) {
|
||||
|
||||
/**
|
||||
* Create Google Map In Single Property Only
|
||||
*/
|
||||
function getFormData () {
|
||||
|
||||
var formData = new FormData();
|
||||
|
||||
formData.append('section', 'general');
|
||||
$(".cmb2-uploader-files").each( function(){
|
||||
var file_btn = $( 'input.select-file', this );
|
||||
|
||||
var files = $(".uploader-item-preview", this );
|
||||
|
||||
var name = $(this).data( 'name' );
|
||||
var issingle = $( this ).data('single');
|
||||
$(files).each( function( i , element ){
|
||||
var file = $(this).prop( 'file');
|
||||
if( file ) {
|
||||
if( issingle ){
|
||||
formData.append( name, file );
|
||||
} else {
|
||||
formData.append( name+"["+i+"]", file );
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
||||
function toggleSubmit ( _this ){
|
||||
if( $( _this ).attr('disabled') == "disabled" ){
|
||||
$( _this ).removeAttr( 'disabled' );
|
||||
$(_this).find('i').remove( );
|
||||
} else {
|
||||
$( _this ).attr('disabled','disabled');
|
||||
$(_this).append( ' <i class="fa fa-spinner fa-spin"></i> ' );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function makeAjax( formData, $submit_btn ) {
|
||||
$.ajax({
|
||||
url : opalesateJS.ajaxurl,
|
||||
data : formData,
|
||||
type : 'POST',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: "json",
|
||||
success : function( response ){
|
||||
if( response.status == true ){
|
||||
if( response.redirect ){
|
||||
window.location.href = response.redirect;
|
||||
}
|
||||
|
||||
var myToast = $.toast({
|
||||
heading: response.heading,
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 5000,
|
||||
showHideTransition: 'fade',
|
||||
});
|
||||
} else {
|
||||
toggleSubmit( $submit_btn );
|
||||
var myToast = $.toast({
|
||||
heading: response.heading,
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 5000,
|
||||
showHideTransition: 'fade'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var init = function ( form ){
|
||||
$( form ).on( "submit", function(){
|
||||
|
||||
if( typeof(tinyMCE) != "undefined" ) {
|
||||
tinyMCE.triggerSave();
|
||||
}
|
||||
|
||||
toggleSubmit( $("button:submit" , form ) ) ;
|
||||
|
||||
var formData = getFormData();
|
||||
var dataSubmit = $( form ).serializeArray();
|
||||
|
||||
$.each( dataSubmit, function ( key, input ) {
|
||||
formData.append( input.name, input.value );
|
||||
});
|
||||
|
||||
makeAjax( formData, $("button:submit" , form ) )
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
init( form );
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
$(document).ready(function () {
|
||||
/// update agency profile
|
||||
if( $("#opalestate_ofe_front").length > 0 ){
|
||||
new AgencyUpdateProfile( $("#opalestate_ofe_front") );
|
||||
}
|
||||
// update agent profile
|
||||
if( $("#opalestate_agt_front").length > 0 ){
|
||||
new AgencyUpdateProfile( $("#opalestate_agt_front") );
|
||||
}
|
||||
|
||||
if( $("#opalestate_user_front").length > 0 ){
|
||||
new AgencyUpdateProfile( $("#opalestate_user_front") );
|
||||
}
|
||||
|
||||
if( $("#opalestate-add-team-form").length > 0 ){
|
||||
function formatRepo (repo) {
|
||||
if ( repo.loading ) {
|
||||
return repo.text;
|
||||
}
|
||||
var markup = "<div class='select2-search-member clearfix'>" +
|
||||
"<div class='avatar'><img width=\"50\" src='" + repo.avatar_url + "' /></div>" +
|
||||
"<div class='member-meta'>" +
|
||||
"<div class='member-title'>" + repo.full_name + "</div>";
|
||||
markup += "</div></div>";
|
||||
return markup;
|
||||
}
|
||||
|
||||
function formatRepoSelection (repo) {
|
||||
return repo.full_name || repo.text;
|
||||
}
|
||||
function load_select2_member ( id, action ) {
|
||||
$( id ).select2({
|
||||
width: '100%',
|
||||
ajax: {
|
||||
url: opalesateJS.ajaxurl+"?action="+action,
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term, // search term
|
||||
page: params.page
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.items,
|
||||
pagination: {
|
||||
more: (params.page * 30) < data.total_count
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
placeholder: 'Search for a repository',
|
||||
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
|
||||
minimumInputLength: 1,
|
||||
templateResult: formatRepo,
|
||||
templateSelection: formatRepoSelection
|
||||
});
|
||||
}
|
||||
|
||||
load_select2_member( ".opalesate-find-user", 'opalestate_search_property_users');
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
})(jQuery);
|
||||
|
||||
86
assets/js/frontend/elementor.js
Executable file
86
assets/js/frontend/elementor.js
Executable file
@@ -0,0 +1,86 @@
|
||||
(function ($ ) {
|
||||
"use strict";
|
||||
|
||||
var carouselSlick = function( $scope , $selector, elementorFrontend ) {
|
||||
|
||||
|
||||
var slidesToShow = 0;
|
||||
|
||||
var elementSettings = $scope.data('settings');
|
||||
|
||||
if( elementSettings === undefined ){
|
||||
var elementSettings = $scope.find(".elementor-opal-slick-slider").data('settings');
|
||||
}
|
||||
// console.log( elementSettings );
|
||||
if( elementSettings === undefined ){
|
||||
return true;
|
||||
}
|
||||
|
||||
var slidesToShow =+ elementSettings.slides_to_show || 3,
|
||||
isSingleSlide = 1 === slidesToShow,
|
||||
breakpoints = elementorFrontend.config.breakpoints;
|
||||
|
||||
var slickOptions = {
|
||||
slidesToShow: slidesToShow,
|
||||
autoplay: 'yes' === elementSettings.autoplay,
|
||||
autoplaySpeed: elementSettings.autoplay_speed,
|
||||
infinite: 'yes' === elementSettings.infinite,
|
||||
pauseOnHover: 'yes' === elementSettings.pause_on_hover,
|
||||
speed: elementSettings.speed,
|
||||
arrows: -1 !== [ 'arrows', 'both' ].indexOf( elementSettings.navigation ),
|
||||
dots: -1 !== [ 'dots', 'both' ].indexOf( elementSettings.navigation ),
|
||||
rtl: 'rtl' === elementSettings.direction,
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: breakpoints.lg,
|
||||
settings: {
|
||||
slidesToShow: +elementSettings.slides_to_show_tablet || ( isSingleSlide ? 1 : 2 ),
|
||||
slidesToScroll: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
breakpoint: breakpoints.md,
|
||||
settings: {
|
||||
slidesToShow: +elementSettings.slides_to_show_mobile || 1,
|
||||
slidesToScroll: 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if ( isSingleSlide ) {
|
||||
slickOptions.fade = 'fade' === elementSettings.effect;
|
||||
} else {
|
||||
slickOptions.slidesToScroll = +elementSettings.slides_to_scroll;
|
||||
}
|
||||
|
||||
var $carousel = $scope.find( $selector );
|
||||
// $carousel.removeClass('products');
|
||||
$carousel.slick( slickOptions );
|
||||
// $carousel.addClass('products');
|
||||
}
|
||||
|
||||
/// // / / / /
|
||||
$(window).on('elementor/frontend/init', function(){
|
||||
|
||||
elementorFrontend.hooks.addAction( 'frontend/element_ready/opalestate-agent-collection.default', function( $scope ) {
|
||||
if( $scope.find(".elementor-opal-slick-slider") ) {
|
||||
carouselSlick( $scope, '.elementor-slick-slider-row.row-items', elementorFrontend );
|
||||
}
|
||||
} );
|
||||
|
||||
elementorFrontend.hooks.addAction( 'frontend/element_ready/opalestate-property-collection.default', function( $scope ) {
|
||||
if( $scope.find(".elementor-opal-slick-slider") ) {
|
||||
carouselSlick( $scope, '.elementor-slick-slider-row.row-items' , elementorFrontend );
|
||||
}
|
||||
} );
|
||||
|
||||
elementorFrontend.hooks.addAction( 'frontend/element_ready/opalestate-category-list.default', function( $scope ) {
|
||||
if( $scope.find(".elementor-opal-slick-slider") ) {
|
||||
carouselSlick( $scope, '.elementor-slick-slider-row.row-items' , elementorFrontend );
|
||||
}
|
||||
} );
|
||||
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
621
assets/js/frontend/googlemaps.js
Executable file
621
assets/js/frontend/googlemaps.js
Executable file
@@ -0,0 +1,621 @@
|
||||
;(function ($, settings) {
|
||||
"use strict";
|
||||
|
||||
if (window.Opalestate === undefined) {
|
||||
window.Opalestate = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* GooglemapSearch
|
||||
*/
|
||||
var GooglemapSingle = Opalestate.GooglemapSingle = 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 allMarkers = [];
|
||||
|
||||
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( $('<em class="nearby-counter">'+markers.length+'</em>') );
|
||||
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( $('<em class="nearby-counter">'+markers.length+'</em>') );
|
||||
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,
|
||||
panControl: false,
|
||||
zoomControl: true,
|
||||
mapTypeControl: false,
|
||||
scaleControl: false,
|
||||
streetViewControl: true,
|
||||
overviewMapControl: false,
|
||||
zoomControlOptions: {
|
||||
style: google.maps.ZoomControlStyle.SMALL,
|
||||
position: google.maps.ControlPosition.RIGHT_TOP
|
||||
},
|
||||
streetViewControlOptions: {
|
||||
position: google.maps.ControlPosition.RIGHT_TOP
|
||||
}
|
||||
};
|
||||
|
||||
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++ ) {
|
||||
|
||||
// console.log( properties[i] );
|
||||
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;
|
||||
size = new google.maps.Size( 83, 113 );
|
||||
}
|
||||
}
|
||||
|
||||
var image = {
|
||||
url: url,
|
||||
size: size,
|
||||
scaledSize: new google.maps.Size( 30, 51 ),
|
||||
origin: new google.maps.Point( 0, 0 ),
|
||||
anchor: new google.maps.Point( 21, 56 )
|
||||
};
|
||||
|
||||
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,
|
||||
animation: google.maps.Animation.DROP,
|
||||
visible: true
|
||||
});
|
||||
|
||||
bounds.extend( markers[i].getPosition() );
|
||||
|
||||
var boxText = document.createElement( "div" );
|
||||
var pricelabel = '';
|
||||
|
||||
if( properties[i].pricelabel ){
|
||||
pricelabel = ' / ' + properties[i].pricelabel;
|
||||
}
|
||||
|
||||
// console.log( properties[i] );
|
||||
boxText.className = 'map-info-preview media';
|
||||
|
||||
var meta = '<ul class="list-inline property-meta-list">';
|
||||
if( properties[i].metas ){
|
||||
for ( var x in properties[i].metas ){
|
||||
var m = properties[i].metas[x];
|
||||
meta += '<li><i class="icon-property-'+x+'"></i>' + m.value +'<span class="label-property">' + m.label + '</span></li>'
|
||||
}
|
||||
}
|
||||
meta += '</ul>';
|
||||
|
||||
boxText.innerHTML = '<div class="media-top"><a class="thumb-link" href="' + properties[i].url + '">' +
|
||||
'<img class="prop-thumb" src="' + properties[i].thumb + '" alt="' + properties[i].title + '"/>' +
|
||||
'</a>'+ properties[i].status +'</div>' +
|
||||
'<div class="info-container media-body">' +
|
||||
'<h5 class="prop-title"><a class="title-link" href="' + properties[i].url + '">' + properties[i].title +
|
||||
'</a></h5><p class="prop-address"><em>' + properties[i].address + '</em></p><p><span class="price text-primary">' + properties[i].pricehtml + pricelabel +
|
||||
'</span></p>'+meta+'</div>'+'<div class="arrow-down"></div>';
|
||||
|
||||
var myOptions = {
|
||||
content: boxText,
|
||||
disableAutoPan: true,
|
||||
maxWidth: 0,
|
||||
alignBottom: true,
|
||||
pixelOffset: new google.maps.Size( -122, -48 ),
|
||||
zIndex: null,
|
||||
closeBoxMargin: "0 0 -16px -16px",
|
||||
closeBoxURL: opalesateJS.mapiconurl+"close.png",
|
||||
infoBoxClearance: new google.maps.Size( 1, 1 ),
|
||||
isHidden: false,
|
||||
pane: "floatPane",
|
||||
enableEventPropagation: false
|
||||
};
|
||||
|
||||
var ib = new InfoBox( myOptions );
|
||||
|
||||
attachInfoBoxToMarker( map, markers[i], ib, i );
|
||||
}
|
||||
|
||||
var last = null ;
|
||||
|
||||
$('body').delegate( '[data-related="map"]', 'mouseenter', function(){
|
||||
if( $(this).hasClass('map-active') ){
|
||||
return true;
|
||||
}
|
||||
|
||||
var i = $(this).data( 'id' );
|
||||
$( '[data-related="map"]' ).removeClass( 'map-active' );
|
||||
$(this).addClass( 'active' );
|
||||
map.setZoom( 65536 );// alert( scale );
|
||||
|
||||
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 projection = map.getProjection();
|
||||
var markerPosition = marker.getPosition();
|
||||
var markerScreenPosition = projection.fromLatLngToPoint( markerPosition );
|
||||
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);
|
||||
|
||||
/* Marker Clusters */
|
||||
var markerClustererOptions = {
|
||||
ignoreHidden: true,
|
||||
maxZoom: 14,
|
||||
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(){
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
if( last != null ){
|
||||
last.close();
|
||||
}
|
||||
|
||||
var scale = Math.pow( 2, map.getZoom() );
|
||||
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 aboveMarkerLatLng = projection.fromPointToLatLng( pointHalfScreenAbove );
|
||||
map.setCenter( aboveMarkerLatLng );
|
||||
infoBox.open( map, marker );
|
||||
last = infoBox;
|
||||
});
|
||||
}
|
||||
}
|
||||
initializePropertiesMap( data );
|
||||
}
|
||||
|
||||
/////
|
||||
$(document).ready(function () {
|
||||
|
||||
function initialize_property_street_view( data , id ){
|
||||
|
||||
var propertyMarkerInfo = data;
|
||||
|
||||
var propertyLocation = new google.maps.LatLng( propertyMarkerInfo.latitude, propertyMarkerInfo.longitude );
|
||||
|
||||
/**
|
||||
* Street View
|
||||
*/
|
||||
var panoramaOptions = {
|
||||
position: propertyLocation,
|
||||
pov: {
|
||||
heading: 34,
|
||||
pitch: 10
|
||||
}
|
||||
};
|
||||
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') );
|
||||
} );
|
||||
|
||||
$( ".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') ;
|
||||
|
||||
initialize_property_street_view( d , i );
|
||||
} );
|
||||
$( ".property-preview-street-map").show( 100 );
|
||||
} );
|
||||
///
|
||||
// auto set height for split google map
|
||||
$( '.split-maps-container' ).each( function() {
|
||||
$( "#opalestate-map-preview ").height( $(window).height() );
|
||||
} );
|
||||
})
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// search
|
||||
// show google maps
|
||||
// update google maps
|
||||
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 );
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
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( $('<div class="opalestate-loading"></div>') );
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: opalesateJS.ajaxurl,
|
||||
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( {
|
||||
width: '100%',
|
||||
minimumResultsForSearch: -1
|
||||
} );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePropertiesByParseringHtml( newurl ){
|
||||
$( '.opalesate-properties-results .opalesate-archive-bottom').append( $('<div class="opalestate-loading"></div>') );
|
||||
$.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) {
|
||||
var ps = $form.serialize();
|
||||
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?'+ ps;
|
||||
window.history.pushState({path:newurl},'',newurl);
|
||||
updatePropertiesByParseringHtml( newurl );
|
||||
}
|
||||
|
||||
} else {
|
||||
updatePropertiesResults( $(this).serialize() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} );
|
||||
|
||||
|
||||
$( '.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);
|
||||
}
|
||||
$form.submit();
|
||||
return false;
|
||||
} );
|
||||
} );
|
||||
|
||||
// // Sortable Change // //
|
||||
$("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( $(".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();
|
||||
}
|
||||
} );
|
||||
// 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);
|
||||
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;
|
||||
|
||||
updatePreviewGoogleMap( url );
|
||||
$('form.opalestate-search-form').submit();
|
||||
return true;
|
||||
} );
|
||||
|
||||
$( "body" ).delegate( "form.opalestate-search-form input", "change", function () {
|
||||
|
||||
if( $(this).hasClass("ranger-geo_radius") ){
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = $( "form.opalestate-search-form" ).serialize();
|
||||
var url = "action=opalestate_ajx_get_properties&"+params;
|
||||
updatePreviewGoogleMap( url );
|
||||
$('form.opalestate-search-form').submit();
|
||||
} );
|
||||
}
|
||||
/////////// ///////
|
||||
|
||||
|
||||
} );
|
||||
})(jQuery);
|
||||
|
||||
//// //////
|
||||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
$(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] );
|
||||
// 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() {
|
||||
|
||||
var place = autocomplete.getPlace();
|
||||
|
||||
|
||||
if ( ! place.geometry ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( place.geometry.location.lat() ){
|
||||
$(mapInstance).addClass("active");
|
||||
} else {
|
||||
$(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("");
|
||||
latitude.change();
|
||||
} );
|
||||
|
||||
$( searchInput ).keypress( function( event ) {
|
||||
if ( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
263
assets/js/frontend/property.js
Executable file
263
assets/js/frontend/property.js
Executable file
@@ -0,0 +1,263 @@
|
||||
/* global tinymce, wpCookies, autosaveL10n, switchEditors */
|
||||
// Back-compat
|
||||
window.opalestate_messages = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Adds autosave to the window object on dom ready.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param {jQuery} $ jQuery object.
|
||||
* @param {window} The window object.
|
||||
*
|
||||
*/
|
||||
|
||||
( function( $, window ) {
|
||||
|
||||
/**
|
||||
* @summary Auto saves the post.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @returns {Object}
|
||||
* {{
|
||||
* getPostData: getPostData,
|
||||
* getCompareString: getCompareString,
|
||||
* disableButtons: disableButtons,
|
||||
* enableButtons: enableButtons,
|
||||
* local: ({hasStorage, getSavedPostData, save, suspend, resume}|*),
|
||||
* server: ({tempBlockSave, triggerSave, postChanged, suspend, resume}|*)}
|
||||
* }
|
||||
* The object with all functions for autosave.
|
||||
*/
|
||||
|
||||
function opalestate_messages() {
|
||||
|
||||
var $document = $( document );
|
||||
var $page = $( '#page-importer' );
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function trigger_send_messages(){
|
||||
$( ".opalestate-message-form" ).on('submit', function(){
|
||||
make_ajax( $( this ).serialize(), this );
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
function toggle_submit_button ( submit ){
|
||||
var _this = $('button[type="submit"]', submit );
|
||||
if( $( _this ).attr('disabled') == "disabled" ){
|
||||
$( _this ).removeAttr( 'disabled' );
|
||||
$(_this).find('i').remove( );
|
||||
} else {
|
||||
$( _this ).attr('disabled','disabled');
|
||||
$(_this).append( '<i class="fa fa-spinner fa-spin"></i>' );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function trigger_send_reply(){
|
||||
$( ".opalestate-form-reply" ).on( "submit" , function(){
|
||||
var message = $( 'textarea', this).val();
|
||||
if( message ) {
|
||||
make_ajax_reply( $( this ).serialize(), this );
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
function make_ajax_reply( data, _this ){
|
||||
|
||||
$( '.opalestate-message-notify', _this ).remove();
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
url : opalesateJS.ajaxurl,
|
||||
data : 'action=send_email_contact_reply&' + data,
|
||||
success: function( response ) {
|
||||
if( response ) {
|
||||
var _class = response.status ? 'success' : 'danger';
|
||||
// $( _this ).append('<p class="opalestate-message-notify msg-status-'+ _class +'"><span>'+ response.msg +'</span></p>');
|
||||
if( response.status ){
|
||||
$( 'textarea', _this ).val( "" );
|
||||
var myToast = $.toast({
|
||||
heading: response.heading,
|
||||
text: response.msg,
|
||||
icon: 'success',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 3500,
|
||||
showHideTransition: 'fade'
|
||||
});
|
||||
if ( response.data ){
|
||||
var html = '<div class="message-body">';
|
||||
html += '<div class="message-body"><div class="message-avatar">';
|
||||
html += '<img src="'+response.data.avatar+'">';
|
||||
html += '</div><div class="message-content">';
|
||||
html += '<div>'+response.data.created+'</div>' + response.data.message;
|
||||
html += '</div></div>';
|
||||
html += '</div>';
|
||||
|
||||
$(".opalestate-read-message").append( html );
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function load_message_reply(){
|
||||
|
||||
}
|
||||
|
||||
function make_ajax ( data, _this ) {
|
||||
$( '.opalestate-message-notify', _this ).remove();
|
||||
var action = $( _this ).data('action')? $( _this ).data('action') : 'send_email_contact';
|
||||
toggle_submit_button( _this );
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
url : opalesateJS.ajaxurl,
|
||||
data : 'action='+action+'&' + data,
|
||||
success: function( response ) {
|
||||
if( response ) {
|
||||
var _class = response.status ? 'success' : 'danger';
|
||||
$( _this ).append('<p class="opalestate-message-notify msg-status-'+ _class +'"><span>'+ response.msg +'</span></p>');
|
||||
if( response.status ){
|
||||
$( 'textarea', _this ).val( "" );
|
||||
}
|
||||
toggle_submit_button( _this );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function trigger_print_property() {
|
||||
$( '.js-print-property' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $( this ).data( 'id' );
|
||||
var newWindown = window.open( '', 'Print!', 'width=800 ,height=850' );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: {
|
||||
'action': 'opalestate_ajax_create_property_print',
|
||||
'id': id,
|
||||
},
|
||||
success: function ( data ) {
|
||||
newWindown.document.write( data );
|
||||
newWindown.document.close();
|
||||
newWindown.focus();
|
||||
|
||||
setTimeout( function () {
|
||||
newWindown.print();
|
||||
}, 1000 );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
function trigger_toggle_featured() {
|
||||
/// ajax set featured
|
||||
$( 'body' ).delegate( '.btn-toggle-featured', 'click', function () {
|
||||
var $this = $( this );
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: 'property_id=' + $( this ).data( 'property-id' ) + '&action=opalestate_toggle_featured_property', // elements.
|
||||
dataType: 'json',
|
||||
success: function ( data ) {
|
||||
if ( data.status ) {
|
||||
$( '[data-id="property-toggle-featured-' + $this.data( 'property-id' ) + '"]' )
|
||||
.removeClass( 'hide' );
|
||||
$this.remove();
|
||||
} else {
|
||||
alert( data.msg );
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
function trigger_view_gallery(){
|
||||
$( 'body' ).delegate( '.opalestate-ajax-gallery', 'click', function () {
|
||||
var parent = $(this).parent();
|
||||
var open_gallery = function ( parent ){
|
||||
$(parent ).magnificPopup({
|
||||
type: 'image',
|
||||
delegate: 'a.gallery-item',
|
||||
gallery:{
|
||||
enabled:true
|
||||
}
|
||||
});
|
||||
$( 'a.gallery-item', parent ).trigger('click');
|
||||
}
|
||||
if( $(".gallery-item", parent ).length <= 0 ){
|
||||
var items = [];
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: 'property_id=' + $( this ).data( 'id' ) + '&action=opalestate_gallery_property', // elements.
|
||||
dataType: 'json',
|
||||
success: function ( data ) {
|
||||
if( data.gallery ){
|
||||
for( var image in data.gallery ){
|
||||
parent.append( '<a href="'+data.gallery[image]+'" class="gallery-item hide"></a>' );
|
||||
}
|
||||
|
||||
}
|
||||
open_gallery( parent );
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
open_gallery( parent );
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
/**
|
||||
* @summary Sets the autosave time out.
|
||||
*
|
||||
* Wait for TinyMCE to initialize plus 1 second. for any external css to finish loading,
|
||||
* then save to the textarea before setting initialCompareString.
|
||||
* This avoids any insignificant differences between the initial textarea content and the content
|
||||
* extracted from the editor.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
$document.on( '.opalestate-message-form', function( event, editor ) {
|
||||
|
||||
}).ready( function() {
|
||||
trigger_send_messages();
|
||||
trigger_send_reply();
|
||||
|
||||
trigger_print_property();
|
||||
trigger_toggle_featured();
|
||||
|
||||
trigger_view_gallery();
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/** @namespace wp */
|
||||
window.wp = window.wp || {};
|
||||
window.wp.opalestate_messages = opalestate_messages();
|
||||
|
||||
}( jQuery, window ));
|
||||
245
assets/js/frontend/submission.js
Executable file
245
assets/js/frontend/submission.js
Executable file
@@ -0,0 +1,245 @@
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
|
||||
var toggleSubmit = function ( _this ){
|
||||
if( $( _this ).attr('disabled') == "disabled" ){
|
||||
$( _this ).removeAttr( 'disabled' );
|
||||
$(_this).find('i').remove( );
|
||||
} else {
|
||||
$( _this ).attr('disabled','disabled');
|
||||
$(_this).append( '<i class="fa fa-spinner fa-spin"></i>' );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$( '.opalestate-submission-tab' ).each( function () {
|
||||
var $submission_tab = $( this );
|
||||
var $submit_btn = $submission_tab.find( '[name=submit-cmb]' );
|
||||
var $next_btn = $( '.submission-next-btn' );
|
||||
var $back_btn = $( '.submission-back-btn' );
|
||||
var $tab_content = $submission_tab.find( '.opalestate-tab-content' );
|
||||
|
||||
$submission_tab.find( '.tab-item' ).first().addClass( 'active' );
|
||||
$tab_content.first().addClass( 'active' );
|
||||
if ( $tab_content.length != 1 ) {
|
||||
$submit_btn.hide();
|
||||
} else {
|
||||
$next_btn.hide();
|
||||
}
|
||||
|
||||
$submit_btn.on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
var empty_required_inputs = opalestate_get_empty_required_inputs( $submission_tab );
|
||||
if ( empty_required_inputs.length === 0 ) {
|
||||
$submit_btn.parents( 'form' ).submit();
|
||||
}
|
||||
} );
|
||||
|
||||
/*
|
||||
$next_btn.click( function(){
|
||||
// $submit_btn.click();
|
||||
|
||||
return false;
|
||||
});
|
||||
*/
|
||||
var submitFormFiles = function ( name, files ) {
|
||||
|
||||
var formData = new FormData();
|
||||
|
||||
formData.append('section', 'general');
|
||||
// formData.append('action', 'opalestate_submitted_property');
|
||||
|
||||
|
||||
$(".cmb2-uploader-files").each( function(){
|
||||
var file_btn = $( 'input.select-file', this );
|
||||
|
||||
var files = $(".uploader-item-preview", this );
|
||||
|
||||
var name = $(this).data( 'name' );
|
||||
var issingle = $( this ).data('single');
|
||||
$(files).each( function( i , element ){
|
||||
var file = $(this).prop( 'file');
|
||||
if( file ) {
|
||||
if( issingle ){
|
||||
formData.append( name, file );
|
||||
} else {
|
||||
formData.append( name+"["+i+"]", file );
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
// console.log( formData );
|
||||
|
||||
var dataSubmit = $submit_btn.parents( 'form' ).serializeArray();
|
||||
|
||||
$.each( dataSubmit, function ( key, input ) {
|
||||
formData.append( input.name, input.value );
|
||||
});
|
||||
|
||||
formData.append('action', 'opalestate_save_agency_data');
|
||||
toggleSubmit( $submit_btn );
|
||||
$.ajax({
|
||||
url : opalesateJS.ajaxurl,
|
||||
data : formData,
|
||||
type : 'POST',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: "json",
|
||||
success : function( response ){
|
||||
if( response.status == true ){
|
||||
if( response.redirect ){
|
||||
window.location.href = response.redirect;
|
||||
}
|
||||
|
||||
var myToast = $.toast({
|
||||
heading: response.heading,
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 5000,
|
||||
showHideTransition: 'fade',
|
||||
});
|
||||
} else {
|
||||
toggleSubmit( $submit_btn );
|
||||
var myToast = $.toast({
|
||||
heading: response.heading,
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 5000,
|
||||
showHideTransition: 'fade'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$submit_btn.parents( 'form' ).on('submit', function() {
|
||||
submitFormFiles();
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
||||
// Clicking Next button
|
||||
$next_btn.on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
var $tab_content = $( this ).parents( '.opalestate-tab-content' );
|
||||
var empty_required_inputs = opalestate_get_empty_required_inputs( $tab_content );
|
||||
|
||||
if ( empty_required_inputs.length === 0 ) {
|
||||
var $next_tab_content = $tab_content.next();
|
||||
if ( $next_tab_content.length != 0 ) {
|
||||
$submission_tab.find( '.opalestate-tab-content' ).removeClass( 'active' );
|
||||
$submission_tab.find( '.tab-item.active' )
|
||||
.removeClass( 'active' )
|
||||
.addClass( 'validated' )
|
||||
.addClass( 'passed' )
|
||||
.next()
|
||||
.addClass( 'active' );
|
||||
$tab_content.addClass( 'validated' ).addClass( 'passed' );
|
||||
$next_tab_content.addClass( 'active' );
|
||||
|
||||
$( 'html, body' ).animate( {
|
||||
scrollTop: $next_tab_content.offset().top - 100
|
||||
}, 500 );
|
||||
|
||||
// Show Save button if is last tab.
|
||||
if ( $next_tab_content.is( ':last-child' ) ) {
|
||||
$next_btn.hide();
|
||||
$submit_btn.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Clicking Back button
|
||||
$back_btn.on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
var $tab_content = $( this ).parents( '.opalestate-tab-content' );
|
||||
|
||||
$submission_tab.find( '.opalestate-tab-content' ).removeClass( 'active' );
|
||||
$submission_tab.find( '.tab-item.active' )
|
||||
.removeClass( 'active' )
|
||||
.removeClass( 'passed' )
|
||||
.prev()
|
||||
.addClass( 'active' );
|
||||
$tab_content.removeClass( 'active' );
|
||||
|
||||
var $prev_tab_content = $tab_content.prev();
|
||||
|
||||
if ( $prev_tab_content.length != 0 ) {
|
||||
$prev_tab_content.addClass( 'active' ).removeClass( 'passed' );
|
||||
$( 'html, body' ).animate( {
|
||||
scrollTop: $prev_tab_content.offset().top - 100
|
||||
}, 500 );
|
||||
}
|
||||
|
||||
$submit_btn.hide();
|
||||
$next_btn.show();
|
||||
} );
|
||||
|
||||
$( '.tab-item' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
var $el = $( this );
|
||||
var $prev_tab_item = $el.prev();
|
||||
if ( $el.hasClass( 'validated' ) || ($prev_tab_item.length != 0 && $prev_tab_item.hasClass( 'validated' ) &&
|
||||
$prev_tab_item.hasClass( 'passed' )) ) {
|
||||
$submission_tab.find( '.opalestate-tab-content' ).removeClass( 'active' );
|
||||
$submission_tab.find( '.tab-item.active' ).removeClass( 'active' );
|
||||
var $tab_id = $el.attr( 'href' );
|
||||
var $prev_tab_content = $( $tab_id ).prev();
|
||||
var $next_tab_content = $( $tab_id ).next();
|
||||
|
||||
if ( $prev_tab_content.length != 0 ) {
|
||||
$back_btn.show();
|
||||
} else {
|
||||
$back_btn.hide();
|
||||
}
|
||||
|
||||
if ( $next_tab_content.length != 0 ) {
|
||||
$next_btn.show();
|
||||
$submit_btn.hide();
|
||||
} else {
|
||||
$next_btn.hide();
|
||||
$submit_btn.show();
|
||||
}
|
||||
|
||||
$el.addClass( 'active' );
|
||||
$( $tab_id ).addClass( 'active' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
function opalestate_get_empty_required_inputs( el_wrapper ) {
|
||||
var empty_required_inputs = [];
|
||||
el_wrapper.find( 'input' ).each( function () {
|
||||
$( this ).removeClass( 'required' );
|
||||
$( this ).blur();
|
||||
|
||||
if ( $( this ).prop( 'required' ) ) {
|
||||
if ( $( this ).val() == '' ) {
|
||||
$( this ).addClass( 'required' );
|
||||
$( this ).focus();
|
||||
empty_required_inputs.push( $( this ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
return empty_required_inputs;
|
||||
}
|
||||
|
||||
$( '.opalestate-tab-content input' ).each( function ( e ) {
|
||||
if ( $( this ).prop( 'required' ) ) {
|
||||
$( this ).on( 'input', function () {
|
||||
if ( $( this ).val() == '' ) {
|
||||
$( this ).addClass( 'required' );
|
||||
$( this ).focus();
|
||||
} else {
|
||||
$( this ).removeClass( 'required' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
193
assets/js/frontend/uploader.js
Executable file
193
assets/js/frontend/uploader.js
Executable file
@@ -0,0 +1,193 @@
|
||||
/* global tinymce, wpCookies, autosaveL10n, switchEditors */
|
||||
// Back-compat
|
||||
window.opalestate_uploader = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Adds autosave to the window object on dom ready.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param {jQuery} $ jQuery object.
|
||||
* @param {window} The window object.
|
||||
*
|
||||
*/
|
||||
|
||||
( function( $, window ) {
|
||||
|
||||
/**
|
||||
* @summary Auto saves the post.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* The object with all functions for autosave.
|
||||
*/
|
||||
|
||||
function opalestate_uploader() {
|
||||
|
||||
$document = $( document );
|
||||
|
||||
function is_image_file( file ) {
|
||||
const acceptedImageTypes = ['image/gif', 'image/jpeg', 'image/png'];
|
||||
return file && acceptedImageTypes.includes(file['type'])
|
||||
}
|
||||
|
||||
function check_number_files( file , i ) {
|
||||
if( is_image_file(file) ) {
|
||||
if( i+1 > opalesateJS.mfile_image ){
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if( i+1 > opalesateJS.mfile_other ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function check_filesize ( file , i ) {
|
||||
|
||||
if( is_image_file(file) ) {
|
||||
if( file.size > opalesateJS.size_image ){
|
||||
var myToast = $.toast({
|
||||
heading: file.name,
|
||||
text: opalesateJS.error_upload_size,
|
||||
icon: 'error',
|
||||
position: 'bottom-right',
|
||||
hideAfter: 3500,
|
||||
showHideTransition: 'fade'
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function trigger_button_upload(){
|
||||
|
||||
var handleUpload = function ( _container ){
|
||||
|
||||
var file_btn = $( 'input.select-file', _container );
|
||||
var allow_files = [];
|
||||
// var all_selected = [];
|
||||
var name = $(this).data( 'name' );
|
||||
var issingle = $(_container).data('single');
|
||||
var show_icon = $(_container).data( 'show-icon' );
|
||||
|
||||
var on_select_files = function ( files, _container ) {
|
||||
|
||||
if ( window.File && window.FileList && window.FileReader ) {
|
||||
$(files).each( function( i, file ){
|
||||
|
||||
if( check_number_files( file, i+$(".uploader-item-preview",_container).length ) == false ){
|
||||
return ;
|
||||
}
|
||||
if( check_filesize( file, i ) ) {
|
||||
var picReader = new FileReader();
|
||||
picReader.addEventListener("load", function ( event ) {
|
||||
var input = '<div class="uploader-item-preview">';
|
||||
var picFile = event.target;
|
||||
if ( picFile.result ) {
|
||||
if( show_icon == 1 ) {
|
||||
input += '<div class="inner preview-icon"><span class="btn-close"></span><i class="fas fa-paperclip"></i> '+ file.name +' </div>';
|
||||
} else {
|
||||
input += '<div class="inner preview-image"><span class="btn-close"></span><img src="'+picFile.result+'"></div>';
|
||||
}
|
||||
|
||||
}
|
||||
input += '</div>';
|
||||
var a = $(input) ;
|
||||
if( issingle ){
|
||||
$( ".uploader-item-preview", _container ).remove();
|
||||
all_selected = [];
|
||||
}
|
||||
$( _container ).prepend( a );
|
||||
a.prop( 'file', file );
|
||||
} );
|
||||
picReader.readAsDataURL( file );
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
||||
|
||||
file_btn.on("change", function( event ){
|
||||
on_select_files( event.target.files, _container, allow_files );
|
||||
|
||||
} );
|
||||
|
||||
$( _container ).on( "click", ".btn-close", function(){
|
||||
if( confirm(opalesateJS.confirmed ) ){
|
||||
if( $("input", $(this).parent().parent()).length ){
|
||||
var rinput = $("<input type=\"hidden\" name=\"remove_image_id[]\" value=\""+ $("input", $(this).parent().parent()).val() +"\">");
|
||||
$(_container).append( rinput );
|
||||
}
|
||||
|
||||
$(this).parent().parent().remove();
|
||||
}
|
||||
} );
|
||||
|
||||
$( ".button-placehold", _container ).click( function(){
|
||||
file_btn.trigger("click");
|
||||
} );
|
||||
}
|
||||
|
||||
$(".cmb2-uploader-files").each( function(){
|
||||
handleUpload( this )
|
||||
} );
|
||||
|
||||
// fix for submittion form
|
||||
window.CMB2 = window.CMB2 || {};
|
||||
window.CMB2.metabox().find('.cmb-repeatable-group').on( 'cmb2_add_row', function(i, row ) {
|
||||
var _container = $( row );
|
||||
if( $(".cmb2-uploader-files", _container ).length ) {
|
||||
$( ".uploader-item-preview", _container ).remove();
|
||||
$(".cmb2-uploader-files", _container ).each( function(){
|
||||
var name = $( 'input', this ).attr('name');
|
||||
$( this ).attr('data-name', name );
|
||||
$(this).data( 'name', name );
|
||||
handleUpload( this );
|
||||
});
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function upload_attachments( name, files ) {
|
||||
|
||||
alert( name );
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Sets the autosave time out.
|
||||
*
|
||||
* Wait for TinyMCE to initialize plus 1 second. for any external css to finish loading,
|
||||
* then save to the textarea before setting initialCompareString.
|
||||
* This avoids any insignificant differences between the initial textarea content and the content
|
||||
* extracted from the editor.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
$document.on( 'body', function( event, editor ) {
|
||||
|
||||
}).ready( function() {
|
||||
trigger_button_upload();
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/** @namespace wp */
|
||||
window.wp = window.wp || {};
|
||||
window.wp.opalestate_uploader = opalestate_uploader();
|
||||
|
||||
}( jQuery, window ));
|
||||
772
assets/js/infobox.js
Executable file
772
assets/js/infobox.js
Executable file
@@ -0,0 +1,772 @@
|
||||
/**
|
||||
* @name InfoBox
|
||||
* @version 1.1.9 [October 2, 2011]
|
||||
* @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
|
||||
* @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
|
||||
* @fileoverview InfoBox extends the Google Maps JavaScript API V3 <tt>OverlayView</tt> class.
|
||||
* <p>
|
||||
* An InfoBox behaves like a <tt>google.maps.InfoWindow</tt>, but it supports several
|
||||
* additional properties for advanced styling. An InfoBox can also be used as a map label.
|
||||
* <p>
|
||||
* An InfoBox also fires the same events as a <tt>google.maps.InfoWindow</tt>.
|
||||
* <p>
|
||||
* Browsers tested:
|
||||
* <p>
|
||||
* Mac -- Safari (4.0.4), Firefox (3.6), Opera (10.10), Chrome (4.0.249.43), OmniWeb (5.10.1)
|
||||
* <br>
|
||||
* Win -- Safari, Firefox, Opera, Chrome (3.0.195.38), Internet Explorer (8.0.6001.18702)
|
||||
* <br>
|
||||
* iPod Touch/iPhone -- Safari (3.1.2)
|
||||
*/
|
||||
|
||||
/*!
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*jslint browser:true */
|
||||
/*global google */
|
||||
|
||||
/**
|
||||
* @name InfoBoxOptions
|
||||
* @class This class represents the optional parameter passed to the {@link InfoBox} constructor.
|
||||
* @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).
|
||||
* @property {boolean} disableAutoPan Disable auto-pan on <tt>open</tt> (default is <tt>false</tt>).
|
||||
* @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.
|
||||
* @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox
|
||||
* (or the bottom left corner if the <code>alignBottom</code> property is <code>true</code>)
|
||||
* to the map pixel corresponding to <tt>position</tt>.
|
||||
* @property {LatLng} position The geographic location at which to display the InfoBox.
|
||||
* @property {number} zIndex The CSS z-index style value for the InfoBox.
|
||||
* Note: This value overrides a zIndex setting specified in the <tt>boxStyle</tt> property.
|
||||
* @property {string} boxClass The name of the CSS class defining the styles for the InfoBox container.
|
||||
* The default name is <code>infoBox</code>.
|
||||
* @property {Object} [boxStyle] An object literal whose properties define specific CSS
|
||||
* style values to be applied to the InfoBox. Style values defined here override those that may
|
||||
* be defined in the <code>boxClass</code> style sheet. If this property is changed after the
|
||||
* InfoBox has been created, all previously set styles (except those defined in the style sheet)
|
||||
* are removed from the InfoBox before the new style values are applied.
|
||||
* @property {string} closeBoxMargin The CSS margin style value for the close box.
|
||||
* The default is "2px" (a 2-pixel margin on all sides).
|
||||
* @property {string} closeBoxURL The URL of the image representing the close box.
|
||||
* Note: The default is the URL for Google's standard close box.
|
||||
* Set this property to "" if no close box is required.
|
||||
* @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the
|
||||
* map edge after an auto-pan.
|
||||
* @property {boolean} isHidden Hide the InfoBox on <tt>open</tt> (default is <tt>false</tt>).
|
||||
* @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the <code>position</code>
|
||||
* location (default is <tt>false</tt> which means that the top left corner of the InfoBox is aligned).
|
||||
* @property {string} pane The pane where the InfoBox is to appear (default is "floatPane").
|
||||
* Set the pane to "mapPane" if the InfoBox is being used as a map label.
|
||||
* Valid pane names are the property names for the <tt>google.maps.MapPanes</tt> object.
|
||||
* @property {boolean} enableEventPropagation Propagate mousedown, click, dblclick,
|
||||
* and contextmenu events in the InfoBox (default is <tt>false</tt> to mimic the behavior
|
||||
* of a <tt>google.maps.InfoWindow</tt>). Set this property to <tt>true</tt> if the InfoBox
|
||||
* is being used as a map label. iPhone note: This property setting has no effect; events are
|
||||
* always propagated.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an InfoBox with the options specified in {@link InfoBoxOptions}.
|
||||
* Call <tt>InfoBox.open</tt> to add the box to the map.
|
||||
* @constructor
|
||||
* @param {InfoBoxOptions} [opt_opts]
|
||||
*/
|
||||
function InfoBox(opt_opts) {
|
||||
|
||||
opt_opts = opt_opts || {};
|
||||
|
||||
google.maps.OverlayView.apply(this, arguments);
|
||||
|
||||
// Standard options (in common with google.maps.InfoWindow):
|
||||
//
|
||||
this.content_ = opt_opts.content || "";
|
||||
this.disableAutoPan_ = opt_opts.disableAutoPan || false;
|
||||
this.maxWidth_ = opt_opts.maxWidth || 0;
|
||||
this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
|
||||
this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
|
||||
this.zIndex_ = opt_opts.zIndex || null;
|
||||
|
||||
// Additional options (unique to InfoBox):
|
||||
//
|
||||
this.boxClass_ = opt_opts.boxClass || "infoBox";
|
||||
this.boxStyle_ = opt_opts.boxStyle || {};
|
||||
this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
|
||||
this.closeBoxURL_ = opt_opts.closeBoxURL || "http://www.google.com/intl/en_us/mapfiles/close.gif";
|
||||
if (opt_opts.closeBoxURL === "") {
|
||||
this.closeBoxURL_ = "";
|
||||
}
|
||||
this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
|
||||
this.isHidden_ = opt_opts.isHidden || false;
|
||||
this.alignBottom_ = opt_opts.alignBottom || false;
|
||||
this.pane_ = opt_opts.pane || "floatPane";
|
||||
this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
|
||||
|
||||
this.div_ = null;
|
||||
this.closeListener_ = null;
|
||||
this.eventListener1_ = null;
|
||||
this.eventListener2_ = null;
|
||||
this.eventListener3_ = null;
|
||||
this.moveListener_ = null;
|
||||
this.contextListener_ = null;
|
||||
this.fixedWidthSet_ = null;
|
||||
}
|
||||
|
||||
/* InfoBox extends OverlayView in the Google Maps API v3.
|
||||
*/
|
||||
InfoBox.prototype = new google.maps.OverlayView();
|
||||
|
||||
/**
|
||||
* Creates the DIV representing the InfoBox.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.createInfoBoxDiv_ = function () {
|
||||
|
||||
var bw;
|
||||
var me = this;
|
||||
|
||||
// This handler prevents an event in the InfoBox from being passed on to the map.
|
||||
//
|
||||
var cancelHandler = function (e) {
|
||||
e.cancelBubble = true;
|
||||
|
||||
if (e.stopPropagation) {
|
||||
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
|
||||
// This handler ignores the current event in the InfoBox and conditionally prevents
|
||||
// the event from being passed on to the map. It is used for the contextmenu event.
|
||||
//
|
||||
var ignoreHandler = function (e) {
|
||||
|
||||
e.returnValue = false;
|
||||
|
||||
if (e.preventDefault) {
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (!me.enableEventPropagation_) {
|
||||
|
||||
cancelHandler(e);
|
||||
}
|
||||
};
|
||||
|
||||
if (!this.div_) {
|
||||
|
||||
this.div_ = document.createElement("div");
|
||||
|
||||
this.setBoxStyle_();
|
||||
|
||||
if (typeof this.content_.nodeType === "undefined") {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
|
||||
} else {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_();
|
||||
this.div_.appendChild(this.content_);
|
||||
}
|
||||
|
||||
// Add the InfoBox DIV to the DOM
|
||||
this.getPanes()[this.pane_].appendChild(this.div_);
|
||||
|
||||
this.addClickHandler_();
|
||||
|
||||
if (this.div_.style.width) {
|
||||
|
||||
this.fixedWidthSet_ = true;
|
||||
|
||||
} else {
|
||||
|
||||
if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
|
||||
|
||||
this.div_.style.width = this.maxWidth_;
|
||||
this.div_.style.overflow = "auto";
|
||||
this.fixedWidthSet_ = true;
|
||||
|
||||
} else { // The following code is needed to overcome problems with MSIE
|
||||
|
||||
bw = this.getBoxWidths_();
|
||||
|
||||
this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
|
||||
this.fixedWidthSet_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.panBox_(this.disableAutoPan_);
|
||||
|
||||
if (!this.enableEventPropagation_) {
|
||||
|
||||
// Cancel event propagation.
|
||||
//
|
||||
this.eventListener1_ = google.maps.event.addDomListener(this.div_, "mousedown", cancelHandler);
|
||||
this.eventListener2_ = google.maps.event.addDomListener(this.div_, "click", cancelHandler);
|
||||
this.eventListener3_ = google.maps.event.addDomListener(this.div_, "dblclick", cancelHandler);
|
||||
this.eventListener4_ = google.maps.event.addDomListener(this.div_, "mouseover", function (e) {
|
||||
this.style.cursor = "default";
|
||||
});
|
||||
}
|
||||
|
||||
this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
|
||||
|
||||
/**
|
||||
* This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
|
||||
* @name InfoBox#domready
|
||||
* @event
|
||||
*/
|
||||
google.maps.event.trigger(this, "domready");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the HTML <IMG> tag for the close box.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.getCloseBoxImg_ = function () {
|
||||
|
||||
var img = "";
|
||||
|
||||
if (this.closeBoxURL_ !== "") {
|
||||
|
||||
img = "<img";
|
||||
img += " src='" + this.closeBoxURL_ + "'";
|
||||
img += " align=right"; // Do this because Opera chokes on style='float: right;'
|
||||
img += " style='";
|
||||
img += " position: relative;"; // Required by MSIE
|
||||
img += " cursor: pointer;";
|
||||
img += " margin: " + this.closeBoxMargin_ + ";";
|
||||
img += "'>";
|
||||
}
|
||||
|
||||
return img;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the click handler to the InfoBox close box.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.addClickHandler_ = function () {
|
||||
|
||||
var closeBox;
|
||||
|
||||
if (this.closeBoxURL_ !== "") {
|
||||
|
||||
closeBox = this.div_.firstChild;
|
||||
this.closeListener_ = google.maps.event.addDomListener(closeBox, 'click', this.getCloseClickHandler_());
|
||||
|
||||
} else {
|
||||
|
||||
this.closeListener_ = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the function to call when the user clicks the close box of an InfoBox.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.getCloseClickHandler_ = function () {
|
||||
|
||||
var me = this;
|
||||
|
||||
return function (e) {
|
||||
|
||||
// 1.0.3 fix: Always prevent propagation of a close box click to the map:
|
||||
e.cancelBubble = true;
|
||||
|
||||
if (e.stopPropagation) {
|
||||
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
me.close();
|
||||
|
||||
/**
|
||||
* This event is fired when the InfoBox's close box is clicked.
|
||||
* @name InfoBox#closeclick
|
||||
* @event
|
||||
*/
|
||||
google.maps.event.trigger(me, "closeclick");
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Pans the map so that the InfoBox appears entirely within the map's visible area.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.panBox_ = function (disablePan) {
|
||||
|
||||
var map;
|
||||
var bounds;
|
||||
var xOffset = 0, yOffset = 0;
|
||||
|
||||
if (!disablePan) {
|
||||
|
||||
map = this.getMap();
|
||||
|
||||
if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
|
||||
|
||||
if (!map.getBounds().contains(this.position_)) {
|
||||
// Marker not in visible area of map, so set center
|
||||
// of map to the marker position first.
|
||||
map.setCenter(this.position_);
|
||||
}
|
||||
|
||||
bounds = map.getBounds();
|
||||
|
||||
var mapDiv = map.getDiv();
|
||||
var mapWidth = mapDiv.offsetWidth;
|
||||
var mapHeight = mapDiv.offsetHeight;
|
||||
var iwOffsetX = this.pixelOffset_.width;
|
||||
var iwOffsetY = this.pixelOffset_.height;
|
||||
var iwWidth = this.div_.offsetWidth;
|
||||
var iwHeight = this.div_.offsetHeight;
|
||||
var padX = this.infoBoxClearance_.width;
|
||||
var padY = this.infoBoxClearance_.height;
|
||||
var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
|
||||
|
||||
if (pixPosition.x < (-iwOffsetX + padX)) {
|
||||
xOffset = pixPosition.x + iwOffsetX - padX;
|
||||
} else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
|
||||
xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
|
||||
}
|
||||
if (this.alignBottom_) {
|
||||
if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
|
||||
yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
|
||||
} else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
|
||||
yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
|
||||
}
|
||||
} else {
|
||||
if (pixPosition.y < (-iwOffsetY + padY)) {
|
||||
yOffset = pixPosition.y + iwOffsetY - padY;
|
||||
} else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
|
||||
yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(xOffset === 0 && yOffset === 0)) {
|
||||
|
||||
// Move the map to the shifted center.
|
||||
//
|
||||
var c = map.getCenter();
|
||||
map.panBy(xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the style of the InfoBox by setting the style sheet and applying
|
||||
* other specific styles requested.
|
||||
* @private
|
||||
*/
|
||||
InfoBox.prototype.setBoxStyle_ = function () {
|
||||
|
||||
var i, boxStyle;
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
// Apply style values from the style sheet defined in the boxClass parameter:
|
||||
this.div_.className = this.boxClass_;
|
||||
|
||||
// Clear existing inline style values:
|
||||
this.div_.style.cssText = "";
|
||||
|
||||
// Apply style values defined in the boxStyle parameter:
|
||||
boxStyle = this.boxStyle_;
|
||||
for (i in boxStyle) {
|
||||
|
||||
if (boxStyle.hasOwnProperty(i)) {
|
||||
|
||||
this.div_.style[i] = boxStyle[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Fix up opacity style for benefit of MSIE:
|
||||
//
|
||||
if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
|
||||
|
||||
this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
|
||||
}
|
||||
|
||||
// Apply required styles:
|
||||
//
|
||||
this.div_.style.position = "absolute";
|
||||
this.div_.style.visibility = 'hidden';
|
||||
if (this.zIndex_ !== null) {
|
||||
|
||||
this.div_.style.zIndex = this.zIndex_;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the widths of the borders of the InfoBox.
|
||||
* @private
|
||||
* @return {Object} widths object (top, bottom left, right)
|
||||
*/
|
||||
InfoBox.prototype.getBoxWidths_ = function () {
|
||||
|
||||
var computedStyle;
|
||||
var bw = {top: 0, bottom: 0, left: 0, right: 0};
|
||||
var box = this.div_;
|
||||
|
||||
if (document.defaultView && document.defaultView.getComputedStyle) {
|
||||
|
||||
computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
|
||||
|
||||
if (computedStyle) {
|
||||
|
||||
// The computed styles are always in pixel units (good!)
|
||||
bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
|
||||
bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
|
||||
bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
|
||||
bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
|
||||
}
|
||||
|
||||
} else if (document.documentElement.currentStyle) { // MSIE
|
||||
|
||||
if (box.currentStyle) {
|
||||
|
||||
// The current styles may not be in pixel units, but assume they are (bad!)
|
||||
bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
|
||||
bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
|
||||
bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
|
||||
bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
|
||||
}
|
||||
}
|
||||
|
||||
return bw;
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoked when <tt>close</tt> is called. Do not call it directly.
|
||||
*/
|
||||
InfoBox.prototype.onRemove = function () {
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
this.div_.parentNode.removeChild(this.div_);
|
||||
this.div_ = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws the InfoBox based on the current map projection and zoom level.
|
||||
*/
|
||||
InfoBox.prototype.draw = function () {
|
||||
|
||||
this.createInfoBoxDiv_();
|
||||
|
||||
var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
|
||||
|
||||
this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
|
||||
|
||||
if (this.alignBottom_) {
|
||||
this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
|
||||
} else {
|
||||
this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
|
||||
}
|
||||
|
||||
if (this.isHidden_) {
|
||||
|
||||
this.div_.style.visibility = 'hidden';
|
||||
|
||||
} else {
|
||||
|
||||
this.div_.style.visibility = "visible";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the options for the InfoBox. Note that changes to the <tt>maxWidth</tt>,
|
||||
* <tt>closeBoxMargin</tt>, <tt>closeBoxURL</tt>, and <tt>enableEventPropagation</tt>
|
||||
* properties have no affect until the current InfoBox is <tt>close</tt>d and a new one
|
||||
* is <tt>open</tt>ed.
|
||||
* @param {InfoBoxOptions} opt_opts
|
||||
*/
|
||||
InfoBox.prototype.setOptions = function (opt_opts) {
|
||||
if (typeof opt_opts.boxClass !== "undefined") { // Must be first
|
||||
|
||||
this.boxClass_ = opt_opts.boxClass;
|
||||
this.setBoxStyle_();
|
||||
}
|
||||
if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
|
||||
|
||||
this.boxStyle_ = opt_opts.boxStyle;
|
||||
this.setBoxStyle_();
|
||||
}
|
||||
if (typeof opt_opts.content !== "undefined") {
|
||||
|
||||
this.setContent(opt_opts.content);
|
||||
}
|
||||
if (typeof opt_opts.disableAutoPan !== "undefined") {
|
||||
|
||||
this.disableAutoPan_ = opt_opts.disableAutoPan;
|
||||
}
|
||||
if (typeof opt_opts.maxWidth !== "undefined") {
|
||||
|
||||
this.maxWidth_ = opt_opts.maxWidth;
|
||||
}
|
||||
if (typeof opt_opts.pixelOffset !== "undefined") {
|
||||
|
||||
this.pixelOffset_ = opt_opts.pixelOffset;
|
||||
}
|
||||
if (typeof opt_opts.alignBottom !== "undefined") {
|
||||
|
||||
this.alignBottom_ = opt_opts.alignBottom;
|
||||
}
|
||||
if (typeof opt_opts.position !== "undefined") {
|
||||
|
||||
this.setPosition(opt_opts.position);
|
||||
}
|
||||
if (typeof opt_opts.zIndex !== "undefined") {
|
||||
|
||||
this.setZIndex(opt_opts.zIndex);
|
||||
}
|
||||
if (typeof opt_opts.closeBoxMargin !== "undefined") {
|
||||
|
||||
this.closeBoxMargin_ = opt_opts.closeBoxMargin;
|
||||
}
|
||||
if (typeof opt_opts.closeBoxURL !== "undefined") {
|
||||
|
||||
this.closeBoxURL_ = opt_opts.closeBoxURL;
|
||||
}
|
||||
if (typeof opt_opts.infoBoxClearance !== "undefined") {
|
||||
|
||||
this.infoBoxClearance_ = opt_opts.infoBoxClearance;
|
||||
}
|
||||
if (typeof opt_opts.isHidden !== "undefined") {
|
||||
|
||||
this.isHidden_ = opt_opts.isHidden;
|
||||
}
|
||||
if (typeof opt_opts.enableEventPropagation !== "undefined") {
|
||||
|
||||
this.enableEventPropagation_ = opt_opts.enableEventPropagation;
|
||||
}
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
this.draw();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the content of the InfoBox.
|
||||
* The content can be plain text or an HTML DOM node.
|
||||
* @param {string|Node} content
|
||||
*/
|
||||
InfoBox.prototype.setContent = function (content) {
|
||||
this.content_ = content;
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
if (this.closeListener_) {
|
||||
|
||||
google.maps.event.removeListener(this.closeListener_);
|
||||
this.closeListener_ = null;
|
||||
}
|
||||
|
||||
// Odd code required to make things work with MSIE.
|
||||
//
|
||||
if (!this.fixedWidthSet_) {
|
||||
|
||||
this.div_.style.width = "";
|
||||
}
|
||||
|
||||
if (typeof content.nodeType === "undefined") {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_() + content;
|
||||
} else {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_();
|
||||
this.div_.appendChild(content);
|
||||
}
|
||||
|
||||
// Perverse code required to make things work with MSIE.
|
||||
// (Ensures the close box does, in fact, float to the right.)
|
||||
//
|
||||
if (!this.fixedWidthSet_) {
|
||||
this.div_.style.width = this.div_.offsetWidth + "px";
|
||||
if (typeof content.nodeType === "undefined") {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_() + content;
|
||||
} else {
|
||||
this.div_.innerHTML = this.getCloseBoxImg_();
|
||||
this.div_.appendChild(content);
|
||||
}
|
||||
}
|
||||
|
||||
this.addClickHandler_();
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired when the content of the InfoBox changes.
|
||||
* @name InfoBox#content_changed
|
||||
* @event
|
||||
*/
|
||||
google.maps.event.trigger(this, "content_changed");
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the geographic location of the InfoBox.
|
||||
* @param {LatLng} latlng
|
||||
*/
|
||||
InfoBox.prototype.setPosition = function (latlng) {
|
||||
|
||||
this.position_ = latlng;
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
this.draw();
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired when the position of the InfoBox changes.
|
||||
* @name InfoBox#position_changed
|
||||
* @event
|
||||
*/
|
||||
google.maps.event.trigger(this, "position_changed");
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the zIndex style for the InfoBox.
|
||||
* @param {number} index
|
||||
*/
|
||||
InfoBox.prototype.setZIndex = function (index) {
|
||||
|
||||
this.zIndex_ = index;
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
this.div_.style.zIndex = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired when the zIndex of the InfoBox changes.
|
||||
* @name InfoBox#zindex_changed
|
||||
* @event
|
||||
*/
|
||||
google.maps.event.trigger(this, "zindex_changed");
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the content of the InfoBox.
|
||||
* @returns {string}
|
||||
*/
|
||||
InfoBox.prototype.getContent = function () {
|
||||
|
||||
return this.content_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the geographic location of the InfoBox.
|
||||
* @returns {LatLng}
|
||||
*/
|
||||
InfoBox.prototype.getPosition = function () {
|
||||
|
||||
return this.position_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the zIndex for the InfoBox.
|
||||
* @returns {number}
|
||||
*/
|
||||
InfoBox.prototype.getZIndex = function () {
|
||||
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the InfoBox.
|
||||
*/
|
||||
InfoBox.prototype.show = function () {
|
||||
|
||||
this.isHidden_ = false;
|
||||
if (this.div_) {
|
||||
this.div_.style.visibility = "visible";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the InfoBox.
|
||||
*/
|
||||
InfoBox.prototype.hide = function () {
|
||||
|
||||
this.isHidden_ = true;
|
||||
if (this.div_) {
|
||||
this.div_.style.visibility = "hidden";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the InfoBox to the specified map or Street View panorama. If <tt>anchor</tt>
|
||||
* (usually a <tt>google.maps.Marker</tt>) is specified, the position
|
||||
* of the InfoBox is set to the position of the <tt>anchor</tt>. If the
|
||||
* anchor is dragged to a new location, the InfoBox moves as well.
|
||||
* @param {Map|StreetViewPanorama} map
|
||||
* @param {MVCObject} [anchor]
|
||||
*/
|
||||
InfoBox.prototype.open = function (map, anchor) {
|
||||
|
||||
var me = this;
|
||||
|
||||
if (anchor) {
|
||||
|
||||
this.position_ = anchor.getPosition();
|
||||
this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function () {
|
||||
me.setPosition(this.getPosition());
|
||||
});
|
||||
}
|
||||
|
||||
this.setMap(map);
|
||||
|
||||
if (this.div_) {
|
||||
|
||||
this.panBox_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the InfoBox from the map.
|
||||
*/
|
||||
InfoBox.prototype.close = function () {
|
||||
|
||||
if (this.closeListener_) {
|
||||
|
||||
google.maps.event.removeListener(this.closeListener_);
|
||||
this.closeListener_ = null;
|
||||
}
|
||||
|
||||
if (this.eventListener1_) {
|
||||
|
||||
google.maps.event.removeListener(this.eventListener1_);
|
||||
google.maps.event.removeListener(this.eventListener2_);
|
||||
google.maps.event.removeListener(this.eventListener3_);
|
||||
google.maps.event.removeListener(this.eventListener4_);
|
||||
this.eventListener1_ = null;
|
||||
this.eventListener2_ = null;
|
||||
this.eventListener3_ = null;
|
||||
this.eventListener4_ = null;
|
||||
}
|
||||
|
||||
if (this.moveListener_) {
|
||||
|
||||
google.maps.event.removeListener(this.moveListener_);
|
||||
this.moveListener_ = null;
|
||||
}
|
||||
|
||||
if (this.contextListener_) {
|
||||
|
||||
google.maps.event.removeListener(this.contextListener_);
|
||||
this.contextListener_ = null;
|
||||
}
|
||||
|
||||
this.setMap(null);
|
||||
};
|
||||
83
assets/js/jquery.fitvids.js
Executable file
83
assets/js/jquery.fitvids.js
Executable file
@@ -0,0 +1,83 @@
|
||||
/*global jQuery */
|
||||
/*jshint browser:true */
|
||||
/*!
|
||||
* FitVids 1.1
|
||||
*
|
||||
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
|
||||
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
|
||||
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
|
||||
*
|
||||
*/
|
||||
|
||||
;(function( $ ){
|
||||
|
||||
'use strict';
|
||||
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null,
|
||||
ignore: null
|
||||
};
|
||||
|
||||
if(!document.getElementById('fit-vids-style')) {
|
||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||
head.appendChild(div.childNodes[1]);
|
||||
}
|
||||
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
'iframe[src*="youtube-nocookie.com"]',
|
||||
'iframe[src*="kickstarter.com"][src*="video.html"]',
|
||||
'object',
|
||||
'embed'
|
||||
];
|
||||
|
||||
if (settings.customSelector) {
|
||||
selectors.push(settings.customSelector);
|
||||
}
|
||||
|
||||
var ignoreList = '.fitvidsignore';
|
||||
|
||||
if(settings.ignore) {
|
||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||
}
|
||||
|
||||
var $allVideos = $(this).find(selectors.join(','));
|
||||
$allVideos = $allVideos.not('object object'); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
|
||||
|
||||
$allVideos.each(function(count){
|
||||
var $this = $(this);
|
||||
if($this.parents(ignoreList).length > 0) {
|
||||
return; // Disable FitVids on this video.
|
||||
}
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
||||
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
|
||||
{
|
||||
$this.attr('height', 9);
|
||||
$this.attr('width', 16);
|
||||
}
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if(!$this.attr('id')){
|
||||
var videoID = 'fitvid' + count;
|
||||
$this.attr('id', videoID);
|
||||
}
|
||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
|
||||
$this.removeAttr('height').removeAttr('width');
|
||||
});
|
||||
});
|
||||
};
|
||||
// Works with either jQuery or Zepto
|
||||
})( window.jQuery || window.Zepto );
|
||||
1642
assets/js/markerclusterer.js
Executable file
1642
assets/js/markerclusterer.js
Executable file
File diff suppressed because it is too large
Load Diff
51
assets/js/mortgage.js
Executable file
51
assets/js/mortgage.js
Executable file
@@ -0,0 +1,51 @@
|
||||
(function ($) {
|
||||
'use strict'
|
||||
$(document).ready(function ($) {
|
||||
if (typeof opalestate_mortgage !== 'undefined') {
|
||||
var currency = opalestate_mortgage.currency
|
||||
var loan_amount_text = opalestate_mortgage.loan_amount_text
|
||||
var your_payment_text = opalestate_mortgage.your_payment_text
|
||||
|
||||
$('.opalestate-mortgage-form input').change(function (e) {
|
||||
e.preventDefault()
|
||||
var $el = $(this),
|
||||
$widget = $el.closest('.opalestate-mortgage-widget-wrap')
|
||||
|
||||
var sale_price = $widget.find('input[name="sale_price"]').val()
|
||||
var precent_down = $widget.find('input[name="deposit"]').val()
|
||||
var years = parseInt($widget.find('input[name="years"]').val(), 10)
|
||||
var interest_rate = parseFloat($widget.find('input[name="interest_rate"]').val(), 10) / 100
|
||||
|
||||
var interest_rate_month = interest_rate / 12
|
||||
var number_of_payments_month = years * 12
|
||||
|
||||
var loan_amount = sale_price - precent_down
|
||||
var monthly_payment = parseFloat(
|
||||
(loan_amount * interest_rate_month) / (1 - Math.pow(1 + interest_rate_month, -number_of_payments_month)))
|
||||
.toFixed(2)
|
||||
|
||||
if (monthly_payment === 'NaN') {
|
||||
monthly_payment = 0
|
||||
}
|
||||
|
||||
var total = parseFloat(precent_down) + parseFloat(monthly_payment * number_of_payments_month)
|
||||
var price_percent = loan_amount / total * 100
|
||||
var deposit_percent = precent_down / total * 100
|
||||
|
||||
$widget.find('.opalestate-monthly-value').html(currency + monthly_payment)
|
||||
|
||||
$widget.find('.opalestate-loan-amount-value').html(currency + loan_amount)
|
||||
|
||||
$widget.find('.opalestate-mortgage-chart-svg').html(
|
||||
'<svg viewBox=\'0 0 64 64\' class=\'pie\'>' +
|
||||
'<circle r=\'25%\' cx=\'50%\' cy=\'50%\' style=\'stroke-dasharray: ' + price_percent + ' 100\'>' +
|
||||
'</circle>' +
|
||||
'<circle r=\'25%\' cx=\'50%\' cy=\'50%\' style=\'stroke-dasharray: ' + deposit_percent + ' 100;' +
|
||||
' stroke:#2f73e9; stroke-dashoffset: -' + price_percent + ';animation-delay: 0.25s\'>' +
|
||||
'</circle>' +
|
||||
'</svg>'
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
})(jQuery)
|
||||
340
assets/js/nouislider.min.js
vendored
Executable file
340
assets/js/nouislider.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
573
assets/js/opalestate.js
Executable file
573
assets/js/opalestate.js
Executable file
@@ -0,0 +1,573 @@
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$( '#show-user-sidebar-btn' ).click( function () {
|
||||
$( 'body' ).toggleClass( 'active' );
|
||||
} );
|
||||
|
||||
$( '.more-options-label, .form-item--types .group-item, .cmb2-checkbox-list.cmb2-list li' ).each( function () {
|
||||
$( this ).append( '<span class="custom-checkbox-label"></span>' );
|
||||
} );
|
||||
|
||||
$( '.opalestate-tooltip' ).each( function () {
|
||||
if ( $( this ).tooltipster ) {
|
||||
$( this ).tooltipster( {
|
||||
side: [ 'bottom', 'top', 'right', 'left' ]
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
/***/
|
||||
|
||||
// Social login.
|
||||
$( '.js-opal-google-login' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: {
|
||||
'action': 'opalestate_ajax_redirect_google_login_link'
|
||||
},
|
||||
success: function ( results ) {
|
||||
window.location.href = results.data;
|
||||
},
|
||||
error: function ( errorThrown ) {
|
||||
// TODO:
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
$( '.js-opal-facebook-login' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: {
|
||||
'action': 'opalestate_ajax_redirect_facebook_login_link'
|
||||
},
|
||||
success: function ( results ) {
|
||||
window.location.href = results.data;
|
||||
},
|
||||
error: function ( errorThrown ) {
|
||||
// TODO:
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
if ( $( '.opalestate-swiper-play' ).length > 0 ) {
|
||||
var play_swiper_sliders = function () {
|
||||
if ( $( '.opalestate-swiper-play' ).length > 0 ) {
|
||||
$( '.opalestate-swiper-play' ).each( function () {
|
||||
var option = $( this ).data( 'swiper' );
|
||||
|
||||
if ( option ) {
|
||||
option = $.extend( {
|
||||
navigation: {
|
||||
nextEl: '.swiper-button-next',
|
||||
prevEl: '.swiper-button-prev'
|
||||
},
|
||||
slidesPerView: 3,
|
||||
spaceBetween: 30,
|
||||
loop: true,
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
breakpoints: {
|
||||
1024: {
|
||||
slidesPerView: 2,
|
||||
spaceBetween: 30
|
||||
},
|
||||
768: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
},
|
||||
640: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
},
|
||||
320: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
}
|
||||
}
|
||||
}, option );
|
||||
|
||||
if ( option.thumbnails_nav ) {
|
||||
var ioption = $( option.thumbnails_nav ).data( 'swiper' );
|
||||
|
||||
ioption.breakpoint = {
|
||||
1024: {
|
||||
slidesPerView: 2,
|
||||
spaceBetween: 30
|
||||
},
|
||||
768: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
},
|
||||
640: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
},
|
||||
320: {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 10
|
||||
}
|
||||
};
|
||||
|
||||
var iswiper = new Swiper( option.thumbnails_nav, ioption );
|
||||
|
||||
option.thumbs = {
|
||||
swiper: iswiper
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
var swiper = new Swiper( this, option );
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
||||
play_swiper_sliders();
|
||||
$( document ).ajaxComplete( function () {
|
||||
play_swiper_sliders();
|
||||
} );
|
||||
}
|
||||
|
||||
////////
|
||||
$( '.opalestate-scroll-elements a' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( $( $( this ).attr( 'href' ) ).length ) {
|
||||
$( '.opalestate-scroll-elements a' ).removeClass( 'active' );
|
||||
$( this ).addClass( 'active' );
|
||||
|
||||
$( 'html, body' ).animate( {
|
||||
scrollTop: $( $( this ).attr( 'href' ) ).offset().top - 80,
|
||||
},
|
||||
500,
|
||||
'linear'
|
||||
);
|
||||
}
|
||||
} );
|
||||
var header = $( '.keep-top-bars' );
|
||||
$( window ).scroll( function () {
|
||||
var scroll = $( window ).scrollTop();
|
||||
if ( scroll >= window.innerHeight ) {
|
||||
header.addClass( 'floating-keep-top' );
|
||||
} else {
|
||||
header.removeClass( 'floating-keep-top' );
|
||||
}
|
||||
} );
|
||||
|
||||
////
|
||||
|
||||
////
|
||||
$( '.opalestate-gallery' ).each( function () { // the containers for all your galleries
|
||||
$( this ).magnificPopup( {
|
||||
delegate: 'a', // the selector for gallery item
|
||||
type: 'image',
|
||||
gallery: {
|
||||
enabled: true
|
||||
}
|
||||
} );
|
||||
var $_this = this;
|
||||
$( '.show-first-photo' ).click( function () {
|
||||
$( 'a', $_this ).first().click();
|
||||
} );
|
||||
$( '.show-last-photo' ).click( function () {
|
||||
$( 'a', $_this ).last().click();
|
||||
} );
|
||||
} );
|
||||
|
||||
//////
|
||||
$( '.opalestate_rating' ).each( function () {
|
||||
$( this )
|
||||
.hide()
|
||||
.before(
|
||||
'<p class="opalestate-stars stars">\
|
||||
<span>\
|
||||
<a class="star-1" href="#">1</a>\
|
||||
<a class="star-2" href="#">2</a>\
|
||||
<a class="star-3" href="#">3</a>\
|
||||
<a class="star-4" href="#">4</a>\
|
||||
<a class="star-5" href="#">5</a>\
|
||||
</span>\
|
||||
</p>'
|
||||
);
|
||||
} );
|
||||
|
||||
$( 'body' )
|
||||
// Star ratings for comments
|
||||
.on( 'click', '.comment-form-rating p.opalestate-stars a', function () {
|
||||
var $star = $( this ),
|
||||
$rating = $( this ).closest( '.comment-form-rating' ).find( '.opalestate_rating' ),
|
||||
$container = $( this ).closest( '.stars' );
|
||||
|
||||
$rating.val( $star.text() );
|
||||
$star.siblings( 'a' ).removeClass( 'active' );
|
||||
$star.addClass( 'active' );
|
||||
$container.addClass( 'selected' );
|
||||
|
||||
return false;
|
||||
} )
|
||||
.on( 'click', '#respond #submit', function () {
|
||||
var $rating = $( this ).closest( '#respond' ).find( '.opalestate_rating' );
|
||||
var rating = $rating.val();
|
||||
|
||||
if ( $rating.length > 0 && !rating ) {
|
||||
window.alert( 'Require rating!' );
|
||||
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
// sticky ////
|
||||
$( '.opalestate-sticky-column' ).stick_in_parent();
|
||||
|
||||
////
|
||||
$( '.input-group-number' ).each( function () {
|
||||
var _input = $( 'input', this );
|
||||
if ( parseInt( _input.val() ) <= 0 ) {
|
||||
_input.val( 1 );
|
||||
}
|
||||
$( '.btn-actions > span', this ).click( function () {
|
||||
|
||||
var _check = function () {
|
||||
return parseInt( _input.val() ) <= 0 ? 1 : parseInt( _input.val() );
|
||||
};
|
||||
|
||||
if ( $( this ).hasClass( 'btn-plus' ) ) {
|
||||
_val = _check() + 1;
|
||||
} else {
|
||||
_val = _check() - 1;
|
||||
}
|
||||
|
||||
_input.val( _val );
|
||||
_input.change();
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
$( 'select.form-control , .cmb2-wrap select, .form-row select' ).select2( {
|
||||
width: '100%',
|
||||
minimumResultsForSearch: -1
|
||||
} );
|
||||
|
||||
function opalCollapse() {
|
||||
$( '.opal-collapse-button' ).on( 'click', function () {
|
||||
var $el = $( this ),
|
||||
data = $el.data( 'collapse' ),
|
||||
$el_data = $( data ),
|
||||
speed = 250;
|
||||
|
||||
if ( $el.data( 'speed' ) && $el.data( 'speed' ) > 0 ) {
|
||||
speed = $el.data( 'speed' );
|
||||
}
|
||||
|
||||
if ( $el_data.is( ':visible' ) ) {
|
||||
$el_data.slideUp( speed );
|
||||
$el.removeClass( 'show' );
|
||||
$el_data.removeClass( 'show' );
|
||||
} else {
|
||||
$el.addClass( 'show' );
|
||||
$el_data.addClass( 'show' );
|
||||
$el_data.slideDown( speed );
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
opalCollapse();
|
||||
|
||||
/************************/
|
||||
|
||||
$( '.opalestate-tab .tab-item' ).click( function ( event ) {
|
||||
event.preventDefault();
|
||||
$( this ).parent().find( ' .tab-item' ).removeClass( 'active' );
|
||||
$( this ).addClass( 'active' );
|
||||
|
||||
$( $( this ).attr( 'href' ) ).parent().children( '.opalestate-tab-content' ).removeClass( 'active' );
|
||||
$( $( this ).attr( 'href' ) ).addClass( 'active' );
|
||||
} );
|
||||
|
||||
$( '.opalestate-tab' ).each( function () {
|
||||
$( this ).find( '.tab-item' ).first().click();
|
||||
} );
|
||||
|
||||
/**
|
||||
* Click to show body popup
|
||||
*/
|
||||
$( 'body' ).delegate( '.opalestate-popup .popup-head', 'click', function () {
|
||||
var $this = $( this ).parent( '.opalestate-popup' );
|
||||
$( '.popup-head', $this ).click( function () {
|
||||
$( '.opalestate-popup.active' ).removeClass( 'active' );
|
||||
$this.toggleClass( 'active' );
|
||||
} );
|
||||
$( '.popup-close', $this ).click( function () {
|
||||
$( '.opalestate-popup' ).removeClass( 'active' );
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Login form
|
||||
**/
|
||||
$( 'body' ).delegate( '.opalestate-mfp-popup form.opalestate-login-form', 'submit', function () {
|
||||
|
||||
var $form = $( this );
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
dataType: 'json',
|
||||
data: $( this ).serialize() + '&ajax=1&action=opalestate_login_form', // serializes the form's elements.
|
||||
success: function ( data ) {
|
||||
if ( data.status == true ) {
|
||||
if ( data.redirect ) {
|
||||
window.location.href = data.redirect;
|
||||
}
|
||||
}
|
||||
if ( data.message ) {
|
||||
$form.find( '.opalestate-notice' ).remove();
|
||||
$form.prepend( data.message );
|
||||
}
|
||||
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
|
||||
/**
|
||||
* Login form
|
||||
**/
|
||||
$( 'body' ).delegate( '.opalestate-mfp-popup form.opalestate-register-form', 'submit', function () {
|
||||
|
||||
var $form = $( this );
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
dataType: 'json',
|
||||
data: $( this ).serialize() + '&ajax=1&action=opalestate_register_form', // serializes the form's elements.
|
||||
success: function ( data ) {
|
||||
if ( data.status == true ) {
|
||||
if ( data.redirect ) {
|
||||
window.location.href = data.redirect;
|
||||
}
|
||||
}
|
||||
if ( data.message ) {
|
||||
$form.find( '.opalestate-notice' ).remove();
|
||||
$form.prepend( data.message );
|
||||
}
|
||||
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
/**
|
||||
* AJAX ACTION
|
||||
*/
|
||||
|
||||
$( '#opalestate_user_frontchangepass' ).submit( function ( e ) {
|
||||
var $this = $( this );
|
||||
$( '.alert', $this ).remove();
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
dataType: 'json',
|
||||
data: $( this ).serialize() + '&action=opalestate_save_changepass', // serializes the form's elements.
|
||||
success: function ( data ) {
|
||||
if ( data.status == false ) {
|
||||
$this.find( '.form-table' )
|
||||
.prepend( $( '<p class="alert alert-danger">' + data.message + '</p>' ) );
|
||||
} else {
|
||||
$this.find( '.form-table' ).prepend( $( '<p class="alert alert-info">' + data.message + '</p>' ) );
|
||||
$( 'input[type="text"]', $this ).val( '' );
|
||||
setTimeout( function () {
|
||||
$( '.alert', $this ).remove();
|
||||
}, 1000 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||
} );
|
||||
|
||||
$( 'body' ).delegate( '.opalestate-popup-button', 'click', function () {
|
||||
var $target = $( this ).data( 'target' );
|
||||
$.magnificPopup.open( {
|
||||
items: {
|
||||
src: $target
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
|
||||
// open login form
|
||||
$( document ).on( 'opalestate:login', function () {
|
||||
if ( $( '#opalestate-user-form-popup' ) ) {
|
||||
$.magnificPopup.open( {
|
||||
items: {
|
||||
src: '#opalestate-user-form-popup'
|
||||
},
|
||||
mainClass: 'mfp-with-zoom', // this class is for CSS animation below
|
||||
zoom: {
|
||||
enabled: true
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'body' ).delegate( '.opalestate-need-login', 'click', function () {
|
||||
$( document ).trigger( 'opalestate:login', [ true ] );
|
||||
return false;
|
||||
} );
|
||||
//// ajax favorite
|
||||
$( 'body' ).delegate( '.property-toggle-favorite', 'click', function () {
|
||||
var $this = $( this );
|
||||
if ( $( this ).hasClass( 'opalestate-need-login' ) ) {
|
||||
return;
|
||||
}
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: 'property_id=' + $( this ).data( 'property-id' ) + '&action=opalestate_toggle_status', // serializes
|
||||
// the form's
|
||||
// elements.
|
||||
success: function ( data ) {
|
||||
if ( data ) {
|
||||
$this.replaceWith( $( data ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
if ( $( '.opalestate-datepicker' ).length > 0 ) {
|
||||
$( '.opalestate-datepicker' ).datepicker( { minDate: 0 } );
|
||||
}
|
||||
//
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$( '.list-property-status li' ).click( function () {
|
||||
$( '.opalestate-search-form [name=status]' ).val( $( this ).data( 'id' ) );
|
||||
$( '.list-property-status li' ).removeClass( 'active' );
|
||||
$( this ).addClass( 'active' );
|
||||
} );
|
||||
if ( $( '.opalestate-search-form [name=status]' ).val() > 0 ) {
|
||||
var id = $( '.opalestate-search-form [name=status]' ).val();
|
||||
$( '.list-property-status li' ).removeClass( 'active' );
|
||||
$( '.list-property-status [data-id=' + id + ']' ).addClass( 'active' );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
$( '.opal-slide-ranger' ).each( function () {
|
||||
var _this = this;
|
||||
var unit = $( this ).data( 'unit' );
|
||||
var decimals = $( this ).data( 'decimals' );
|
||||
var min = $( '.slide-ranger-bar', this ).data( 'min' );
|
||||
var max = $( '.slide-ranger-bar', this ).data( 'max' );
|
||||
var mode = $( '.slide-ranger-bar', this ).data( 'mode' );
|
||||
var start = $( '.slide-ranger-bar', this ).data( 'start' );
|
||||
|
||||
var imin = $( '.slide-ranger-min-input', this ).val();
|
||||
var imax = $( '.slide-ranger-max-input', this ).val();
|
||||
var slider = $( '.slide-ranger-bar', this ).get( 0 );
|
||||
var unit_pos = $( this ).data( 'unitpos' );
|
||||
|
||||
var config_format = {
|
||||
decimals: decimals,
|
||||
thousand: ',',
|
||||
};
|
||||
|
||||
if ( unit_pos == 'prefix' ) {
|
||||
config_format.prefix = ' ' + unit + ' ';
|
||||
} else {
|
||||
config_format.postfix = ' ' + unit + ' ';
|
||||
}
|
||||
|
||||
var nummm = wNumb( config_format );
|
||||
var istart = [ imin, imax ];
|
||||
if ( mode && mode == 1 && start ) {
|
||||
istart = [ start ];
|
||||
}
|
||||
|
||||
noUiSlider.create( slider, {
|
||||
range: {
|
||||
'min': [ min ],
|
||||
'max': [ max ]
|
||||
},
|
||||
connect: true,
|
||||
start: istart,
|
||||
format: nummm,
|
||||
direction: opalesateJS.rtl == 'true' ? 'rtl' : 'ltr',
|
||||
|
||||
} );
|
||||
slider.noUiSlider.on( 'update', function ( values, handle ) {
|
||||
var val = values[ handle ];
|
||||
if ( handle == 0 ) {
|
||||
$( '.slide-ranger-min-label', _this ).text( val );
|
||||
$( '.slide-ranger-min-input', _this ).val( nummm.from( val ) );
|
||||
} else {
|
||||
$( '.slide-ranger-max-label', _this ).text( val );
|
||||
$( '.slide-ranger-max-input', _this ).val( nummm.from( val ) );
|
||||
}
|
||||
} );
|
||||
|
||||
slider.noUiSlider.on( 'end', function ( values, handle ) {
|
||||
var val = values[ handle ];
|
||||
if ( handle == 0 ) {
|
||||
$( '.slide-ranger-min-input', _this ).change();
|
||||
} else {
|
||||
$( '.slide-ranger-max-input', _this ).change();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
//////***Search Search **/
|
||||
$( 'body' ).delegate( '#opalestate-save-search-form', 'submit', function () {
|
||||
var params = window.location.search.substring( 1 );
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: 'params=' + encodeURIComponent( params ) + '&' + $( this ).serialize() +
|
||||
'&action=opalestate_ajx_save_search',
|
||||
success: function ( data ) {
|
||||
$( '#opalestate-save-search-form .alert' ).remove();
|
||||
$( '#opalestate-save-search-form input' ).val( '' );
|
||||
$( '#opalestate-save-search-form' )
|
||||
.append( '<div class="opalestate-message-notify msg-status-success" style="margin-top:20px">' +
|
||||
data.message + '</div>' );
|
||||
$( '#opalestate-save-search-form .alert' ).delay( 5000 ).queue( function () {
|
||||
$( '#opalestate-save-search-form .alert' ).remove();
|
||||
} );
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
|
||||
$( '.ajax-load-properties' ).delegate( '.pagination li', 'click', function () {
|
||||
var $content = $( this ).parents( '.ajax-load-properties' );
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: opalesateJS.ajaxurl,
|
||||
data: location.search.substr( 1 ) + '&action=get_agent_property&paged=' + $( this ).data( 'paged' ) +
|
||||
'&id=' + $content.data( 'id' ),
|
||||
success: function ( data ) {
|
||||
if ( data ) {
|
||||
$content.html( data );
|
||||
}
|
||||
}
|
||||
} );
|
||||
return false;
|
||||
} );
|
||||
|
||||
if ( $( '.opalestate-sticky' ).length > 0 ) {
|
||||
$( '.opalestate-sticky' ).each( function () {
|
||||
$( this ).stick_in_parent( $( this ).data() );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
Reference in New Issue
Block a user