diff --git a/css/chart.css b/css/chart.css index 8ad180972..78a9c5fc6 100644 --- a/css/chart.css +++ b/css/chart.css @@ -57,24 +57,37 @@ background-color: rgb(153, 153, 153); } -#gameDemos tr { +.gameDemos tr { padding: 0px; } -#gameDemos th { +.gameDemos th { padding: 2px; } -#gameDemos td { +.gameDemos td { padding: 0px 2px; } -#gameDemos td img { +.gameDemos td img.downloadImage { vertical-align: middle; width: 22px; height: 22px; } -#gameDemos .gameTarget { +.gameDemos td img.noSubcat { + vertical-align: middle; + width: 14px; + height: 14px; +} + +.gameDemos td img.subcatToggle { + vertical-align: middle; + width: 14px; + height: 14px; + cursor: pointer; +} + +.gameDemos .gameTarget { width: 15%; } diff --git a/images/subcat-close.png b/images/subcat-close.png new file mode 100644 index 000000000..08f249365 Binary files /dev/null and b/images/subcat-close.png differ diff --git a/images/subcat-open.png b/images/subcat-open.png new file mode 100644 index 000000000..6332fefea Binary files /dev/null and b/images/subcat-open.png differ diff --git a/javascripts/game_demos.js b/javascripts/game_demos.js new file mode 100644 index 000000000..dbcf99f8c --- /dev/null +++ b/javascripts/game_demos.js @@ -0,0 +1,59 @@ +$(document).ready(function () { + hideDuplicates(); + resetDemosTable(); + attachSubcatListeners(); +}); + +function attachSubcatListeners() { + $(".gameDemos .subcatToggle").live("click", function() { + var clickedImage = $(this); + var clickedTarget = $(this).parent().parent().children("td:nth-child(2)").html(); + var doOpen = (clickedImage.attr("src") == "images/subcat-open.png"); + + $(this).parent().parent().nextAll().each(function() { + var curRow = $(this); + var curTarget = curRow.children("td:nth-child(2)").html(); + if (curTarget == clickedTarget) { + if (doOpen) { + clickedImage.attr("src", "images/subcat-close.png"); + curRow.fadeIn("fast", function() { + resetDemosTable(); + }); + } else { + clickedImage.attr("src", "images/subcat-open.png"); + curRow.fadeOut("fast", function() { + resetDemosTable(); + }); + } + } + }); + }); +} + +function hideDuplicates() { + $(".gameDemos tbody tr").each(function() { + var curRow = $(this); + var curTarget = curRow.children("td:nth-child(2)").html(); + var prevTarget = curRow.prev().children("td:nth-child(2)").html(); + var nextTarget = curRow.next().children("td:nth-child(2)").html(); + var buttonHTML = ""; + + if (curTarget == prevTarget) { + curRow.hide(); + buttonHTML = ""; + } else if (curTarget != prevTarget && curTarget == nextTarget) { + buttonHTML = ""; + } else { + buttonHTML = ""; + } + + curRow.children("td:nth-child(1)").html(buttonHTML + curRow.children("td:nth-child(1)").html()); + }); +} + +function resetDemosTable() { + $(".gameDemos").each(function() { + $(this).filter("tbody tr:visible:odd" ).removeClass("color2 color0").addClass("color2"); + $(this).filter("tbody tr:visible:even").removeClass("color2 color0").addClass("color0"); + }); +} diff --git a/templates/game_demos.tpl b/templates/game_demos.tpl index 4e6e9c8e9..5b496f708 100644 --- a/templates/game_demos.tpl +++ b/templates/game_demos.tpl @@ -1,3 +1,6 @@ + + +