Skip to content

Instantly share code, notes, and snippets.

@sungraiz
sungraiz / submit-google-map.js
Created October 14, 2019 13:54
Fix for coordinates search
/**
* Javascript to handle google map for property submit page
*/
jQuery( function( $ ) {
'use strict';
var mapField = {};
(function(){
function remove_agents_from_dropdown( $hook ) {
if ( 'property' !== get_current_screen()->post_type ) {
return;
}
?>
<script>
window.addEventListener('load', function () {
let agentSelect = $("#REAL_HOMES_agents");
if (agentSelect.find("option").length > 3) {
$(window).on('load', function () {
let agentSelect = $("#agent-selectbox");
if (agentSelect.find("option").length > 3) {
for (let i = 0; i < 3; i++) {
agentSelect.find("option:first-child").remove();
}
agentSelect.select2("destroy");
agentSelect.select2();
}
});
form_submit.click( function( e ) {
let $inputs = $(document).find('#inspiry-additional-details-container input'),
$titleInputs = $(document).find('.inspiry-detail-title input'),
$valueInputs = $(document).find('.inspiry-detail-value input'),
$emptyTitleInputs = $titleInputs.filter(function(){ return !$(this).val(); }).length,
$emptyValueInputs = $valueInputs.filter(function(){ return !$(this).val(); }).length;
if ( $emptyTitleInputs !== $emptyValueInputs) {
e.preventDefault();