add Ox.TabPanel()

This commit is contained in:
rlx 2011-08-17 14:59:37 +00:00
parent c4842ca863
commit a103ef8f7d
2 changed files with 59 additions and 1 deletions

View file

@ -1602,6 +1602,18 @@ Panels
.OxSplitPanel_.OxVertical > .OxSeparator > .OxSpace {
height: 2px;
}
.OxTabPanel > .OxBar {
text-align: center;
}
.OxTabPanel > .OxBar > .OxButtonGroup {
position: absolute;
left: 0;
top: 4px;
right: 0;
margin: auto;
}
/*
================================================================================
Requests

View file

@ -1,4 +1,50 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
Ox.TabPanel = function(options, self) {
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;
};