Skip to content
This repository has been archived by the owner on Sep 27, 2018. It is now read-only.

Commit

Permalink
Issue #90. Change game filter dropdown to icon list. @wouatcha, you'r…
Browse files Browse the repository at this point in the history
…e next!
  • Loading branch information
Florent Biville committed Feb 19, 2013
1 parent 3da2e3f commit 1da0390
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/main/webapp/WEB-INF/pages/timeline/timeline.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
</h1>
<div id="catContent">
<form action="">
<label id="gameFilterLabel" for="gameFilter">Select a game</label>
<select id="gameFilter" multiple="true">
<ul id="gameFilter">Select a game</p>
<c:forEach var="game" items="${games}">
<option value="<c:out value="${game.id}" />">
<c:out value="${game.title}" />
</option>
<li><img class="gameIcon"
src="<c:out value="${game.iconUrl}" />"
alt="<c:out value="${game.title}" />"
data-game-id="<c:out value="${game.id}" />" />
</li>
</c:forEach>
</select>
</ul>
</form>
<div id="calContent">
<c:choose>
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/static/css/timeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
#arrowRight a { margin-right: 10px; background: url('../img/navNext.png') no-repeat;}

#arrowLeft:hover a, #arrowRight:hover a { opacity:1;}
img.gFImg { width:70px; height:70px;}
img.gFImg { width:70px; height:70px;}

.gameIcon.selected { border:3px solid pink;}
31 changes: 26 additions & 5 deletions src/main/webapp/static/js/pages/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,42 @@ define([
"use strict";

var filterId = "#gameFilter",
iconClass = ".gameIcon",
hasErrors = false;

return {
trigger: function() {
var $icons = $(filterId + " " + iconClass);
hasErrors = sanityChecker.checkIfNotExists(filterId, 'Game filter') || hasErrors;

if (hasErrors) {
logger.error('Script initialization failed due to multiple errors');
} else {
logger.debug('Initializing game filter...');
$(filterId).bind("change", function() {
var selectedGameIds = _.map($(filterId).val(), function(gameId) {
return parseInt(gameId, 10);
}),
allOccurrences = $("article[data-game]");
$icons.click(function() {
var selectedGameIds,
allOccurrences = $("article[data-game]"),
newStatus = ($(this).data("selected") === undefined) ? true : !($(this).data("selected").value);

$(this)
.toggleClass("selected", newStatus)
.data("selected", {value:newStatus});


selectedGameIds = _.map(
_.filter(
$icons,
function(icon) {
var status = $(icon).data("selected");
return !(_.isUndefined(status)) && status.value;
}
),
function(icon) {
return $(icon).data("game-id");
}
);

logger.debug(selectedGameIds);

_.map(allOccurrences, function(occ) {
if(_.indexOf(selectedGameIds, $(occ).data("game")) !== -1) {
Expand Down

0 comments on commit 1da0390

Please sign in to comment.