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
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.Label <f> Label element
|
2012-07-04 11:29:18 +00:00
|
|
|
options <o|u> Options object
|
|
|
|
self <o|u> Shared private variable
|
2012-05-31 10:32:54 +00:00
|
|
|
([options[, self]]) -> <o:Ox.Element> Label element
|
2011-05-16 08:24:46 +00:00
|
|
|
@*/
|
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)
|
2012-05-28 19:35:41 +00:00
|
|
|
.defaults({
|
|
|
|
disabled: false,
|
|
|
|
id: '',
|
|
|
|
overlap: 'none',
|
|
|
|
textAlign: 'left',
|
|
|
|
style: 'rounded',
|
|
|
|
title: '',
|
|
|
|
width: 'auto'
|
|
|
|
})
|
|
|
|
.options(options || {})
|
|
|
|
.update({
|
|
|
|
title: function() {
|
|
|
|
that.html(self.options.title);
|
|
|
|
},
|
|
|
|
width: function() {
|
|
|
|
that.css({
|
|
|
|
width: self.options.width - (
|
2016-01-12 05:41:08 +00:00
|
|
|
Ox.contains(['rounded', 'squared'], self.options.style)
|
|
|
|
? 14 : 8
|
2012-05-28 19:35:41 +00:00
|
|
|
) + 'px'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addClass(
|
2016-01-12 05:41:08 +00:00
|
|
|
'OxLabel'
|
|
|
|
+ (
|
|
|
|
self.options.style != 'rounded'
|
|
|
|
? ' Ox' + Ox.toTitleCase(self.options.style)
|
|
|
|
: ''
|
|
|
|
)
|
2012-05-28 19:35:41 +00:00
|
|
|
+ (self.options.disabled ? ' OxDisabled' : '')
|
|
|
|
+ (
|
|
|
|
self.options.overlap != 'none'
|
|
|
|
? ' OxOverlap' + Ox.toTitleCase(self.options.overlap) : ''
|
2011-04-22 22:03:10 +00:00
|
|
|
)
|
2012-05-28 19:35:41 +00:00
|
|
|
)
|
|
|
|
.css(Ox.extend(self.options.width == 'auto' ? {} : {
|
|
|
|
width: self.options.width - (
|
2016-01-12 05:41:08 +00:00
|
|
|
Ox.contains(['rounded', 'squared'], self.options.style)
|
|
|
|
? 14 : 8
|
2012-05-28 19:35:41 +00:00
|
|
|
) + 'px'
|
|
|
|
}, {
|
|
|
|
textAlign: self.options.textAlign
|
|
|
|
}))
|
2013-11-15 23:23:23 +00:00
|
|
|
.html(Ox.isUndefined(self.options.title) ? '' : self.options.title);
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|