Add custom form utils mixin to forms for educational background and position history.
This commit is contained in:
parent
da9f7ee0c4
commit
bdc0bbfeae
2 changed files with 14 additions and 11 deletions
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue