From: Chuck Scott Date: Thu, 23 Jun 2016 18:17:56 +0000 (-0400) Subject: Updated event code to have automatic updates to the map location when entering an... X-Git-Tag: v1.2.11^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=44c42d4f0a856562ebf095ebefa79160540ffd96;p=WP-Plugins%2Fglm-member-db-events.git Updated event code to have automatic updates to the map location when entering an address for a new event until one of the following happen. * The event is submitted (will not auto update when editing later. * The user clicks the "Map Location Using Above Address" button * The user drags the map pointer to a new location. * "Update pointer" button is clicked to use specified lat/lon values. Also added more instructions on how to use the map below the "Update pointer" button. Tested and committed to code as HotFix --- diff --git a/index.php b/index.php index a822126..9a03a9c 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Events * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.2.10 + * Version: 1.2.11 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -20,7 +20,7 @@ * @package glmMembersDatabaseEventsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.2.10 + * @version 1.2.11 */ /* @@ -38,7 +38,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.10'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.11'); define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.18'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index b60e9a3..21a6d5b 100644 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -332,8 +332,19 @@ } // Function to initialize actions related to a specific location + var mapLocationAuto = new Array(1); // Flags for each location indicating whether the location should be doing auto map updates when entering the address function initLocation(locID) { + // Get lat and lon from the input fields + var glmLat = $('#glmLat_' + locID).val(); + var glmLng = $('#glmLng_' + locID).val(); + + // If Lat and Lon for this event are currently set to default, then set that location to mapLocationAuto true. + mapLocationAuto[locID] = false; + if (glmLat == {$settings.maps_default_lat} || glmLng == {$settings.maps_default_lon}) { + mapLocationAuto[locID] = true; + } + // Delete a location $('.delete-location').on( 'click', function() { locID = $(this).attr('data-id'); @@ -348,6 +359,9 @@ // Listen for changes in the lat/lon inputs $('.latLonRecenter').on('click', function() { + // Stop any automatic updates + mapLocationAuto[locID] = false; + locID = $(this).attr('data-id'); // Get lat and lon from the input fields @@ -982,6 +996,9 @@ // Listen for an end of drag event for the map marker google.maps.event.addListener(marker[locID],'dragend',function(event) { + // Stop any automatic updates + mapLocationAuto[locID] = false; + // Get the end postion glmLat = this.position.lat(); glmLng = this.position.lng(); @@ -996,9 +1013,21 @@ // When estimate location button is clicked, geocode using address $('#glm-estimate-location_' + locID).on('click', function() { + + // Stop any automatic updates + mapLocationAuto[locID] = false; + glmGeocode(locID); }); + // When an address is updated and mapLocationAuto is set for that locID, geocode using address + $('.location-address').on('change', function() { + locID = $(this).attr('data-id'); + if (mapLocationAuto[locID]) { + glmGeocode(locID); + } + }); + } function glmGeocode(locID) { @@ -1035,7 +1064,7 @@ // Otherwise tell the user. } else { - alert('Not able to estimate position from the current address.'); + alert('Not able to estimate map position from the current address.'); } }); diff --git a/views/admin/events/editLocation.html b/views/admin/events/editLocation.html index d3ba261..29b82a2 100644 --- a/views/admin/events/editLocation.html +++ b/views/admin/events/editLocation.html @@ -76,7 +76,7 @@ Address: - + @@ -85,7 +85,7 @@
Add a new City
- {foreach from=$loc.city.list item=v} {foreach from=$newLocation.fieldData.city.list item=v}