rjy7 2010-07-22 17:28:54 +00:00
parent 525840e9f0
commit 2d59346f54

View file

@ -145,22 +145,13 @@ var addAuthorForm = {
showFieldsForNewPerson: function() { showFieldsForNewPerson: function() {
this.firstNameWrapper.show(); this.firstNameWrapper.show();
this.middleNameWrapper.show(); this.middleNameWrapper.show();
// this.toggleLastNameLabel('Name', 'Last name');
}, },
hideFieldsForNewPerson: function() { hideFieldsForNewPerson: function() {
this.hideFields(this.firstNameWrapper); this.hideFields(this.firstNameWrapper);
this.hideFields(this.middleNameWrapper); 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);
// },
/* *** Ajax initializations *** */ /* *** Ajax initializations *** */
/* Autocomplete */ /* Autocomplete */
@ -171,7 +162,7 @@ var addAuthorForm = {
this.acCache = {}; this.acCache = {};
this.setAcFilter(); this.setAcFilter();
$('#lastName').autocomplete({ this.lastNameField.autocomplete({
minLength: 2, minLength: 2,
source: function(request, response) { source: function(request, response) {
if (request.term in addAuthorForm.acCache) { if (request.term in addAuthorForm.acCache) {
@ -256,8 +247,10 @@ var addAuthorForm = {
this.hideFields(this.lastNameWrapper); this.hideFields(this.lastNameWrapper);
// This shouldn't be needed, because they are already hidden, but for some reason on select // This shouldn't be needed, because they are already hidden, but for some reason on select
// these fields get displayed, even before entering the select event listener. // these fields get displayed, even before entering the select event listener.
this.hideFields(this.firstNameWrapper); // These get displayed if the selection was made through an enter keystroke,
this.hideFields(this.middleNameWrapper); // since the keydown event on the last name field is also triggered (and
// executes first).
this.hideFieldsForNewPerson();
// Cancel restores initial form view // Cancel restores initial form view
this.cancel.unbind('click'); this.cancel.unbind('click');
@ -451,7 +444,7 @@ var addAuthorForm = {
this.lastNameField.keydown(function(event) { this.lastNameField.keydown(function(event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
addAuthorForm.onLastNameChange(); addAuthorForm.onLastNameChange();
return false; return false; // don't submit form
} }
}); });