-
+
+<%
+ // Try this in order to get the new author hightlighted after page reload.
+ // If we do an ajax submit, we won't need it.
+ //String processedForm = (String) vreq.getAttribute("processedForm");
+ //String ulClass = "";
+ //if (processedForm != null && processedForm.equals("true")) {
+ // ulClass = "class='processedSubmission'";
+ //}
+ //System.out.println(vreq.getAttribute("entToReturnTo"));
+%>
+
diff --git a/productMods/edit/forms/css/addAuthorsToInformationResource.css b/productMods/edit/forms/css/addAuthorsToInformationResource.css
index b4376268..92ed2b03 100644
--- a/productMods/edit/forms/css/addAuthorsToInformationResource.css
+++ b/productMods/edit/forms/css/addAuthorsToInformationResource.css
@@ -9,7 +9,6 @@
margin-bottom: .75em;
}
-
#authors a.existingAuthor {
display: inline-block;
width: 15em;
@@ -20,14 +19,6 @@
display: none;
}
-/* Hide elements not used in non-JS version of form */
-#showAddForm,
-a.remove,
-a.undo,
-#selectedAuthor {
- display: none;
-}
-
#showAddForm span.or {
display: none;
}
@@ -93,3 +84,24 @@ form a:hover.cancel,
#content form p.submit {
margin-top: 3em;
}
+
+a.undo,
+#selectedAuthor {
+ display: none;
+}
+
+/* Hide elements not used in non-JS version of form */
+/* rjy7 Currently not supporting non-JS version of this form. */
+/*
+#showAddForm,
+a.remove,
+a.undo,
+#selectedAuthor {
+ display: none;
+}
+*/
+
+/* These styles will need to be redone or removed to support a non-JS version of the form. */
+form#addAuthorForm {
+ display: none;
+}
diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js
index bf95429b..8a1774ee 100644
--- a/productMods/edit/forms/js/addAuthorsToInformationResource.js
+++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js
@@ -29,6 +29,7 @@ var addAuthorForm = {
this.firstNameField = $('#firstName');
this.middleNameField = $('#middleName');
this.lastNameField = $('#lastName');
+ this.lastNameLabel = $('label[for=lastName]');
this.personUriField = $('#personUri');
this.firstNameWrapper = this.firstNameField.parent();
this.middleNameWrapper = this.middleNameField.parent();
@@ -134,18 +135,42 @@ var addAuthorForm = {
onLastNameChange: function() {
this.showFieldsForNewPerson();
this.firstNameField.focus();
+ this.fixNames();
},
- showFieldsForNewPerson: function() {
+ showFieldsForNewPerson: function() {
this.firstNameWrapper.show();
this.middleNameWrapper.show();
+ this.toggleLastNameLabel('Name', 'Last name');
+ },
+
+ // User may have typed first name as well as last name into last name field.
+ // If so, when showing first and middle name fields, move anything after a comma
+ // into the first name field.
+ fixNames: function() {
+ var lastNameInput = this.lastNameField.val(),
+ names = lastNameInput.split(','),
+ lastName = names[0].replace(/[, ]+$/, ''),
+ firstName;
+
+ this.lastNameField.val(lastName);
+
+ if (names.length > 1) {
+ firstName = names[1].replace(/^[, ]+/, '');
+ this.firstNameField.val(firstName);
+ }
},
hideFieldsForNewPerson: function() {
- // Hide form fields that shouldn't display on first view.
- // Includes clearing their contents.
this.hideFields(this.firstNameWrapper);
this.hideFields(this.middleNameWrapper);
+ this.toggleLastNameLabel('Last name', 'Name');
+ },
+
+ toggleLastNameLabel: function(currentText, newText) {
+ var lastNameLabelText = this.lastNameLabel.html(),
+ newLastNameLabelText = lastNameLabelText.replace(currentText, newText);
+ this.lastNameLabel.html(newLastNameLabelText);
},
// This view shows the list of existing authors and hides the form.