From 1e017d1e09084e5ce34a234155de55cac19fda83 Mon Sep 17 00:00:00 2001
From: Matthew Juhl <mjuhl24@gmail.com>
Date: Wed, 28 Apr 2010 16:46:32 +0000
Subject: [PATCH] Further improvements to the profile form.

---
 .../scripts/JS/enhanceProfileForm.php         | 43 +++++++------------
 .../unl_theme/views/default/profile/edit.php  |  2 +-
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/plugins/unl_theme/scripts/JS/enhanceProfileForm.php b/plugins/unl_theme/scripts/JS/enhanceProfileForm.php
index 437b3954..d8135097 100644
--- a/plugins/unl_theme/scripts/JS/enhanceProfileForm.php
+++ b/plugins/unl_theme/scripts/JS/enhanceProfileForm.php
@@ -5,8 +5,6 @@
 	
 	function updateLL () {
 		var city = $("input[name=form_data_profile_city]").val(), state = $("select[name=form_data_profile_state]").val(), country = $("select[name=form_data_profile_country]").val();
-		
-			
 		$.get("<?php echo $vars['url']; ?>mod/unl_theme/scripts/latlon.php",{city:city,state:state,country:country},function(response){
 			try {
 				var data = eval(response);
@@ -16,7 +14,7 @@
 			} catch (e) {}
 		});
 	};
-
+	
 	function updateLLhome () {
 		var city = $("input[name=form_data_profile_homecity]").val(), state = $("select[name=form_data_profile_homestate]").val(), country = $("select[name=form_data_profile_homecountry]").val();
 		$.get("<?php echo $vars['url']; ?>mod/unl_theme/scripts/latlon.php",{city:city,state:state,country:country},function(response){
@@ -61,7 +59,7 @@
 		var to_parent = $("input[name=form_data_profile_attended_to]").parent();
 		$("input[name=form_data_profile_attended_to]").remove();
 
-		$("input[name=form_data_profile_city]").parent().find("label").html('Your map location <span class="helper">Please enter the location you want to use for yourself on the map</span>');
+		$("input[name=form_data_profile_city]").parent().find("label").html('Your map location <span class="helper">Please enter the location you want to use for yourself on the map.</span>');
 
 
 		/* set up various year inputs */
@@ -111,9 +109,9 @@
 			
 		}
 		$(selTo).html(html);
-		from_parent.append(" to ");
+		from_parent.append(to_parent.find("label"));
 		from_parent.append(selTo);
-		//to_parent.parent().remove();
+		
 
 		var states = ["AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"];
 		
@@ -321,9 +319,7 @@
 			}
 			html += '>' + countries[i] + '</option>';
 		}
-		/*if (current_country == "") {
-			html += '<option selected="selected" value="">-Select your country-</option>';
-		}*/
+		
 		$(selCountry).html(html);
 
 		var selState = document.createElement("select");
@@ -336,9 +332,7 @@
 			}
 			html += '>' + states[i] + '</option>';
 		}
-		/*if (current_state == "") {
-			html += '<option selected="selected" value="">&nbsp;</option>';
-		}*/
+		
 		$(selState).html(html);
 
 		var selhomeCountry = document.createElement("select");
@@ -351,9 +345,7 @@
 			}
 			html += '>' + countries[i] + '</option>';
 		}
-		/*if (home_country == "") {
-			html += '<option selected="selected" value="">-Select your country-</option>';
-		}*/
+		
 		$(selhomeCountry).html(html);
 
 		var selhomeState = document.createElement("select");
@@ -366,19 +358,16 @@
 			}
 			html += '>' + states[i] + '</option>';
 		}
-		/*if (home_state == "") {
-			html += '<option selected="selected" value="">&nbsp;</option>';
-		}*/
 		
 		$(selhomeState).html(html);
 		
-		 $("input[name=form_data_profile_dob_month]").parent().append(selYear);
-		 country_parent.append(selCountry);
-		 state_parent.append(selState);
-		 homecountry_parent.append(selhomeCountry);
-		 homestate_parent.append(selhomeState);
-		 
-		 $("input[name=form_data_profile_dob_day]").insertBefore($("select[name=form_data_profile_dob_year]"));
+		$("input[name=form_data_profile_dob_month]").parent().append(selYear);
+		country_parent.append(selCountry);
+		state_parent.append(selState);
+		homecountry_parent.append(selhomeCountry);
+		homestate_parent.append(selhomeState);
+		
+		$("input[name=form_data_profile_dob_day]").insertBefore($("select[name=form_data_profile_dob_year]"));
 		
 		// don't display the latitude/longitude fields
 		$("input[name=form_data_latitude],input[name=form_data_longitude]").parent().hide();
@@ -395,8 +384,8 @@
 			updateLLhome();
 		});
 
-		$("form.cool label").each(function(){
-			if (this.innerHTML.match(/day/i) ||  this.innerHTML.match(/year\s*$/i) ){
+		$("#profileEditor label").each(function(){
+			if (this.innerHTML.match(/day/i) ||  this.innerHTML.match(/year/i) ){
 				$(this).parent().remove();
 
 			} else if (this.innerHTML.match(/month/i)) {
diff --git a/plugins/unl_theme/views/default/profile/edit.php b/plugins/unl_theme/views/default/profile/edit.php
index f10e367e..522efa8b 100644
--- a/plugins/unl_theme/views/default/profile/edit.php
+++ b/plugins/unl_theme/views/default/profile/edit.php
@@ -33,7 +33,7 @@ if ($_GET['firstlogin'] == 'yes'){
 }
 
 //echo '<div id="formloading"><img src="/wdn/templates_3.0/css/header/images/colorbox/loading.gif" alt="Loading Form" /><noscript>Please enable JavaScript to use the profile editor.</noscript></div>';
-echo '<form action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data" class="zenform cool">';
+echo '<form action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data" class="zenform cool" id="profileEditor">';
 
 echo elgg_view('input/securitytoken');
 echo "<fieldset><ol>";
-- 
GitLab