diff --git a/productMods/edit/forms/css/customForm.css b/productMods/edit/forms/css/customForm.css index a240eee9..9a7d1e20 100644 --- a/productMods/edit/forms/css/customForm.css +++ b/productMods/edit/forms/css/customForm.css @@ -32,12 +32,18 @@ display: inline-block; } +#existingOrNew { + font-style:italic; + margin-left: 1em; +} + #new { padding: .6em 0 .6em 1.5em; border: 1px solid #9c9c9c; width: 70%; } + /* #content form p.inline span,*/ #content form p.inline input { float: right; diff --git a/productMods/edit/forms/js/customForm.js b/productMods/edit/forms/js/customForm.js index 2bda0529..95d0233f 100644 --- a/productMods/edit/forms/js/customForm.js +++ b/productMods/edit/forms/js/customForm.js @@ -5,23 +5,30 @@ var customForm = { onLoad: function() { // Create references to form elements. - // NB must be done after document has loaded, else the elements aren't present - // in the DOM yet. + // NB must be done after the elements have been loaded. + this.form = $('#content form'), this.button = $('#submit'), + this.requiredLegend = $('#requiredLegend'), + + // These may need to be changed to classes rather than ids, if there are + // multiple sets of divs to show/hide during the workflow. this.addNewLink = $('#addNewLink'), this.existing = $('#existing'), this.addNew = $('#new'), this.entry = $('#entry'), + this.existingOrNew = $('#existingOrNew'), + this.cancel = this.form.find('.cancel'), - this.requiredLegend = $('#requiredLegend'), - this.requiredHints = this.form.find('.requiredHint'), + this.requiredHints = this.form.find('.requiredHint'), // Read values used to control display this.editType = $("input[name='editType']").val(), this.entryType = $("input[name='entryType']").val().capitalize(), this.newType = $("input[name='newType']").val().capitalize(); - + + this.adjustForJs(); + if (this.editType == 'add') { //adding a new entry this.initAddForm(); @@ -30,10 +37,21 @@ var customForm = { } }, + // On page load, make changes to the non-Javascript version for the Javascript version. + // These are features that will not change in the Javascript version. + adjustForJs: function() { + this.existingOrNew.hide(); + + var selectExistingLabel = $('#existing label'); + selectExistingLabel.html(selectExistingLabel.html().replace('Select Existing ', '')); + + }, + // Reset add form to initial state (step 1) // Should only be needed after returning to step 1 from step 2, // but sometimes seems to be needed on page load as well, so call it from initAddForm() resetAddForm: function() { + // Clear all form data and error messages $('input:text').val(''); $('.error').text(''); @@ -47,9 +65,6 @@ var customForm = { }, // Set up add form on page load, or when returning to initial state - // (The latter is not yet implemented, but we are preparing for it. Note - // that initializations to occur ONLY on page load are done in the onLoad() method.) - // RY *** SOME of this will be shared with the edit form - figure out which initAddForm: function() { this.resetAddForm(); @@ -58,25 +73,12 @@ var customForm = { this.addNewLink.show(); this.existing.show(); this.addNew.hide(); - this.entry.hide(); + this.entry.hide(); this.requiredLegend.hide(); this.button.val('Continue'); - // Assign event listeners - // add new link => step 2b - this.addNewLink.bind('click', function() { - $(this).hide(); - customForm.existing.hide(); - customForm.showFields(customForm.addNew); - customForm.entry.show(); - customForm.requiredLegend.show(); - - customForm.button.val('Create ' + customForm.entryType + ' & ' + customForm.newType); - customForm.button.unbind('click'); - - customForm.doCancel(); - }); - + // Assign event listeners + // button => step 2a this.button.bind('click', function() { customForm.entry.show(); @@ -91,6 +93,20 @@ var customForm = { return false; }); + + // add new link => step 2b + this.addNewLink.bind('click', function() { + $(this).hide(); + customForm.existing.hide(); + customForm.showFields(customForm.addNew); + customForm.entry.show(); + customForm.requiredLegend.show(); + + customForm.button.val('Create ' + customForm.entryType + ' & ' + customForm.newType); + customForm.button.unbind('click'); + + customForm.doCancel(); + }); }, initEditForm: function() { @@ -112,12 +128,14 @@ var customForm = { }, - // Add required hints to required fields in element array elArray. + // Add required hints to required fields in a list of elements. // Use when the non-Javascript version should not show the required hint, - // because the field is not required in that version. + // because the field is not required in that version (e.g., it's one of two + // fields, where one of the two must be filled in but neither one is required). // Arguments: action = 'add' or 'remove' // Varargs: element(s) toggleRequiredHints: function(action /* elements */) { + var labelText, newLabelText, requiredHintText = ' *'; diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 9abf5ac0..a0567e54 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -310,13 +310,15 @@
" >