2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-05-16 10:49:48 +00:00
|
|
|
|
|
|
|
/*@
|
|
|
|
Ox.FormItem <f:Ox.Element> FormItem Element, wrap form element with an error message
|
|
|
|
() -> <f> FormItem Element
|
|
|
|
(options) -> <f> FormItem Element
|
|
|
|
(options, self) -> <f> FormItem Element
|
|
|
|
options <o> Options object
|
|
|
|
element <o|null> element
|
|
|
|
error <s> error message
|
|
|
|
self <o> Shared private variable
|
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.FormItem = function(options, self) {
|
|
|
|
|
|
|
|
var self = self || {},
|
2011-04-29 12:40:51 +00:00
|
|
|
that = new Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
element: null,
|
|
|
|
error: '',
|
|
|
|
})
|
|
|
|
.options(options || {})
|
|
|
|
.addClass('OxFormItem')
|
|
|
|
.append(self.options.element);
|
|
|
|
|
|
|
|
self.$message = new Ox.Element()
|
|
|
|
.addClass('OxFormMessage')
|
|
|
|
.appendTo(that);
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
setMessage <f> set message
|
|
|
|
(message) -> <u> set message
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
that.setMessage = function(message) {
|
|
|
|
self.$message.html(message)[message !== '' ? 'show' : 'hide']();
|
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
value <f> get value
|
|
|
|
() -> <s> get value of wrapped element
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
that.value = function() {
|
|
|
|
return self.options.element.value();
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
}
|