diff --git a/index.js b/index.js index 5ecde1dd..211b14f2 100644 --- a/index.js +++ b/index.js @@ -382,6 +382,7 @@ Ox.load(function() { path: 'dev/', references: /\b(Ox\.[\w\$]+)\b/g, replace: [app.re.code], + results: app.data.testResults || void 0, selected: app.user.item.doc, showTests: true }) @@ -401,6 +402,9 @@ Ox.load(function() { .bindEventOnce({ load: function(data) { app.data.docItems = data.items; + }, + tests: function(data) { + app.data.testResults = data.results; } }); }, diff --git a/source/Ox.UI/js/Code/DocPanel.js b/source/Ox.UI/js/Code/DocPanel.js index 8ecb4434..bf030714 100644 --- a/source/Ox.UI/js/Code/DocPanel.js +++ b/source/Ox.UI/js/Code/DocPanel.js @@ -47,6 +47,7 @@ Ox.DocPanel = function(options, self) { replace: [], resizable: false, resize: [128, 256, 384], + results: null, runTests: false, selected: '', showTests: false, @@ -60,7 +61,9 @@ Ox.DocPanel = function(options, self) { } }); - self.results = {}; + if (!self.options.results) { + self.options.results = {}; + } self.$testsButton = Ox.Button({title: 'Run Tests'}) .css({float: 'left', margin: '4px'}) @@ -109,7 +112,7 @@ Ox.DocPanel = function(options, self) { self.$sidebar.replaceElement(0, self.$toolbar); renderList(); self.options.runTests && runTests(); - that.triggerEvent('load', {items: docItems}); + that.triggerEvent('load', {items: self.options.items}); }); }); } else { @@ -153,8 +156,8 @@ Ox.DocPanel = function(options, self) { } function getIcon(id, expanded) { - var $icon = null, results = self.results[id]; - if (!Ox.isEmpty(self.results)) { + var $icon = null, results = self.options.results[id]; + if (!Ox.isEmpty(self.options.results)) { $icon = Ox.Theme.getColorImage( 'symbol' + (expanded === true ? 'Down' : expanded === false ? 'Right' : 'Center'), !results ? 'none' : results.failed === 0 ? 'passed' : 'failed', @@ -281,13 +284,14 @@ Ox.DocPanel = function(options, self) { item.section ? item.module + '/' + item.section + '/' : [], item.module + '/' + (item.section ? item.section + '/' : '') + item.name ).forEach(function(key) { - self.results[key] = self.results[key] || {passed: 0, failed: 0}; - self.results[key][passed]++; + self.options.results[key] = self.options.results[key] || {passed: 0, failed: 0}; + self.options.results[key][passed]++; }); }); self.$testsLabel.hide(); self.$testsButton.show(); renderList(); + that.triggerEvent('tests', {results: self.options.results}); }); }); }