update test stats ui

This commit is contained in:
rolux 2012-06-12 17:37:35 +02:00
parent b915839305
commit 84d345624f

View file

@ -61,7 +61,7 @@ Ox.DocPanel = function(options, self) {
} }
}); });
self.$toolbar = Ox.Bar({size: 24}); self.$toolbar = Ox.Bar({size: 24}).css({textAlign: 'center'});
self.$list = Ox.Element(); self.$list = Ox.Element();
self.$sidebar = Ox.SplitPanel({ self.$sidebar = Ox.SplitPanel({
elements: [ elements: [
@ -71,22 +71,20 @@ Ox.DocPanel = function(options, self) {
orientation: 'vertical' orientation: 'vertical'
}); });
self.$page = Ox.Element(); self.$page = Ox.Element();
self.$testsStatus = $('<div>')
.css({marginTop: '5px', textAlign: 'center'})
.appendTo(self.$toolbar);
if (!self.options.results) { if (!self.options.results) {
self.options.results = {}; self.options.results = {};
self.$testsButton = Ox.Button({title: 'Run Tests'}) self.$testsButton = Ox.Button({title: 'Run Tests'})
.css({float: 'left', margin: '4px'}) .css({margin: '4px auto'})
.bindEvent({click: runTests}) .bindEvent({click: runTests})
.appendTo(self.$toolbar); .appendTo(self.$toolbar);
self.$testsLabel = Ox.Label({title: 'Running Tests...'}).hide(); self.$testsStatus.hide();
} else { } else {
self.$testsLabel = Ox.Label({title: formatResults()}); self.$testsStatus.html(formatResults());
} }
self.$testsLabel
.css({float: 'left', margin: '4px'})
.appendTo(self.$toolbar);
that.setElement( that.setElement(
self.$panel = Ox.SplitPanel({ self.$panel = Ox.SplitPanel({
elements: [ elements: [
@ -280,8 +278,8 @@ Ox.DocPanel = function(options, self) {
} }
function runTests() { function runTests() {
self.$testsButton.hide(); self.$testsButton.remove();
self.$testsLabel.show(); self.$testsStatus.html('Running tests...').show();
Ox.load({Geo: {}, Image: {}, Unicode: {}}, function() { Ox.load({Geo: {}, Image: {}, Unicode: {}}, function() {
Ox.test(self.options.items, function(results) { Ox.test(self.options.items, function(results) {
results.forEach(function(result) { results.forEach(function(result) {
@ -298,7 +296,7 @@ Ox.DocPanel = function(options, self) {
self.options.results[key][passed]++; self.options.results[key][passed]++;
}); });
}); });
self.$testsLabel.options({title: formatResults()}); self.$testsStatus.html(formatResults());
renderList(); renderList();
that.triggerEvent('tests', {results: self.options.results}); that.triggerEvent('tests', {results: self.options.results});
}); });