diff --git a/webapp/web/js/customFormUtils.js b/webapp/web/js/customFormUtils.js index 29e9bade7..c4c4ae5b0 100644 --- a/webapp/web/js/customFormUtils.js +++ b/webapp/web/js/customFormUtils.js @@ -6,6 +6,14 @@ if (!vitro) { } vitro.customFormUtils = { + + hideForm: function() { + this.hideFields(this.form); + }, + + clearFormData: function() { + this.clearFields(this.form); + }, // This method should always be called instead of calling hide() directly on any // element containing form fields. diff --git a/webapp/web/js/utils.js b/webapp/web/js/utils.js index d62fa4e42..a4c37d7d2 100644 --- a/webapp/web/js/utils.js +++ b/webapp/web/js/utils.js @@ -4,25 +4,20 @@ var vitro; if (!vitro) { vitro = {}; } -/* From "JavaScript: The Definitive Guide," 5th edition, by David Flanagan - * Copyright 2006 O'Reilly Media, Inc. - * ISBN 978-0-596-10199-2 - */ + vitro.utils = { + /* borrowMethods concept from "JavaScript: The Definitive Guide," 5th edition, by David Flanagan + * Copyright 2006 O'Reilly Media, Inc. + * ISBN 978-0-596-10199-2 + */ // Borrow methods from one class for use by another. // The arguments should be the constructor functions for the classes. // Methods of built-in types such as Object, Array, Date, and RegExp are // not enumerable and cannot be borrowed from with this method. borrowPrototypeMethods: function(borrowFrom, addTo) { - var from = borrowFrom.prototype; // prototype object to borrow from - var to = addTo.prototype; // prototype object to extend - - for (m in from) { // loop through all properties of the prototype - if (typeof from[m] != "function") { continue; } // ignore non-functions - to[m] = from[m]; - } + borrowMethods(borrowFrom.prototype, addTo.prototype); }, borrowMethods: function(borrowFrom, addTo) {