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