DocPanel: don't empty page when selecting module or section folder

This commit is contained in:
rolux 2012-06-22 09:22:58 +02:00
parent c301a73e38
commit 0200a2478b

View file

@ -274,17 +274,17 @@ Ox.DocPanel = function(options, self) {
? getIcon ? getIcon
: Ox.UI.getImageURL('symbolCenter'), : Ox.UI.getImageURL('symbolCenter'),
items: treeItems, items: treeItems,
selected: self.options.selected selected: self.options.selected ? [self.options.selected] : '',
? [self.options.selected] : '',
width: self.options.size width: self.options.size
}) })
.bindEvent({ .bindEvent({
select: function(data) { select: function(data) {
if (!data.ids[0] || !Ox.endsWith(data.ids[0], '/')) {
selectItem( selectItem(
data.ids.length ? Ox.last(data.ids[0].split('/')) : '', data.ids[0] ? data.ids[0].split('/').pop() : ''
true
); );
} }
}
}); });
self.$sidebar.replaceElement(0, self.$list); self.$sidebar.replaceElement(0, self.$list);
selectItem(self.options.selected); selectItem(self.options.selected);
@ -316,7 +316,7 @@ Ox.DocPanel = function(options, self) {
}); });
} }
function selectItem(id, fromList) { function selectItem(id) {
var item = id ? getItemByName(id) : null; var item = id ? getItemByName(id) : null;
if (item) { if (item) {
self.options.selected = id; self.options.selected = id;
@ -337,10 +337,10 @@ Ox.DocPanel = function(options, self) {
that.triggerEvent('example', data); that.triggerEvent('example', data);
} }
}); });
that.$element.replaceElement(1, self.$page); self.$panel.replaceElement(1, self.$page);
} else { } else {
self.options.selected = ''; self.options.selected = '';
!fromList && self.$list.options({selected: []}); self.$list.options({selected: []});
self.$page.empty().append(self.options.element); self.$page.empty().append(self.options.element);
} }
that.triggerEvent('select', {id: self.options.selected}); that.triggerEvent('select', {id: self.options.selected});