Skip to content

Commit

Permalink
Replace Select a category with current category.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiancalhoun committed Jan 1, 2013
1 parent 3ddce27 commit 6ba601d
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions ThirdParty/jasmine-1.3.1/jasmine-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jasmine.HtmlReporterHelpers.isSuiteFocused = function(suite) {

return false;
};

jasmine.HtmlReporter = function(_doc) {
var self = this;
var doc = _doc || window.document;
Expand Down Expand Up @@ -227,7 +227,7 @@ jasmine.HtmlReporter = function(_doc) {

var i, matchedCategory = false;

if (focusedCategories && focusedCategories.indexOf('all') !== -1) {
if (focusedCategories && focusedCategories.indexOf('All') !== -1) {

if (typeof spec.categories !== 'undefined') {
if (paramMap.not && spec.categories.indexOf(paramMap.not) !== -1) {
Expand Down Expand Up @@ -429,17 +429,39 @@ jasmine.HtmlReporter.ReporterView = function(dom) {

this.categories = [];

function getCurrentCategoryName() {
var paramMap = [];
var params = jasmine.HtmlReporter.parameters(window.document);

for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}

var categoryNames = paramMap.category;

if (typeof categoryNames === 'undefined') {
return '---';
}

if (typeof paramMap.not !== 'undefined') {
return 'All except ' + paramMap.not;
}

return categoryNames.split(',')[0];
}

this.createCategoryMenu = function() {
this.categoryMenu = this.createDom('span', {className: 'categoryMenu'}, 'Category: ',
this.categorySelect = this.createDom('select', {id: 'categorySelect' },
this.createDom('option', {value: ' '}, 'Select a category'),
this.createDom('option', {value: 'all'}, 'All')), 'Run all but selected:',
this.createDom('option', {value: ' '}, getCurrentCategoryName()),
this.createDom('option', {value: 'All'}, 'All')), 'Run all but selected:',
this.categoryException = this.createDom('input', {type: 'checkbox', id: 'categoryException'}));

this.categorySelect.onchange = function() {
var select = document.getElementById('categorySelect');
if (document.getElementById('categoryException').checked) {
top.location.href = '?category=all&not=' + encodeURIComponent(select.options[select.selectedIndex].value);
top.location.href = '?category=All&not=' + encodeURIComponent(select.options[select.selectedIndex].value);
return false;
}
top.location.href = '?category=' + encodeURIComponent(select.options[select.selectedIndex].value);
Expand Down

0 comments on commit 6ba601d

Please sign in to comment.