Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WEB: Hide demos with the same target IDs by default (can be toggled)
Now, only the first demo will be shown from a group of demos with the same target ID. Icons are shown next to each grouped download, which allow the users to open/close the groups (forming virtual "folders"). This simplifies the demos page a lot, without any changes to the existing data. This feature is a progressive enhancement: the demos page will still look the same when Javascript is disabled
- Loading branch information
Showing
5 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "<img src='images/cat-blank.png' class='noSubcat'>"; | ||
} else if (curTarget != prevTarget && curTarget == nextTarget) { | ||
buttonHTML = "<img src='images/subcat-open.png' class='subcatToggle'>"; | ||
} else { | ||
buttonHTML = "<img src='images/cat-blank.png' class='noSubcat'>"; | ||
} | ||
|
||
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"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters