oxjs/source/Ox.UI/js/Panel/Ox.TabPanel.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-07-29 18:48:43 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-04-22 22:03:10 +00:00
Ox.TabPanel = function(options, self) {
2011-08-17 14:59:37 +00:00
self = self || {};
var that = Ox.Element({}, self)
.defaults({
content: null,
tabs: []
})
.options(options || {});
self.$bar = Ox.Bar({size: 24});
self.$tabs = Ox.ButtonGroup({
buttons: self.options.tabs,
id: 'tabs',
selectable: true,
})
.bindEvent({
change: function(event) {
var id = event.selected[0];
that.$element.replaceElement(1, self.options.content(id));
that.triggerEvent('change', {
selected: id
});
}
})
.appendTo(self.$bar);
that.$element = Ox.SplitPanel({
elements: [
{
element: self.$bar,
size: 24
},
{
element: self.options.content(
self.options.tabs.filter(function(tab) {
return tab.selected;
})[0].id
)
}
],
orientation: 'vertical'
})
.addClass('OxTabPanel');
return that;
2011-04-22 22:03:10 +00:00
};