From 4129e7ab27054aa023bf98e534e8eaa9c74d9e5c Mon Sep 17 00:00:00 2001
From: Matthew Juhl <mjuhl24@gmail.com>
Date: Tue, 18 Aug 2009 19:25:41 +0000
Subject: [PATCH] Profile editor view fixes

---
 flexprofile_mj/views/default/profile/edit.php |  6 +-
 .../views/default/page_elements/header.php    | 76 ++++++++++++++++++-
 2 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/flexprofile_mj/views/default/profile/edit.php b/flexprofile_mj/views/default/profile/edit.php
index f66e9f6b..773b0978 100755
--- a/flexprofile_mj/views/default/profile/edit.php
+++ b/flexprofile_mj/views/default/profile/edit.php
@@ -26,10 +26,10 @@ if ($form) {
 /* import forms css */
 echo '<style type="text/css">@IMPORT url("/wdn/templates_3.0/css/content/forms.css");</style>';
 /* add 'cool' class to form */
-
+echo '<div id="formloading"><img src="http://ucommjuhl.unl.edu/wdn/templates_3.0/css/header/images/colorbox/loading.gif" alt="Loading Form" /></div>';
 echo '<form action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data" class="cool">';
 /* add fieldset and legend */
-echo '<fieldset><legend>Edit Profile</legend>';
+echo '<fieldset><legend>Edit Profile</legend><ol>';
 /* mjuhl: remove dynamic form by commenting out the following line: */
 echo '<!--------start copying here------------>';
 echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0));
@@ -46,7 +46,7 @@ echo '<!--------stop copying here------------>';
 		
 		<input type="submit" value="<?php echo elgg_echo("save"); ?>" />
 	</p>
-
+	</ol>
 </form>
 <?php
 } else {
diff --git a/unl_theme/views/default/page_elements/header.php b/unl_theme/views/default/page_elements/header.php
index 77b2d968..697a1f20 100644
--- a/unl_theme/views/default/page_elements/header.php
+++ b/unl_theme/views/default/page_elements/header.php
@@ -49,6 +49,24 @@ echo elgg_view('metatags',$vars);
 <?php 
 if ($vars['title'] == "Edit profile") {
 ?>
+<style type="text/css">
+#maincontent form.cool {
+	display: none;
+}
+
+#maincontent form.cool div.element {
+	margin: 0;
+}
+
+#maincontent form.cool label {
+	vertical-align: inherit !important;
+}
+
+#maincontent form.cool fieldset li {
+	padding-bottom: 15px;
+}
+
+</style>
 <script type="text/javascript">
 (function(){
 	// Edit Profile Stuff
@@ -64,12 +82,68 @@ if ($vars['title'] == "Edit profile") {
 	};
 			
 	$(document).ready(function(){
+		/* SET UP PROFILE EDIT FORM */
+		
+		
+		// get the dob_year for later use
+		var dob_year = $("input[name=form_data_profile_dob_year]").val();
+		// remove the text input. will be replacing with a selector
+		$("input[name=form_data_profile_dob_year]").remove();
+		
+		
+		
+		// wrap the fields in <li>s
+		$("form.cool label").wrap("<li></li>");
+		$("form.cool label br").remove();
+		$("form.cool p.form-field-description").each(function(){
+			$(this).appendTo($(this).prev()).css({
+				marginLeft: "162px",
+				fontSize: "75%",
+				color: "#1091D1"
+			});
+		});
+		$("form.cool fieldset input, form.cool fieldset select").wrap('<div class="element"></div>');
+		$("form.cool label div").each(function(){
+			
+			$(this).insertAfter($(this).parent());
+		});
+
+
+		var selYear = document.createElement("select");
+		selYear.name = "form_data_profile_dob_year";
+		var x = 1900, html = "";
+		while (x++ < (new Date()).getFullYear()) {
+			html+= '<option';
+			if (x == dob_year) {
+				html += ' selected="selected"'
+			}
+			html += '>' + x + '</option>';
+			
+		}
+		selYear.innerHTML = html;
+		
+		 $("select[name=form_data_profile_dob_month]").parent().append(selYear);
+		 $("select[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();
+		$("input[name=form_data_latitude],input[name=form_data_longitude]").parent().parent().hide();
 		// update the lat/long automatically whenever current location is changed
 		$("input[name=form_data_profile_city],input[name=form_data_profile_state],input[name=form_data_profile_country]").change(function(){
 			updateLL();
 		});
+
+		$("form.cool label").each(function(){
+			if (this.innerHTML.match(/day/i) ||  this.innerHTML.match(/year\s*$/i) ){
+				$(this).parent().remove();
+
+			} else if (this.innerHTML.match(/month/i)) {
+				this.innerHTML = "Birthday";
+			}
+		});
+		
+		$("#formloading").remove();
+		$("#maincontent form.cool").show();
 	});
 })();
 </script>
-- 
GitLab