update code/example panels ('selected' option)
This commit is contained in:
parent
919f119422
commit
92d4b032da
2 changed files with 57 additions and 41 deletions
|
@ -7,6 +7,7 @@ Ox.DocPanel <f> Documentation Panel
|
||||||
(options, self) -> <f> Documentation Panel
|
(options, self) -> <f> Documentation Panel
|
||||||
options <o> Options object
|
options <o> Options object
|
||||||
collapsible <b|true> can be collabsed
|
collapsible <b|true> can be collabsed
|
||||||
|
element <e> Default content
|
||||||
files <a|[]> files to parse for docs
|
files <a|[]> files to parse for docs
|
||||||
getModule <f> returns module for given item
|
getModule <f> returns module for given item
|
||||||
getSection <f> returns section for given item
|
getSection <f> returns section for given item
|
||||||
|
@ -21,12 +22,11 @@ Ox.DocPanel <f> Documentation Panel
|
||||||
|
|
||||||
Ox.DocPanel = function(options, self) {
|
Ox.DocPanel = function(options, self) {
|
||||||
|
|
||||||
// FIXME: defaults should be falsy
|
|
||||||
|
|
||||||
self = self || {};
|
self = self || {};
|
||||||
var that = Ox.Element({}, self)
|
var that = Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
collapsible: true,
|
collapsible: false,
|
||||||
|
element: '',
|
||||||
files: [],
|
files: [],
|
||||||
getModule: function(item) {
|
getModule: function(item) {
|
||||||
return item.file.replace(self.options.path, '');
|
return item.file.replace(self.options.path, '');
|
||||||
|
@ -36,33 +36,38 @@ Ox.DocPanel = function(options, self) {
|
||||||
},
|
},
|
||||||
path: '',
|
path: '',
|
||||||
replace: [],
|
replace: [],
|
||||||
resizable: true,
|
resizable: false,
|
||||||
resize: [128, 256, 384],
|
resize: [128, 256, 384],
|
||||||
|
selected: '',
|
||||||
size: 256
|
size: 256
|
||||||
})
|
})
|
||||||
.options(options || {});
|
.options(options || {});
|
||||||
|
|
||||||
self.$list = Ox.Element();
|
self.$list = Ox.Element();
|
||||||
self.$page = Ox.Element();
|
self.$page = Ox.Element().addClass('OxDocument').append(self.options.element);
|
||||||
|
Ox.print('ELEMENT', self.options.element)
|
||||||
|
|
||||||
that.$element = Ox.SplitPanel({
|
that.setElement(
|
||||||
elements: [
|
self.$panel = Ox.SplitPanel({
|
||||||
{
|
elements: [
|
||||||
collapsible: self.options.collapsible,
|
{
|
||||||
element: self.$list,
|
collapsible: self.options.collapsible,
|
||||||
resizable: self.options.resizable,
|
element: self.$list,
|
||||||
resize: self.options.resize,
|
resizable: self.options.resizable,
|
||||||
size: self.options.size
|
resize: self.options.resize,
|
||||||
},
|
size: self.options.size
|
||||||
{
|
},
|
||||||
element: self.$page
|
{
|
||||||
}
|
element: self.$page
|
||||||
],
|
}
|
||||||
orientation: 'horizontal'
|
],
|
||||||
});
|
orientation: 'horizontal'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
loadList(function(docItems) {
|
loadList(function(docItems) {
|
||||||
self.items = docItems;
|
self.items = docItems;
|
||||||
|
self.options.selected && selectItem(self.options.selected);
|
||||||
that.triggerEvent('load', {});
|
that.triggerEvent('load', {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -129,10 +134,14 @@ Ox.DocPanel = function(options, self) {
|
||||||
});
|
});
|
||||||
self.$list = Ox.TreeList({
|
self.$list = Ox.TreeList({
|
||||||
items: treeItems,
|
items: treeItems,
|
||||||
|
selected: self.options.selected
|
||||||
|
? [self.options.selected] : '',
|
||||||
width: self.options.size - Ox.UI.SCROLLBAR_SIZE
|
width: self.options.size - Ox.UI.SCROLLBAR_SIZE
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
select: selectItem
|
select: function(data) {
|
||||||
|
selectItem(data.ids.length ? data.ids[0] : '')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// fixme
|
// fixme
|
||||||
/*
|
/*
|
||||||
|
@ -156,19 +165,18 @@ Ox.DocPanel = function(options, self) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectItem(data) {
|
function selectItem(id) {
|
||||||
var selected;
|
if (id) {
|
||||||
if (data.ids.length) {
|
self.options.selected = id;
|
||||||
selected = data.ids[0];
|
if (self.options.selected[0] != '_') {
|
||||||
if (selected[0] != '_') {
|
self.$list.options({selected: [id]});
|
||||||
|
Ox.print('OVERWRITTING')
|
||||||
self.$page = Ox.DocPage({
|
self.$page = Ox.DocPage({
|
||||||
item: getItemByName(selected),
|
item: getItemByName(self.options.selected),
|
||||||
replace: self.options.replace
|
replace: self.options.replace
|
||||||
});
|
});
|
||||||
that.$element.replaceElement(1, self.$page);
|
that.$element.replaceElement(1, self.$page);
|
||||||
that.triggerEvent('select', {
|
that.triggerEvent('select', {id: self.options.selected});
|
||||||
id: selected
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,14 +190,13 @@ Ox.DocPanel = function(options, self) {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*@
|
|
||||||
selectItem <f> select item
|
self.setOption = function(key, value) {
|
||||||
(id) -> <u> select an item
|
if (key == 'selected') {
|
||||||
id <s> if of item to select
|
selectItem(value);
|
||||||
@*/
|
}
|
||||||
that.selectItem = function(id) {
|
|
||||||
self.$list.triggerEvent('select', {'ids': [id]});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@ Ox.ExamplePanel = function(options, self) {
|
||||||
path: '',
|
path: '',
|
||||||
replaceCode: [],
|
replaceCode: [],
|
||||||
replaceComment: [],
|
replaceComment: [],
|
||||||
|
selected: '',
|
||||||
size: 256
|
size: 256
|
||||||
})
|
})
|
||||||
.options(options || {})
|
.options(options || {})
|
||||||
|
@ -49,17 +50,18 @@ Ox.ExamplePanel = function(options, self) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
items: self.items,
|
items: self.items,
|
||||||
selected: [self.options.selected],
|
max: 1,
|
||||||
|
selected: self.options.selected
|
||||||
|
? [self.options.selected] : [],
|
||||||
scrollbarVisible: true,
|
scrollbarVisible: true,
|
||||||
sort: ['+title']
|
sort: ['+title']
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
select: function(data) {
|
select: function(data) {
|
||||||
selectExample(data.ids[0] || '');
|
selectItem(data.ids[0] || '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.$panel.replaceElement(0, self.$list);
|
self.$panel.replaceElement(0, self.$list);
|
||||||
selectExample(self.options.selected);
|
|
||||||
that.triggerEvent('load', {});
|
that.triggerEvent('load', {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ Ox.ExamplePanel = function(options, self) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectExample(id) {
|
function selectItem(id) {
|
||||||
var item;
|
var item;
|
||||||
if (id) {
|
if (id) {
|
||||||
item = Ox.getObjectById(self.items, id);
|
item = Ox.getObjectById(self.items, id);
|
||||||
|
@ -111,6 +113,13 @@ Ox.ExamplePanel = function(options, self) {
|
||||||
that.triggerEvent('select', {id: id});
|
that.triggerEvent('select', {id: id});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setOption = function(key, value) {
|
||||||
|
if (key == 'selected') {
|
||||||
|
Ox.print('SETTING LIST SELECTED TO', [value])
|
||||||
|
self.$list.options({selected: [value]});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in a new issue