2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
2012-05-21 10:38:18 +00:00
|
|
|
|
2011-05-16 08:24:46 +00:00
|
|
|
/*@
|
|
|
|
Ox.Label <f:Ox.Element> Label Object
|
2012-05-22 13:14:40 +00:00
|
|
|
([options[, self]]) -> <o> Label Object
|
2011-05-16 08:24:46 +00:00
|
|
|
options <o> Options object
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.Label = function(options, self) {
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
disabled: false,
|
|
|
|
id: '',
|
|
|
|
overlap: 'none',
|
|
|
|
textAlign: 'left',
|
2011-11-30 14:42:54 +00:00
|
|
|
style: 'rounded',
|
2011-04-22 22:03:10 +00:00
|
|
|
title: '',
|
|
|
|
width: 'auto'
|
|
|
|
})
|
2011-10-31 12:45:08 +00:00
|
|
|
.options(options || {})
|
2011-04-22 22:03:10 +00:00
|
|
|
.addClass(
|
2011-11-30 14:42:54 +00:00
|
|
|
'OxLabel Ox' + Ox.toTitleCase(self.options.style)
|
|
|
|
+ (self.options.disabled ? ' OxDisabled' : '')
|
|
|
|
+ (
|
|
|
|
self.options.overlap != 'none'
|
|
|
|
?
|
|
|
|
' OxOverlap' + Ox.toTitleCase(self.options.overlap) : ''
|
|
|
|
)
|
2011-04-22 22:03:10 +00:00
|
|
|
)
|
2011-09-17 18:36:09 +00:00
|
|
|
.css(Ox.extend(self.options.width == 'auto' ? {} : {
|
2011-11-30 14:42:54 +00:00
|
|
|
width: self.options.width - (
|
2012-04-06 12:10:21 +00:00
|
|
|
self.options.style == 'rounded' ? 14 : 8
|
2011-11-30 14:42:54 +00:00
|
|
|
) + 'px'
|
2011-04-22 22:03:10 +00:00
|
|
|
}, {
|
|
|
|
textAlign: self.options.textAlign
|
|
|
|
}))
|
|
|
|
.html(self.options.title);
|
|
|
|
|
2011-04-29 12:40:51 +00:00
|
|
|
self.setOption = function(key, value) {
|
2011-04-22 22:03:10 +00:00
|
|
|
if (key == 'title') {
|
|
|
|
that.html(value);
|
2011-05-21 17:56:15 +00:00
|
|
|
} else if (key == 'width') {
|
2012-04-06 12:10:21 +00:00
|
|
|
that.css({
|
|
|
|
width: self.options.width - (
|
|
|
|
self.options.style == 'rounded' ? 14 : 8
|
|
|
|
) + 'px'
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
2011-06-19 17:48:32 +00:00
|
|
|
};
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|