50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
'use strict';
|
|
|
|
/*@
|
|
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
|
|
@*/
|
|
|
|
Ox.FormItem = function(options, self) {
|
|
|
|
self = self || {};
|
|
var that = Ox.Element({}, self)
|
|
.defaults({
|
|
element: null,
|
|
error: '',
|
|
})
|
|
.options(options || {})
|
|
.addClass('OxFormItem')
|
|
.append(self.options.element);
|
|
|
|
self.$message = Ox.Element()
|
|
.addClass('OxFormMessage')
|
|
.appendTo(that);
|
|
|
|
/*@
|
|
setMessage <f> set message
|
|
(message) -> <u> set message
|
|
@*/
|
|
that.setMessage = function(message) {
|
|
self.$message.html(message)[message !== '' ? 'show' : 'hide']();
|
|
};
|
|
|
|
/*@
|
|
value <f> get value
|
|
() -> <s> get value of wrapped element
|
|
@*/
|
|
that.value = function() {
|
|
return self.options.element.value();
|
|
};
|
|
|
|
return that;
|
|
|
|
};
|