CollapsePanel: add support for left-hand side extras

This commit is contained in:
rolux 2014-05-10 15:10:27 +02:00 committed by j
parent d31ba7a28e
commit c11e279803

View file

@ -44,6 +44,17 @@ Ox.CollapsePanel = function(options, self) {
} }
}); });
var index = Ox.indexOf(self.options.extras, Ox.isEmpty);
self.extras = index > -1
? [
self.options.extras.slice(0, index),
self.options.extras.slice(index + 1)
]
: [
[],
self.options.extras
];
self.$titlebar = Ox.Bar({ self.$titlebar = Ox.Bar({
orientation: 'horizontal', orientation: 'horizontal',
size: self.options.size size: self.options.size
@ -71,18 +82,30 @@ Ox.CollapsePanel = function(options, self) {
}) })
.appendTo(self.$titlebar); .appendTo(self.$titlebar);
self.$extras = [];
if (self.extras[0].length) {
self.$extras[0] = Ox.Element()
.addClass('OxExtras')
.css({width: self.extras[0].length * 16 + 2 + 'px'})
.appendTo(self.$titlebar);
self.extras[0].forEach(function($extra) {
$extra.appendTo(self.$extras[0]);
});
}
self.$title = Ox.Element() self.$title = Ox.Element()
.addClass('OxTitle') .addClass('OxTitle')
.html(self.options.title) .html(self.options.title)
.appendTo(self.$titlebar); .appendTo(self.$titlebar);
if (self.options.extras.length) { if (self.extras[1].length) {
self.$extras = Ox.Element() self.$extras[1] = Ox.Element()
.addClass('OxExtras') .addClass('OxExtras')
.css({width: self.options.extras.length * 16 + 'px'}) .css({width: self.extras[1].length * 16 + 'px'})
.appendTo(self.$titlebar); .appendTo(self.$titlebar);
self.options.extras.forEach(function($extra) { self.extras[1].forEach(function($extra) {
$extra.appendTo(self.$extras); $extra.appendTo(self.$extras[1]);
}); });
} }