1 (function( $, app, joey ) {
5 ui.AbstractField = ui.AbstractWidget.extend({
8 name : "", // (required) - name of the field
9 require: false, // validation requirements (false, true, regexp, function)
10 value: "", // default value
11 label: "" // human readable label of this field
14 init: function(parent) {
16 this.el = $.joey(this._main_template());
17 this.field = this.el.find("[name="+this.config.name+"]");
18 this.label = this.config.label;
19 this.require = this.config.require;
20 this.name = this.config.name;
21 this.val( this.config.value );
22 this.attach( parent );
25 val: function( val ) {
26 if(val === undefined) {
27 return this.field.val();
29 this.field.val( val );
34 validate: function() {
35 var val = this.val(), req = this.require;
38 } else if( req === true ) {
39 return val.length > 0;
40 } else if( req.test && $.isFunction(req.test) ) {
41 return req.test( val );
42 } else if( $.isFunction(req) ) {
43 return req( val, this );
49 })( this.jQuery, this.app, this.joey );