-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/npsinr-elections/edison-c…
- Loading branch information
Showing
6 changed files
with
149 additions
and
142 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,78 @@ | ||
$(() => { | ||
const carousel = $("results-carousel") as JQuery<HTMLElement> & { | ||
carousel(arg: string | number ): void; | ||
const carousel = $("#results-carousel") as JQuery<HTMLElement> & { | ||
carousel(arg: string | number): void; | ||
}; | ||
|
||
let paused = false; | ||
|
||
$(document).keydown((keydown) => { | ||
if (keydown.key === "32") { | ||
carousel.carousel("pause"); | ||
if (keydown.which === 32) { | ||
carousel.carousel(paused ? "cycle" : "pause"); | ||
paused = !paused; | ||
} | ||
}); | ||
/* | ||
$("#playButton").click(() => { | ||
carousel.carousel("cycle"); | ||
|
||
const candidateBlock = $(".candidates-block"); | ||
|
||
candidateBlock.each((_BLOCK_INDEX, blockElem) => { | ||
const block = $(blockElem); | ||
|
||
const cards = block.find(".candidate-card"); | ||
if (cards.length === 4) { | ||
block.addClass("four-cards"); | ||
} | ||
}); | ||
|
||
$("#pauseButton").click(() => { | ||
carousel.carousel("pause"); | ||
})*/ | ||
function isCandidateSlide(to: number): boolean { | ||
return to % 2 === 1; | ||
} | ||
|
||
carousel.on("slid.bs.carousel", | ||
(slide: JQuery.Event<HTMLElement, null> & { from: number, to: number }) => { | ||
if (isCandidateSlide(slide.to)) { | ||
const pollID = (slide.to - 1) / 2; | ||
const block = $(`#block-${pollID}`); | ||
|
||
const cards = block.find(".candidate-card"); | ||
const winners = block.find(".winner"); | ||
const crowns = winners.find(".crown"); | ||
const notWinners = block.find(".not-winner"); | ||
|
||
cards.each((index, cardElem) => { | ||
const card = $(cardElem); | ||
|
||
const votes = { votes: 0 }; | ||
const numVotes = Number(card.attr("data-votes")); | ||
|
||
const voteSpan = $(`#votes-${pollID}-${index}`); | ||
|
||
$(votes).animate({ votes: numVotes }, { | ||
duration: 2000, | ||
easing: "swing", | ||
step: () => { | ||
voteSpan.text(Math.min(Math.ceil(votes.votes), numVotes)); | ||
} | ||
}); | ||
}); | ||
|
||
window.setTimeout(() => { | ||
winners.addClass("candidate-active"); | ||
notWinners.addClass("candidate-inactive"); | ||
crowns.fadeIn("slow"); | ||
}, 2500); | ||
} | ||
|
||
if (isCandidateSlide(slide.from)) { | ||
const block = $(`#block-${(slide.from - 1) / 2}`); | ||
|
||
const winners = block.find(".winner"); | ||
const notWinners = block.find(".not-winner"); | ||
const crowns = winners.find(".crown"); | ||
|
||
winners.removeClass("candidate-active"); | ||
notWinners.removeClass("candidate-inactive"); | ||
crowns.fadeOut("fast"); | ||
} | ||
} | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,142 +1,79 @@ | ||
#lock, | ||
#confirm-page { | ||
background-size: cover; | ||
background-position: center; | ||
background-color: black; | ||
} | ||
|
||
q { | ||
font-style: italic; | ||
opacity: 0.8; | ||
} | ||
|
||
.carousel-item { | ||
height: 100vh; | ||
} | ||
|
||
.candidates-block { | ||
max-width: 80%; | ||
} | ||
|
||
.candidates-vertical-align { | ||
width: 100%; | ||
.poll-detail-vertical-align, .candidates-vertical-align { | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.candidate-card { | ||
min-width: 160px; | ||
max-width: 20vw; | ||
cursor: pointer; | ||
position: relative; | ||
transition: top 0.3s ease-out, opacity 0.3s ease-out; | ||
-webkit-transition: top 0.3s ease-out, opacity 0.3s ease-out; | ||
-moz-transition: top 0.3s ease-out, opacity 0.3s ease-out; | ||
top: 0; | ||
opacity: 0.7; | ||
} | ||
|
||
.candidate-active { | ||
top: -1rem; | ||
.poll-text { | ||
width: 100%; | ||
padding: 3rem 0; | ||
background-color: #FFF; | ||
} | ||
|
||
.candidate-inactive { | ||
q { | ||
font-style: italic; | ||
opacity: 0.7; | ||
} | ||
|
||
.thin-control { | ||
width: 10%; | ||
} | ||
|
||
.winner { | ||
top: -1rem !important; | ||
opacity: 1; | ||
border-color: black; | ||
border-width: 5px; | ||
animation: winners 3s 1 ease-out; | ||
.candidates-block { | ||
width: 80%; | ||
display: flex; | ||
justify-content: center; | ||
margin-bottom: 1.5rem; | ||
} | ||
|
||
@-webkit-keyframes winners { | ||
from { | ||
transform: scale(0.75); | ||
} | ||
to { | ||
transform: scale(1); | ||
} | ||
.candidates-block.four-cards { | ||
width: 60%; | ||
} | ||
|
||
.card-text { | ||
animation: test 3s 1 ease-out; | ||
.card-deck .candidate-card { | ||
position: relative; | ||
top: 0px; | ||
min-width: 10.75rem; | ||
max-width: 11rem; | ||
margin: 0.7rem; | ||
transition: top 1s ease-out; | ||
} | ||
|
||
@-webkit-keyframes test { | ||
from { | ||
transform: scale(0.1); | ||
} | ||
to { | ||
transform: scale(1); | ||
} | ||
.candidate-card.candidate-active { | ||
top: -0.5rem; | ||
} | ||
|
||
img { | ||
height: 50vh; | ||
.candidate-card.candidate-inactive { | ||
opacity: 0.5; | ||
} | ||
|
||
.h3, | ||
.h4 { | ||
color: black; | ||
.candidate-card .card-body { | ||
text-align: left; | ||
} | ||
|
||
#lock { | ||
position: fixed; | ||
z-index: 50; | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
align-items: center; | ||
top: 0; | ||
transition: top 0.3s ease-out; | ||
.votes { | ||
font-size: 1rem; | ||
} | ||
|
||
#lock-text-container { | ||
.candidate-card table { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
background-color: rgb(255, 255, 50); | ||
padding: 3rem 0; | ||
} | ||
|
||
#left-arrow {} | ||
|
||
#confirm-text-container { | ||
width: 80%; | ||
height: 100%; | ||
background-color: #FFF; | ||
padding: 1rem; | ||
} | ||
|
||
#submit-button { | ||
display: none; | ||
} | ||
|
||
#notification { | ||
z-index: 100; | ||
background-color: #FFFF32; | ||
position: fixed; | ||
margin: 1rem auto; | ||
padding: 1rem; | ||
top: 0; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
display: none; | ||
border-radius: 5px; | ||
.candidate-card td { | ||
padding: 0.5rem; | ||
} | ||
|
||
.carousel-indicators li { | ||
background-color: rgba(200, 200, 200, 0.5); | ||
.candidate-card .card-body { | ||
padding: 0; | ||
} | ||
|
||
.carousel-indicators li.active { | ||
background-color: rgba(200, 200, 200, 1); | ||
.crown { | ||
width: 100%; | ||
position: absolute; | ||
font-size: 3rem; | ||
top: -2rem; | ||
color: goldenrod; | ||
display: none; | ||
} |
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
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
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