From ab3e088cdfbc31b6a4e3756a39ee6436146734d0 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Mon, 14 Jun 2010 20:06:53 +0000 Subject: [PATCH] Add custom form utils mixin to forms for educational background and position history. --- .../forms/addAuthorsToInformationResource.jsp | 8 ++--- .../js/addAuthorsToInformationResource.js | 8 +++-- productMods/edit/forms/js/customForm.js | 32 ++++--------------- .../forms/personHasEducationalBackground.jsp | 4 ++- .../edit/forms/personHasPositionHistory.jsp | 4 ++- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp index e82f6be8..020a303f 100644 --- a/productMods/edit/forms/addAuthorsToInformationResource.jsp +++ b/productMods/edit/forms/addAuthorsToInformationResource.jsp @@ -225,10 +225,10 @@ SPARQL queries for existing values. --%> String linkedAuthorProperty = "http://vivoweb.org/ontology/core#linkedAuthor"; - List customJs = new ArrayList(Arrays.asList( - "/js/utils.js", - "/js/customFormUtils.js", - "/edit/forms/js/addAuthorsToInformationResource.js")); + List customJs = new ArrayList(Arrays.asList("/js/utils.js", + "/js/customFormUtils.js", + "/edit/forms/js/addAuthorsToInformationResource.js" + )); request.setAttribute("customJs", customJs); List customCss = new ArrayList(Arrays.asList("/edit/forms/css/customForm.css", diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js index 4a5fb7cb..a1c25261 100644 --- a/productMods/edit/forms/js/addAuthorsToInformationResource.js +++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js @@ -4,11 +4,16 @@ var addAuthorForm = { onLoad: function() { + this.mixIn(); this.initObjects(); this.adjustForJs(); this.initForm(); }, + mixIn: function() { + // Mix in the custom form utility methods + vitro.utils.borrowMethods(vitro.customFormUtils, this); + }, // On page load, create references within the customForm scope to DOM elements. // NB These must be assigned after the elements have been loaded onto the page. @@ -34,8 +39,7 @@ var addAuthorForm = { initForm: function() { - // Mix in the custom form utility methods - vitro.utils.borrowMethods(vitro.customFormUtils, this); + this.showFormButton.click(function() { addAuthorForm.showFormDiv.hide(); diff --git a/productMods/edit/forms/js/customForm.js b/productMods/edit/forms/js/customForm.js index 7d4d6d97..da833d67 100644 --- a/productMods/edit/forms/js/customForm.js +++ b/productMods/edit/forms/js/customForm.js @@ -57,11 +57,17 @@ var customForm = { onLoad: function() { + this.mixIn(); this.initObjects(); this.adjustForJs(); this.initForm(); }, + mixIn: function() { + // Mix in the custom form utility methods + vitro.utils.borrowMethods(vitro.customFormUtils, this); + }, + // On page load, create references within the customForm scope to DOM elements. // NB These must be assigned after the elements have been loaded onto the page. initObjects: function() { @@ -117,7 +123,7 @@ var customForm = { }, initForm: function() { - + //Adding a new entry if (this.editType === 'add') { this.initAddForm(); @@ -284,8 +290,6 @@ var customForm = { this.doAddNewLinkForCombinedView(); this.setReturnView(this.views.COMBINED); }, - - /***** Utilities *****/ unbindEventListeners: function() { customForm.cancel.unbind('click'); @@ -294,28 +298,6 @@ var customForm = { customForm.close.unbind('click'); customForm.existingSelect.unbind('change'); }, - - clearFormData: function() { - customForm.clearFields(customForm.form); - }, - - // Clear data from form elements in element el - clearFields: function(el) { - el.find(':input[type!="hidden"][type!="submit"][type!="button"]').val(''); - - // For now we can remove the error elements. Later we may include them in - // the markup, for customized positioning, in which case we will empty them - // but not remove them here. See findValidationErrors(). - el.find('.validationError').remove(); - }, - - // This method should always be called instead of calling hide() directly on any - // element containing form fields. - hideFields: function(el) { - // Clear any input and error message, so if we re-show the element it won't still be there. - customForm.clearFields(el); - el.hide(); - }, // Add event listener to the submit button in step 2 doButtonForStep2: function(text) { diff --git a/productMods/edit/forms/personHasEducationalBackground.jsp b/productMods/edit/forms/personHasEducationalBackground.jsp index 74b03a64..5be43e1b 100644 --- a/productMods/edit/forms/personHasEducationalBackground.jsp +++ b/productMods/edit/forms/personHasEducationalBackground.jsp @@ -364,7 +364,9 @@ the org type still gets asserted. --%> <% } - List customJs = new ArrayList(Arrays.asList("/edit/forms/js/customForm.js" + List customJs = new ArrayList(Arrays.asList("/js/utils.js", + "/js/customFormUtils.js", + "/edit/forms/js/customForm.js" //, "/edit/forms/js/customFormOneStep.js" )); request.setAttribute("customJs", customJs); diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 0592aa09..54f709ba 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -295,7 +295,9 @@ <% } - List customJs = new ArrayList(Arrays.asList("/edit/forms/js/customForm.js" + List customJs = new ArrayList(Arrays.asList("/js/utils.js", + "/js/customFormUtils.js", + "/edit/forms/js/customForm.js" //, "/edit/forms/js/customFormTwoStep.js" )); request.setAttribute("customJs", customJs);