diff --git a/source/Ox.UI/js/Code/DocPanel.js b/source/Ox.UI/js/Code/DocPanel.js index afe18eda..2122f1bd 100644 --- a/source/Ox.UI/js/Code/DocPanel.js +++ b/source/Ox.UI/js/Code/DocPanel.js @@ -9,22 +9,23 @@ Ox.DocPanel Documentation Panel results [o] Array of results select select options Options object - collapsible If true, the list can be collabsed - element Default content - files Files to parse for docs (alternative to items option) - getModule Returns module for given item - getSection Returns section for given item - items Array of doc items (alternative to files option) - path Path prefix - references RegExp to find references - replace <[[]]|[]> See Ox.SyntaxHighlighter - resizable If true, list is resizable - resize List resize positions - runTests If true, run tests - selected Id of the selected item - showTests If true, show test results in list - showTooltips If true, show test result tooltips in list - size Default list size + collapsible If true, the list can be collabsed + element Default content + expanded If true, modules and sections are expanded in the list + files Files to parse for docs (alternative to items option) + getModule Returns module for given item + getSection Returns section for given item + items Array of doc items (alternative to files option) + path Path prefix + references RegExp to find references + replace <[[]]|[]> See Ox.SyntaxHighlighter + resizable If true, list is resizable + resize List resize positions + runTests If true, run tests + selected Id of the selected item + showTests If true, show test results in list + showTooltips If true, show test result tooltips in list + size Default list size self Shared private variable @*/ @@ -34,9 +35,10 @@ Ox.DocPanel = function(options, self) { var that = Ox.Element({}, self) .defaults({ collapsible: false, - element: '', + element: null, examples: [], examplesPath: '', + expanded: false, files: [], getModule: function(item) { return item.file.replace(self.options.path, ''); @@ -78,9 +80,7 @@ Ox.DocPanel = function(options, self) { self.$testsStatus = $('
') .css({marginTop: '5px', textAlign: 'center'}) .appendTo(self.$toolbar); - if (!self.options.showTests) { - self.$testsStatus.hide(); - } else if (!self.options.results) { + if (!self.options.results) { self.options.results = {}; self.$testsButton = Ox.Button({title: 'Run Tests'}) .css({margin: '4px auto'}) @@ -109,7 +109,7 @@ Ox.DocPanel = function(options, self) { }) ); - if (self.options.files) { + if (self.options.files && self.options.files.length) { self.options.files = Ox.makeArray(self.options.files); self.options.items = Ox.doc(self.options.files.map(function(file) { return self.options.path + file; @@ -147,21 +147,25 @@ Ox.DocPanel = function(options, self) { title = match ? match[1] : 'Untitled'; Ox.get(path + '/js/example.js', function(js) { var references = js.match(self.options.references); - references && Ox.unique(references).forEach(function(reference) { - var item = getItemByName(reference); - if (item) { - item.examples = (item.examples || []).concat( - {id: example, title: title} - ); - } - }); + if (references) { + Ox.unique(references).forEach(function(reference) { + var item = getItemByName(reference); + if (item) { + item.examples = ( + item.examples || [] + ).concat({id: example, title: title}); + } + }); + } if (++i == self.options.examples.length) { self.options.items.forEach(function(item) { - item.examples && item.examples.sort(function(a, b) { - a = a.title.toLowerCase(); - b = b.title.toLowerCase(); - return a < b ? -1 : a > b ? 1 : 0; - }); + if (item.examples) { + item.examples.sort(function(a, b) { + a = a.title.toLowerCase(); + b = b.title.toLowerCase(); + return a < b ? -1 : a > b ? 1 : 0; + }); + } }); callback(); } @@ -270,6 +274,7 @@ Ox.DocPanel = function(options, self) { }); }); self.$list = Ox.TreeList({ + expanded: self.options.expanded, icon: self.options.showTests ? getIcon : Ox.UI.getImageURL('symbolCenter'), @@ -341,7 +346,7 @@ Ox.DocPanel = function(options, self) { } else { self.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}); }