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 || {});
|
|
|
|
|
2011-11-02 10:23:15 +00:00
|
|
|
self.selected = getSelected();
|
|
|
|
|
2011-08-17 14:59:37 +00:00
|
|
|
self.$bar = Ox.Bar({size: 24});
|
|
|
|
|
|
|
|
self.$tabs = Ox.ButtonGroup({
|
|
|
|
buttons: self.options.tabs,
|
|
|
|
id: 'tabs',
|
|
|
|
selectable: true,
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event) {
|
2011-11-02 10:23:15 +00:00
|
|
|
self.selected = event.selected[0];
|
|
|
|
that.$element.replaceElement(1, self.options.content(self.selected));
|
2011-08-17 14:59:37 +00:00
|
|
|
that.triggerEvent('change', {
|
2011-11-02 10:23:15 +00:00
|
|
|
selected: self.selected
|
2011-08-17 14:59:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$bar);
|
|
|
|
|
|
|
|
that.$element = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: self.$bar,
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
2011-11-02 10:23:15 +00:00
|
|
|
element: self.options.content(self.selected)
|
2011-08-17 14:59:37 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
.addClass('OxTabPanel');
|
|
|
|
|
2011-11-02 10:23:15 +00:00
|
|
|
function getSelected() {
|
|
|
|
return self.options.tabs.filter(function(tab) {
|
|
|
|
return tab.selected;
|
|
|
|
})[0].id;
|
|
|
|
}
|
|
|
|
|
|
|
|
that.selected = function() {
|
|
|
|
return self.selected;
|
|
|
|
};
|
|
|
|
|
2011-08-17 14:59:37 +00:00
|
|
|
return that;
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
};
|