oxjs/source/Ox.UI/js/Form/Ox.FormItem.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2011-07-29 18:48:43 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
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) {
self = self || {};
var that = 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 = Ox.Element()
2011-04-22 22:03:10 +00:00
.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-04-22 22:03:10 +00:00
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;
};