Ox.DocPage: load inherited properties and events in collapsed state

This commit is contained in:
rolux 2012-07-04 12:43:24 +02:00
parent 459755e51f
commit 2d4ab2b32d

View file

@ -2,13 +2,14 @@
/*@
Ox.DocPage <f> DocPage
([options[, self]]) -> <o:Ox.SplitPanel> DocPage object
example <!> example
options <o> Options object
item <o> doc item
replace <[[]]|[]> See Ox.SyntaxHighlighter
stripComments <b|false> If true, strip comments in source code
self <o> Shared private variable
([options[, self]]) -> <o:Ox.SplitPanel> DocPage object
example <!> Fires when an example was selected
id <s> Id of the selected example
@*/
Ox.DocPage = function(options, self) {
@ -119,7 +120,8 @@ Ox.DocPage = function(options, self) {
}
});
sections.forEach(function(section) {
var className = 'OxLine' + Ox.uid();
var className = 'OxLine' + Ox.uid(),
isExpanded = !Ox.contains(section, 'inherited');
if (item[section]) {
if (section == 'description') {
$elements.push($('<div>')
@ -141,7 +143,11 @@ Ox.DocPage = function(options, self) {
})
.append(
$('<img>')
.attr({src: Ox.UI.getImageURL('symbolDown')})
.attr({
src: isExpanded
? Ox.UI.getImageURL('symbolDown')
: Ox.UI.getImageURL('symbolRight')
})
.css({
width: '12px',
height: '12px',
@ -149,28 +155,25 @@ Ox.DocPage = function(options, self) {
})
.click(function() {
var $this = $(this),
isExpanded = $this.attr('src') == Ox.UI.getImageURL('symbolDown');
isExpanded = $this.attr('src') == Ox.UI.getImageURL('symbolRight');
$this.attr({
src: isExpanded ?
Ox.UI.getImageURL('symbolRight') :
Ox.UI.getImageURL('symbolDown')
src: isExpanded
? Ox.UI.getImageURL('symbolDown')
: Ox.UI.getImageURL('symbolRight')
});
$('.' + className).each(function() {
var $this = $(this);
$this[isExpanded ? 'addClass' : 'removeClass'](className + 'Hidden');
var $this = $(this), isHidden = false;
$this[isExpanded ? 'removeClass' : 'addClass'](className + 'Hidden');
if (isExpanded) {
$this.hide();
} else {
var hidden = false;
Ox.forEach(this.className.split(' '), function(v) {
if (/Hidden$/.test(v)) {
hidden = true;
isHidden = true;
Ox.Break();
}
});
if (!hidden) {
$this.show()
}
!isHidden && $this.show();
} else {
$this.hide();
}
});
})
@ -262,7 +265,11 @@ Ox.DocPage = function(options, self) {
+ (v.name || '') : null;
$elements = $elements.concat(
Ox.map(getItem(v, level + 1, name), function($element) {
return $element.addClass(className);
$element.addClass(className);
if (!isExpanded) {
$element.addClass(className + 'Hidden').hide();
}
return $element;
})
);
});