45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
/*@
|
|
Ox.Label <f:Ox.Element> Label Object
|
|
() -> <f> Label Object
|
|
(options) -> <f> Label Object
|
|
(options, self) -> <f> Label Object
|
|
options <o> Options object
|
|
|
|
@*/
|
|
Ox.Label = function(options, self) {
|
|
|
|
self = self || {};
|
|
var that = Ox.Element({}, self)
|
|
.defaults({
|
|
disabled: false,
|
|
id: '',
|
|
overlap: 'none',
|
|
textAlign: 'left',
|
|
title: '',
|
|
width: 'auto'
|
|
})
|
|
.options(options)
|
|
.addClass(
|
|
'OxLabel' + (self.options.disabled ? ' OxDisabled' : '') +
|
|
(self.options.overlap != 'none' ?
|
|
' OxOverlap' + Ox.toTitleCase(self.options.overlap) : '')
|
|
)
|
|
.css(Ox.extend(self.options.width == 'auto' ? {} : {
|
|
width: self.options.width - 14 + 'px' // fixme: why 14????
|
|
}, {
|
|
textAlign: self.options.textAlign
|
|
}))
|
|
.html(self.options.title);
|
|
|
|
self.setOption = function(key, value) {
|
|
if (key == 'title') {
|
|
that.html(value);
|
|
} else if (key == 'width') {
|
|
that.css({width: self.options.width - 14 + 'px'});
|
|
}
|
|
};
|
|
|
|
return that;
|
|
|
|
};
|