* New City Dialog
*/
- // Setup dialog box for adding a new city
- $("#newCityDialog").dialog({
- autoOpen: false,
- minWidth: 400,
- dialogClass: "glm-dialog-no-close"
- });
- $('#newCityCancel').click( function() {
- $("#newCityDialog").dialog("close");
- });
-
- // Ad a new city button action - pop-up dialog
- $('#newCityButton').click( function() {
- $("#newCityDialog").dialog("open");
- });
-
+ function addNewCitySetup() {
+
+ // Setup dialog box for adding a new city
+ $(".newCityDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('.new-city-cancel').click( function() {
+ locID = $(this).attr('data-id');
+ $("#newCityDialog_" + locID).dialog("close");
+ });
+
+ // Add a new city button action - pop-up dialog
+ $('.new-city-button').click( function() {
+ locID = $(this).attr('data-id');
+ $("#newCityDialog_" + locID).dialog("open");
+ });
+ }
+ addNewCitySetup();
+
// Submit new city
var newCityAdded = false;
- $('#newCitySubmit').click( function() {
+ $('.newCitySubmit').click( function() {
+ locID = $(this).attr('data-id');
+
// Get new city name
- var newCityName = $('#newCityName').val();
+ var newCityName = $('#newCityName_' + locID).val();
// If no name is supplied, notify used it's required
if (newCityName == '') {
- $('#newCityNameTD').addClass('glm-form-bad-input');
- $('#newCityNameRequired').text('A city name is required!');
+ $('#newCityNameTD_' + locID).addClass('glm-form-bad-input');
+ $('#newCityNameRequired_' + locID).text('A city name is required!');
return false;
}
// Add new city name to the hidden field that will pass the new name to PHP.
- $('#cityName').val(newCityName);
+ $('#cityName_' + locID).val(newCityName);
// Add new city name to picklist and for storing - Only one permitted per submission
if (newCityAdded) {
// New city already added, so just update the name and select that one
- $('#city').val(-1);
- $('#city option:selected').text(newCityName);
+ $('#city_' + locID).val(-1);
+ $('#city_' + locID + ' option:selected').text(newCityName);
} else {
// Add the new city name to the city picklist
- $('#city').append('<option value="-1">' + newCityName + '</option>');
- $('#city').val(-1);
- $('#newCityNameTD').append('<input type="hidden" name="newCity" value="' + newCityName + '">');
+ $('#city_' + locID).append('<option value="-1">' + newCityName + '</option>');
+ $('#city_' + locID ).val(-1);
+ $('#newCityNameTD_' + locID).append('<input type="hidden" name="newCity" value="' + newCityName + '">');
newCityAdded = true;
}
// Clear new city name from form
- $('#newCityName').val('');
+ $('#newCityName_' + locID).val('');
- $("#newCityDialog").dialog("close");
+ $("#newCityDialog_" + locID).dialog("close");
});
var geoCity = $('#city_' + locID).find('option:selected').text().trim();
var geoState = $('#state_' + locID).find('option:selected').text().trim();
var geoZIP = $('#zip_' + locID).val().trim();
- var geoCountry = $('country_' + locID).find('option:selected').text().trim();
+ var geoCountry = $('#country_' + locID).find('option:selected').text().trim();
// Assemble address string for
var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry;
<tr>
<th>Location Name:</th>
<td>
- <input type="text" name="{$loc.id}_name" value="{$loc.name}" class="glm-form-text-input-medium">
+ <input id="name_{$loc.id}" type="text" name="{$loc.id}_name" value="{$loc.name}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<th>Address:</th>
<td>
- <input type="text" name="{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
+ <input id="address_{$loc.id}" type="text" name="{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<th>City</th>
<td class="glm-item-container">
<!-- Add new city dialog -->
- <div id="newCityButton" class="button button-secondary glm-right">Add a new City</div>
- <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
+ <div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
+ <div id="newCityDialog_{$loc.id}" class="glm-dialog-box" title="Enter a New City">
<table class="glm-admin-table">
<tr>
<th class="glm-required">City Name:</th>
- <td id="newCityNameTD">
- <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
- <div id="newCityNameRequired"></div>
+ <td id="newCityNameTD_{$loc.id}">
+ <input id="newCityName_{$loc.id}" type="text" name="newCityName" class="glm-form-text-input">
+ <div id="newCityNameRequired_{$loc.id}"></div>
</td>
</tr>
</table>
<p><span class="glm-required">*</span> Required</p>
- <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
- <input id="newCitySubmit" type="submit" value="Add new City">
+ <a id="newCityCancel_{$loc.id}" class="button button-primary glm-right new-city-cancel">Cancel</a>
+ <input data-id="{$loc.id}" class="newCitySubmit" type="submit" value="Add new City">
</div>
<!-- City Selection -->
- <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
+ <input id="cityName_{$loc.id}" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
<select id="city_{$loc.id}" name="{$loc.id}_city">
<option value="0"></option>
{foreach from=$loc.city.list item=v}
<tr>
<th>ZIP / Postal Code:</th>
<td>
- <input type="text" name="{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
+ <input id="zip_{$loc.id}" type="text" name="{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<tr>
<th>Location Name:</th>
<td>
- <input type="text" name="{ newLocID }_name" value="{$newLocation.fieldData.name}" class="glm-form-text-input-medium">
+ <input id="name_{ newLocID }" type="text" name="{ newLocID }_name" value="{$newLocation.fieldData.name}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
<th>City</th>
<td class="glm-item-container">
<!-- Add new city dialog -->
- <div id="newCityButton" class="button button-secondary glm-right">Add a new City</div>
- <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
+ <div class="button button-secondary glm-right new-city-button">Add a new City</div>
+ <div id="newCityDialog_{ newLocID }" class="glm-dialog-box" title="Enter a New City">
<table class="glm-admin-table">
<tr>
<th class="glm-required">City Name:</th>
- <td id="newCityNameTD">
- <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
- <div id="newCityNameRequired"></div>
+ <td id="newCityNameTD_{ newLocID }">
+ <input id="newCityName_{ newLocID }" type="text" name="newCityName" class="glm-form-text-input">
+ <div id="newCityNameRequired_{ newLocID }"></div>
</td>
</tr>
</table>
<p><span class="glm-required">*</span> Required</p>
- <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
- <input id="newCitySubmit" type="submit" value="Add new City">
+ <a id="newCityCancel_{ newLocID }" class="button button-primary glm-right new-city-cancel">Cancel</a>
+ <input data-id="{$loc.id}" class="newCitySubmit" type="submit" value="Add new City">
</div>
<!-- City Selection -->
- <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
+ <input id="cityName_{ newLocID }" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
<select id="city_{ newLocID }" name="{ newLocID }_city">
<option value="0"></option>
{foreach from=$newLocation.fieldData.city.list item=v}