Making customFormWithAdvanceTypeSelection.js work where there isn't advance type selection.

This commit is contained in:
bdc34 2010-07-11 21:04:01 +00:00
parent d1c8d701c2
commit e82f3e993a

View file

@ -25,6 +25,9 @@ var customForm = {
this.requiredLegend = $('#requiredLegend'); this.requiredLegend = $('#requiredLegend');
this.typeSelector = this.form.find('#typeSelector'); this.typeSelector = this.form.find('#typeSelector');
//if there isn't a two stage setup, don't do two stage behavior
this.twoStageForm = ( this.typeSelector.length > 1 );
// This is the label element for the field with name 'label' // This is the label element for the field with name 'label'
this.labelFieldLabel = $('label[for=' + $('#label').attr('id') + ']'); this.labelFieldLabel = $('label[for=' + $('#label').attr('id') + ']');
// Get this on page load, so we can prepend to it. We can't just prepend to the current label text, // Get this on page load, so we can prepend to it. We can't just prepend to the current label text,
@ -47,7 +50,7 @@ var customForm = {
this.initAutocomplete(); this.initAutocomplete();
if (this.findValidationErrors()) { if (this.findValidationErrors() || ! this.twoStageForm) {
this.initFormFullView(); this.initFormFullView();
} else { } else {
this.initFormTypeView(); this.initFormTypeView();
@ -62,8 +65,9 @@ var customForm = {
this.requiredLegend.hide(); this.requiredLegend.hide();
this.or.hide(); this.or.hide();
if( twoStageForm ){
this.cancel.unbind('click'); this.cancel.unbind('click');
}
}, },
initFormFullView: function() { initFormFullView: function() {
@ -74,12 +78,14 @@ var customForm = {
this.button.show(); this.button.show();
this.button.val('Create Publication'); this.button.val('Create Publication');
if( twoStageForm ){
this.cancel.unbind('click'); this.cancel.unbind('click');
this.cancel.click(function() { this.cancel.click(function() {
customForm.clearFormData(); // clear any input and validation errors customForm.clearFormData(); // clear any input and validation errors
customForm.initFormTypeView(); customForm.initFormTypeView();
return false; return false;
}); });
}
}, },
// Bind event listeners that persist over the life of the page. // Bind event listeners that persist over the life of the page.
@ -182,13 +188,15 @@ var customForm = {
this.button.val('Add Publication'); this.button.val('Add Publication');
if( this.twoStageForm){
this.cancel.unbind('click'); this.cancel.unbind('click');
this.cancel.click(function() { this.cancel.click(function() {
// TODO Check out cancel action for authors form. Need to undo/empty some of the stuff above. // TODO Check out cancel action for authors form. Need to undo/empty some of the stuff above.
// do we do it in the initfullview method, or here? //do we do it in the initfullview method, or here?
customForm.initFormFullView(); customForm.initFormFullView();
return false; return false;
}); });
}
}, },