fix a bug in TabPanel that would make it return a SplitPanel
This commit is contained in:
parent
37030b5d27
commit
67a0f82266
1 changed files with 15 additions and 6 deletions
|
@ -1,11 +1,14 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
|
||||
'use strict';
|
||||
|
||||
Ox.TabPanel = function(options, self) {
|
||||
|
||||
self = self || {};
|
||||
var that = Ox.Element({}, self)
|
||||
.defaults({
|
||||
content: null,
|
||||
size: 24,
|
||||
tabs: []
|
||||
})
|
||||
.options(options || {});
|
||||
|
@ -20,6 +23,7 @@ Ox.TabPanel = function(options, self) {
|
|||
selectable: true,
|
||||
value: self.selected
|
||||
})
|
||||
.css({top: (self.options.size - 16) / 2 + 'px'})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
self.selected = data.value;
|
||||
|
@ -29,11 +33,12 @@ Ox.TabPanel = function(options, self) {
|
|||
})
|
||||
.appendTo(self.$bar);
|
||||
|
||||
that.$element = Ox.SplitPanel({
|
||||
that.setElement(
|
||||
Ox.SplitPanel({
|
||||
elements: [
|
||||
{
|
||||
element: self.$bar,
|
||||
size: 24
|
||||
size: self.options.size
|
||||
},
|
||||
{
|
||||
element: getContent()
|
||||
|
@ -41,7 +46,8 @@ Ox.TabPanel = function(options, self) {
|
|||
],
|
||||
orientation: 'vertical'
|
||||
})
|
||||
.addClass('OxTabPanel');
|
||||
.addClass('OxTabPanel')
|
||||
);
|
||||
|
||||
function getContent() {
|
||||
return Ox.isObject(self.options.content)
|
||||
|
@ -50,15 +56,18 @@ Ox.TabPanel = function(options, self) {
|
|||
}
|
||||
|
||||
function getSelected() {
|
||||
return self.options.tabs.filter(function(tab) {
|
||||
var selected = self.options.tabs.filter(function(tab) {
|
||||
return tab.selected;
|
||||
})[0].id;
|
||||
});
|
||||
return (selected.length ? selected : self.options.tabs)[0].id;
|
||||
}
|
||||
|
||||
// fixme: does this collide with a jquery fn?
|
||||
that.select = function(id) {
|
||||
if (Ox.getIndexById(self.options.tabs, id) > -1) {
|
||||
self.$tabs.options({value: id});
|
||||
}
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
||||
that.selected = function() {
|
||||
|
|
Loading…
Reference in a new issue