* 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
* @package glmMembersDatabaseEventsAddOn
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.2.10
+ * @version 1.2.11
*/
/*
* 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.
}
// 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');
// 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
// 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();
// 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) {
// 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.');
}
});
<tr>
<th>Address:</th>
<td>
- <input id="address_{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
+ <input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium location-address">
</td>
</tr>
<tr>
<!-- Add new city dialog -->
<div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
<!-- City Selection -->
- <select id="city_{$loc.id}" class="city-picklist" name="Loc{$loc.id}_city">
+ <select id="city_{$loc.id}" data-id="{$loc.id}" class="city-picklist location-address" name="Loc{$loc.id}_city">
<option value="0"></option>
{foreach from=$loc.city.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
<tr>
<th>State:</th>
<td>
- <select id="state_{$loc.id}" name="Loc{$loc.id}_state">
+ <select id="state_{$loc.id}" data-id="{$loc.id}" class="location-address" name="Loc{$loc.id}_state">
{foreach from=$loc.state.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name}
<tr>
<th>ZIP / Postal Code:</th>
<td>
- <input id="zip_{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
+ <input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium location-address">
</td>
</tr>
<tr>
<th>Country:</th>
<td>
- <select id="country_{$loc.id}" name="Loc{$loc.id}_country">
+ <select id="country_{$loc.id}" data-id="{$loc.id}" class="location-address" name="Loc{$loc.id}_country">
{foreach from=$loc.country.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name} {$v.value}
<b>Position:</b>
Lat <input id="glmLat_{$loc.id}" name="Loc{$loc.id}_lat" type="text" value="{$loc.lat}" class="glm-form-text-input-veryshort">
Lon <input id="glmLng_{$loc.id}" name="Loc{$loc.id}_lon" type="text" value="{$loc.lon}" class="glm-form-text-input-veryshort">
- <span data-id="{$loc.id}" class="button button-secondary latLonRecenter">Update pointer</span>
+ <span data-id="{$loc.id}" class="button button-secondary latLonRecenter">Update pointer</span><br>
+ You may drag the map marker to the exact location desired. Also consider selecting "Satellite" view to better locate the marker.
</p>
</p>
</td>
<tr>
<th>Address:</th>
<td>
- <input id="address_{ newLocID }" type="text" name="{ newLocID }_address" value="{$newLocation.fieldData.address}" class="glm-form-text-input-medium">
+ <input id="address_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_address" value="{$newLocation.fieldData.address}" class="glm-form-text-input-medium location-address">
</td>
</tr>
<tr>
<!-- Add new city dialog -->
<div data-id="{ newLocID }" class="button button-secondary glm-right new-city-button">Add a new City</div>
<!-- City Selection -->
- <select id="city_{ newLocID }" class="city-picklist" name="{ newLocID }_city">
+ <select id="city_{ newLocID }" data-id="{ newLocID }" class="city-picklist location-address" name="{ newLocID }_city">
<option value="0"></option>
{foreach from=$newLocation.fieldData.city.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
<tr>
<th>State:</th>
<td>
- <select id="state_{ newLocID }" name="{ newLocID }_state">
+ <select id="state_{ newLocID }" data-id="{ newLocID }" class="location-address" name="{ newLocID }_state">
{foreach from=$newLocation.fieldData.state.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name}
<tr>
<th>ZIP / Postal Code:</th>
<td>
- <input id="zip_{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium">
+ <input id="zip_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium location-address">
</td>
</tr>
<tr>
<th>Country:</th>
<td>
- <select id="country_{ newLocID }" name="{ newLocID }_country">
+ <select id="country_{ newLocID }" data-id="{ newLocID }" class="location-address" name="{ newLocID }_country">
{foreach from=$newLocation.fieldData.country.list item=v}
<option value="{$v.value}"{if $v.default} selected="selected"{/if}>
{$v.name} {$v.value}
<tr>
<th>Location:</th>
<td>
- <input id="glmLat_{ newLocID }" name="{ newLocID }_lat" type="hidden" value="{$newLocation.fieldData.lat}">
- <input id="glmLng_{ newLocID }" name="{ newLocID }_lon" type="hidden" value="{$newLocation.fieldData.lon}">
<!-- Only doing one event per location now.
<span class="glm-right"><a id="deleteLocation_{ newLocID }" data-id="{ newLocID }" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
-->
<div id="glm-estimate-location_{ newLocID }" class="button button-secondary">Map Location Using Address</div>
<p>
- locationMap_{ newLocID }
<div id="locationMap_{ newLocID }" class="glm-map-edit">(map loads here)</div>
<p>
<b>Position:</b>
- Lat <input id="glmLat_{ newLocID }" name="lat" type="text" value="{$newLocation.fieldData.lat}" class="glm-form-text-input-veryshort">
- Lon <input id="glmLng_{ newLocID }" name="lon" type="text" value="{$newLocation.fieldData.lon}" class="glm-form-text-input-veryshort">
- <span data-id="{ newLocID }" class="button button-secondary latLonRecenter">Update pointer.</span>
+ Lat <input id="glmLat_{ newLocID }" name="{ newLocID }_lat" type="text" value="{$newLocation.fieldData.lat}" class="glm-form-text-input-veryshort">
+ Lon <input id="glmLng_{ newLocID }" name="{ newLocID }_lon" type="text" value="{$newLocation.fieldData.lon}" class="glm-form-text-input-veryshort">
+ <span data-id="{ newLocID }" class="button button-secondary latLonRecenter">Update pointer.</span><br>
+ You may drag the map marker to the exact location desired. Also consider selecting "Satellite" view to better locate the marker.
</p>
</p>
</td>